Skip to the content.

Fullstack > Architecture > 🌐 Microservices

Microservices is an architectural style that structures an application as a collection of small, loosely coupled services, which can be developed, deployed, and scaled independently. Each service in a microservices architecture focuses on a specific business capability and can be built and deployed independently.


❓ Why Microservices?

Microservices offer several advantages, particularly for complex, large-scale applications:


🧩 Microservices Components

1️⃣ Service

A service is a core component of the microservices architecture. It performs a specific business function and is typically responsible for a single module or domain of the application. Each service is designed to be:


2️⃣ API Gateway

The API Gateway is a crucial component in a microservices architecture. It serves as a single entry point for all client requests and is responsible for routing requests to the appropriate service.

Responsibilities include:


3️⃣ Service Registry and Discovery

In a microservices architecture, services need to discover each other to communicate. A Service Registry (e.g., Eureka, Consul) keeps track of the available services and their locations.


4️⃣ Database per Service

Each microservice has its own database or persistence layer, which can be a different database type based on the service’s needs (SQL, NoSQL, etc.).

Benefits include:


5️⃣ Communication Between Services

Services in a microservices architecture communicate with each other via lightweight communication mechanisms, typically HTTP, REST APIs, or messaging queues (e.g., Kafka, RabbitMQ).


🌍 Microservices in Fullstack Applications

Backend (Spring Boot + Microservices)

Frontend (Angular)


πŸ“‚ Folder Structure Example


microservices-app/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ service-a/
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”‚   β”œβ”€β”€ application.yml
β”‚   β”œβ”€β”€ service-b/
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”‚   β”œβ”€β”€ application.yml
β”‚   β”œβ”€β”€ api-gateway/
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   └── application.yml
β”‚   β”œβ”€β”€ service-registry/
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   └── application.yml
β”‚   └── docker-compose.yml
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/app/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ app.module.ts
β”‚   └── main.ts
└── docker-compose.yml