This is a simple task manager that allows you to run CRUD against task table using HTTP as well as WebSocket.io.
It is built using NestJS and TypeORM, and it uses RabbitMQ for event-driven communication between microservices.
+----------+ HTTP/WebSocket +-------------------------+
| | <--------------------- | |
| Client | | Backend Facing Frontend |
| | ---------------------> | |
+----------+ +-------------------------+
|
| gRPC
|
v
+------------------------+
| |
| Task Manager |
| |
+------------------------+
| |
| |
------ ------
| |
v v
+------------+ +------------+
| | | |
| PostgreSQL | | RabbitMQ |
| | | |
+----------- + +------------+
|
|
v
+------------+
| |
| Logger |
| |
+------------+
-
Nashville (Backend Facing Frontend) Microservice: Handles incoming requests from the client and forwards them to the Gallatin microservice.
-
Gallatin (Task Manager) Microservice: Handles task-related operations (CRUD) and emits events to the Ashland microservice.
-
Ashland (Logger) Microservice: Listens for events from the Gallatin microservice and logs them to the console.
-
Client Microservice: A simple client that interacts with the Nashville microservice over WebSocket.io.
- Add new tasks
- Delete existing tasks
- Event-driven architecture using RabbitMQ
Before you begin, ensure you have met the following requirements:
- Node.js (>= 20.16.0)
- Yarn (>= 1.22.19)
- Docker (for RabbitMQ)
-
Clone the repository:
git clone https://github.com/faizahmedfarooqui/nestjs-rabbitmq-task-manager.git cd nestjs-rabbitmq-task-manager
-
Install dependencies:
yarn install
-
Set up RabbitMQ:
You can run RabbitMQ using Docker:
docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management # Access the RabbitMQ management console at http://localhost:15672 # Username: guest # Password: guest
-
Configure Variables:
- Goto "services/gallatin-task-manager/src/app.module.ts" and update the RabbitMQ & PostgreSQL configs
- Goto "services/ashland-logger/src/main.ts" and update the RabbitMQ configs
-
Run the Nashville (Backend Facing Frontend) Microservice:
yarn start:nashville
-
Run the Gallatin (Task Manager) Microservice:
yarn start:gallatin
-
Run the Ashland (Logger) Microservice:
yarn start:ashland
-
Run the Client Microservice:
yarn start:client
To run tests, you can use the following command:
-
Run all tests of Gallatin Task Manager MicroService
yarn test:gallatin
-
Run all tests of Nashville BFF MicroService
yarn test:nashville
-
Run all tests of Ashland Logger MicroService
yarn test:ashland
Once the application is running, you can access the API at http://localhost:3000
. Use a tool like Postman or cURL to interact with the API endpoints.
You can refer "TaskManager.postman_collection.json" file for the Postman collection.
- GET /tasks: Retrieve all tasks (with Pagination)
- GET /tasks/{id}: Retrieve a task
- POST /tasks: Create a new task
- DELETE /tasks/:id: Delete a task by ID
- PUT /tasks/:id: Update a Task by ID
You can use the client to interact with the Nashville microservice over WebSocket.io.
-
Connect to the WebSocket server:
yarn start:client
-
Use the following events to interact with the Nashville microservice:
- createTask
- listAllTasks
- listTask
- updateTask
- deleteTask
Refer to the client.ts file for more details.
Contributions are always welcome! Please follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature
) - Commit your changes (
git commit -m 'Add some feature'
) - Push to the branch (
git push origin feature/your-feature
) - Create a Pull Request
This project is licensed under the MIT License. See the LICENSE file for details.
If you have any questions or suggestions, feel free to raise an issue.
Happy coding!