Skip to content

A Twitter like application (Proof of Concept) in Nestjs, Google OAuth and Postgres

License

Notifications You must be signed in to change notification settings

neerajkumar161/twitty

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Twitty (Proof of Concept)

Overview

This project is a backend service for a small Twitter-like application built using NestJS. The application focuses on core features like user management, tweet functionalities, following system, and timeline generation, using PostgreSQL for data storage and Google OAuth for authentication.

Features

  • User Management:

    • User registration and login using Firebase.
    • Profile management.
    • Follow and unfollow functionality.
  • Tweet Functionality:

    • Post tweets (text only).
    • Like and retweet tweets.
  • Timeline:

    • View timeline with tweets from followed users.
    • Pagination support.
  • API Documentation:

    • Documentation generated using Swagger.

Tech Stack

Getting Started

Prerequisites

  • Node.js (v18+)
  • PostgreSQL
  • Google Cloud Project

Installation

  1. Clone the Repository:

    git clone /~https://github.com/neerajkumar161/twitty
    cd twitty
  2. Install Dependencies:

    npm install
  3. Set Up Environment Variables: Create a .env file in the root of the project and add the following variables:

    DB_HOST = <DB_HOST>
    DB_USERNAME = <DB_USERNAME>
    DB_PASSWORD = <DB_PASSWORD>
    DB_NAME = <DB_NAME>
    GOOGLE_CLIENT_ID = <GOOGLE_CLIENT_ID>
    JWT_SCRET_KEY = <JWT_SECRET_KEY>
  4. Configure Google OAuth Concent Screen. Read More. Also don't forget to Add Test users in order to login using Google.

  5. Build the Application:

      npm run build
      npm run start:prod
  6. Start the Application in Development:

     npm run start:dev
  7. Access API Documentation: Open your browser and navigate to http://localhost:3000/api to view the Swagger documentation.

Project Structure

├── src
│   ├── auth        // Contains authentication logic using Google Auth.
│   ├── decorators  // Swagger API combined decorator
│   ├── filters     // Nestjs Filters for Error handling
│   ├── timeline    // Generates user timelines with pagination.
│   ├── tweet       // Manages tweet creation, liking, and retweeting.
│   ├── user        // Handles user management, including profiles and following system
│   └── main.ts
├── test
├── .env
├── .gitignore
├── nest-cli.json
├── package.json
└── README.md

API Endpoints

Authentication

  • POST /auth/google: Register or Login a user using Google.

User Profile and follow

  • GET /users/profile: Fetch a user’s profile.
  • POST /users/follow/:userId: Follow a user.
  • DELETE /users/unfollow/:userId: Unfollow a user.

Tweet Functionality

  • POST /tweets: Post a new tweet.
  • POST /tweets/like: Like a tweet.
  • POST /tweets/retweet: Retweet a tweet.

User Timeline

  • GET /timeline: Get the current user’s timeline with pagination.

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For any inquiries, please contact via Email.

About

A Twitter like application (Proof of Concept) in Nestjs, Google OAuth and Postgres

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published