A progressive Node.js framework for building efficient and scalable server-side applications.
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.
-
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.
- Backend Framework: NestJS
- Database: PostgreSQL with TypeORM
- Authentication: Google Auth
- API Documentation: Swagger
- Node.js (v18+)
- PostgreSQL
- Google Cloud Project
-
Clone the Repository:
git clone /~https://github.com/neerajkumar161/twitty cd twitty
-
Install Dependencies:
npm install
-
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>
-
Configure Google OAuth Concent Screen. Read More. Also don't forget to Add Test users in order to login using Google.
-
Build the Application:
npm run build npm run start:prod
-
Start the Application in Development:
npm run start:dev
-
Access API Documentation: Open your browser and navigate to
http://localhost:3000/api
to view the Swagger documentation.
├── 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
- POST
/auth/google
: Register or Login a user using Google.
- GET
/users/profile
: Fetch a user’s profile. - POST
/users/follow/:userId
: Follow a user. - DELETE
/users/unfollow/:userId
: Unfollow a user.
- POST
/tweets
: Post a new tweet. - POST
/tweets/like
: Like a tweet. - POST
/tweets/retweet
: Retweet a tweet.
- GET
/timeline
: Get the current user’s timeline with pagination.
Contributions are welcome! Please feel free to submit a pull request or open an issue.
This project is licensed under the MIT License. See the LICENSE file for details.
For any inquiries, please contact via Email.