A scalable microservices architecture for managing posts and comments, built with JavaScript. Each service is independently deployable, making it easy to scale and maintain. Perfect for learning or production use!
- Overview
- Architecture
- Services
- Getting Started
- Running the Project
- API Endpoints
- Contributing
- License
This repository contains microservices for handling posts and comments. Each service is a standalone Node.js application, communicating via HTTP (or other protocols, depending on your implementation).
- Post Service: Manages post creation, retrieval, and deletion.
- Comment Service: Handles comment operations linked to posts.
- Gateway/API Service: Routes requests to the appropriate backend services.
- (Optional) Database: Each service can connect to its own database (MongoDB, PostgreSQL, etc.).
post-service/comment-service/api-gateway/shared/(common utilities, if any)
git clone https://github.com/thezaidsheikh/Post-Comment-Microservices.git
cd Post-Comment-MicroservicesNavigate into each service and install dependencies:
cd post-service
npm install
cd ../comment-service
npm install
cd ../api-gateway
npm installYou can run each service in a separate terminal:
# Terminal 1: Post Service
cd post-service
npm run start
# Terminal 2: Comment Service
cd comment-service
npm run start
# Terminal 3: API Gateway
cd api-gateway
npm run startOr use concurrently to run all at once (if configured):
npm run devEach service may require environment variables. Create .env files in each service directory as needed:
# Example .env file
PORT=4000
DATABASE_URL=mongodb://localhost:27017/posts| Service | Endpoint Example | Description |
|---|---|---|
| Post Service | POST /posts |
Create a new post |
| Comment Service | POST /posts/:postId/comments |
Add comment to a post |
| API Gateway | /api/posts, /api/comments |
Unified access point |
To run all services with Docker Compose (if docker-compose.yml is included):
docker-compose up --buildPull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License. See the LICENSE file for details.
Happy coding! ✨
Let me know if you want more specific details for each service, or if you need help writing Docker Compose or .env samples!