A production-ready NestJS application for managing tasks with features like authentication, caching, message queues, and background job processing.
- User authentication and authorization using JWT
- CRUD operations for tasks
- Redis caching for frequently accessed data
- RabbitMQ for event-driven architecture
- Bull queue for background job processing
- Swagger API documentation
- Rate limiting
- Graceful shutdown handling
task-sync/
├── src/
│ ├── auth/ # Authentication module
│ │ ├── decorators/
│ │ ├── dto/
│ │ ├── guards/
│ │ ├── interfaces/
│ │ ├── strategies/
│ │ ├── auth.controller.ts
│ │ ├── auth.module.ts
│ │ └── auth.service.ts
│ ├── common/
│ │ ├── exceptions/
│ │ ├── filters/
│ │ ├── interceptors/
│ │ └── interfaces/
│ ├── config/
│ │ └── configuration.ts
│ ├── tasks/
│ │ ├── dto/
│ │ ├── entities/
│ │ ├── interfaces/
│ │ ├── tasks.controller.ts
│ │ ├── tasks.module.ts
│ │ ├── tasks.service.ts
│ │ └── task.processor.ts
│ ├── users/
│ │ ├── dto/
│ │ ├── entities/
│ │ ├── users.controller.ts
│ │ ├── users.module.ts
│ │ └── users.service.ts
│ ├── app.module.ts
│ └── main.ts
├── test/ # Testing
├── .env # Environment variables
├── .env.example # Example environment variables
├── .gitignore
├── package.json
├── tsconfig.json
└── README.md
- Node.js (v16 or later)
- PostgreSQL
- Redis
- RabbitMQ
- Clone the repository:
git clone https://github.com/yourusername/task-sync.git
cd task-sync
- Install dependencies:
npm install
- Create a PostgreSQL database:
CREATE DATABASE task_sync;
- Configure environment variables:
cp .env.example .env
# Edit .env with your configuration
- Start the development server:
npm run start:dev
- Access the API documentation:
http://localhost:3000/api
- POST /auth/register - Register a new user
- POST /auth/login - Login user
- GET /tasks - Get all tasks
- GET /tasks/:id - Get a specific task
- POST /tasks - Create a new task
- PATCH /tasks/:id - Update a task
- DELETE /tasks/:id - Delete a task
- PATCH /tasks/:id/complete - Mark a task as completed
To run the application using Docker:
- Build the Docker image:
docker build -t task-sync .
- Run the container:
docker run -p 3000:3000 task-sync
Run the test suite:
npm test
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.