This is a Node.js assignment developed by Sagar Kapoor. The project demonstrates various backend technologies and practices for building a robust application.
- TypeScript
- MongoDB
- Redis
- Express
- Mongoose
- Node.js
To run this project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/SagarKapoorin/Guestara-Nodejs-Assignment
-
Navigate to the project directory:
cd Guestara-Nodejs-Assignment -
Install dependencies:
npm install
-
Build the project:
npm run build
-
Run the development server:
npm run dev
Before running the application, ensure to set the following environment variables in a .env file:
PORT=<your_port>
MONGO_URL=<your_mongo_db_connection_string>
REDIS_URL=<your_redis_connection_string>
- CRUD operations for categories, items, and subcategories.
- Caching with Redis for improved performance.
- Rate limiting using Redis.
- MongoDB indexing on the name field for optimized queries.
- Clustering with PM2 for better load handling.
- Type safety using Zod and TypeScript.
- Aggregation pipeline setup for advanced data manipulation.
- Inline comments and proper error handling for maintainability.
This project employs several strategies for optimization and performance:
- Redis for Caching: Reduces database load by caching frequently accessed data.
- Redis for Rate Limiting: Prevents abuse of the API by limiting the number of requests.
- MongoDB Indexing: Enhances query performance by indexing the
namefield. - PM2 Clustering: Allows the application to utilize multiple CPU cores effectively.
- Zod for Type Safety: Ensures the integrity of data throughout the application.
- Aggregation Pipeline Setup: Enables complex data retrieval and transformation.
- Inline Comments and Proper Error Handling: Improves code readability and maintainability.
The application supports the following routes:
- Add Category:
/category - Add Item:
/items - Add Subcategory:
/subcategory
Watch the project overview video here.
You can try the live application here.
For the complete source code, visit the GitHub repository.