This project implements a microservices architecture using Spring Boot and MongoDB. The system consists of multiple microservices that work together to provide a complete blog platform functionality. The services are containerized using Docker for easy deployment and scaling.
To clone the repository:
git clone https://github.com/developer-shubham101/microservices-architecture.git
cd microservices-architecture
For a deep dive into Spring Boot concepts and best practices, check out our comprehensive documentation:
The project consists of the following microservices:
-
Service Discovery (Port: 8761)
- Eureka server for service registration and discovery
- Central registry for all microservices
-
API Gateway (Port: 8084)
- Single entry point for all client requests
- Routes requests to appropriate microservices
- Handles cross-cutting concerns
-
User Service (Port: 7072)
- Manages user-related operations
- Handles user authentication and authorization
-
Blog Info Service (Port: 7070)
- Manages blog post information
- Handles blog content and metadata
-
Blog Business Service (Port: 7071)
- Handles business logic for blog operations
- Processes blog-related transactions
-
Blog Comments Service (Port: 7075)
- Manages blog comments
- Handles comment-related operations
-
MongoDB (Port: 27017)
- Primary database for all services
- Stores data in a distributed manner
- Java 11+
- Maven
- Docker and Docker Compose
- MongoDB (included in Docker setup)
The easiest way to run the entire system is using Docker Compose. This will start all services with the correct configuration and networking.
- Make sure Docker and Docker Compose are installed on your system
- From the project root directory, run:
docker-compose up --build
Or to run in detached mode:
docker-compose up -d
Once all services are running, you can access them at:
- Service Discovery Dashboard: http://localhost:8761
- API Gateway: http://localhost:8084
- Swagger UI (if available): http://localhost:8084/swagger-ui/index.html
The services communicate with each other through the API Gateway, which routes requests to the appropriate microservice. The Service Discovery (Eureka) server helps in locating services dynamically.
MongoDB is used as the primary database, running in a Docker container. Each service can have its own database or share the same database with different collections, depending on the implementation.
To build a specific service:
cd <service-directory>
./mvnw clean install
For local development, you can run services individually:
- Start MongoDB (if not using Docker)
- Start the Service Discovery server
- Start the API Gateway
- Start other services as needed
Update the application.properties
in each service to point to the correct MongoDB instance and other service URLs.
API documentation is available through Swagger UI when accessing the API Gateway. The documentation includes all available endpoints and their usage.
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.