Skip to content

thezaidsheikh/Post-Comment-Microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Post-Comment Microservices 🚀

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!

Table of Contents 📚


Overview 📝

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).

Architecture 🏗️

  • 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.).

Services 🔧

  • post-service/
  • comment-service/
  • api-gateway/
  • shared/ (common utilities, if any)

Getting Started 🚦

Prerequisites

  • Node.js (v16 or above recommended)
  • npm
  • (Optional) Docker 🐳 for containerization

Clone the Repository

git clone https://github.com/thezaidsheikh/Post-Comment-Microservices.git
cd Post-Comment-Microservices

Install Dependencies

Navigate into each service and install dependencies:

cd post-service
npm install

cd ../comment-service
npm install

cd ../api-gateway
npm install

Running the Project ▶️

Start All Services

You 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 start

Or use concurrently to run all at once (if configured):

npm run dev

Environment Variables

Each 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

API Endpoints 🌐

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

Docker Support 🐳

To run all services with Docker Compose (if docker-compose.yml is included):

docker-compose up --build

Contributing 🤝

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.


License 📄

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!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors