Skip to content

This project is developed using a microservices architecture. The system consists of user security, license management, file management, and object storage services. Each service operates independently and is responsible for a specific function.

Notifications You must be signed in to change notification settings

ertugruldege/microservice-architecture-case

Repository files navigation

Microservice Architecture

This project is developed using a microservices architecture. The system consists of user security, license management, file management, and object storage services. Each service operates independently and is responsible for a specific function.

📌 General Architecture

The project consists of four core microservices:

  1. Security Service 🛡️

    • Responsible for user registration and authentication.
    • Notifies the License Service when a new user registers.
  2. License Service 🔑

    • Assigns licenses to users (e.g., 30-day demo license).
    • Tracks user file upload quotas and daily upload limits.
    • Monitors upload/delete operations from the File Management Service and updates quotas accordingly.
  3. Object Storage Service 📦

    • Creates S3/MinIO buckets for users based on information from License Service.
    • Manages bucket and access permissions according to user license details.
  4. File Management Service 📂

    • Manages user file uploads, downloads, listing, and deletions.
    • Checks quotas and limits via the License Service.
    • Notifies the License Service upon file operations.

🛠️ Event-Driven Development (EDD) Approach

This project is built using the Event-Driven Development (EDD) architecture. Services communicate with each other through an event-based system rather than direct calls. This enables each service to scale independently.

User creation and File Management Process

🎯 Example Workflow

  1. When a new user is registered in Security Service, a UserCreated event is published.
  2. License Service listens to this event, assigns a 30-day demo license, and publishes a LicenseCreated event.
  3. Object Storage Service listens to the LicenseCreated event and creates a bucket for the user.
  4. When a user uploads a file, File Management Service publishes a FileUploaded event, which the License Service listens to update the quota.

This architecture is supported by RabbitMQ message queues.

🚀 Setup and Execution

To run the project, use the following Docker and Makefile commands.

1️⃣ Start the Services

Start all microservices using Docker Compose:

make up

Then complete the installation with:

make install

This command will build the base image and launch all services.

2️⃣ Stop the Services

To shut down all services:

make down

3️⃣ Start Queue Processes

Run the following commands to start the queue workers for each service:

make security-queue
make license-queue
make object-storage-queue

🛠️ Purpose of Queue Processes

Security Service Queue: Publishes the UserCreated event when a user is created. This event triggers email notifications and license creation.

License Service Queue: Manages the license creation process. Monitors user activities and updates license information. Notifies the Object Storage Service.

Object Storage Queue: Handles user bucket creation and file management operations. Uses information from License Service to manage Object Storage Service.

Connect to Services

Use the following commands to access each service:

make bash security
make bash license
make bash file-management
make bash object-storage

📂 Project Structure

project-root/
│── security/            # User registration and authentication service
│   ├── app/             
│   ├── Dockerfile       # Dockerfile for Security service
│   ├── ...              
│── license/             # License management service
│   ├── app/
│   ├── Dockerfile       # Dockerfile for License service
│   ├── ...
│── file-management/     # File management service
│   ├── app/
│   ├── Dockerfile       # Dockerfile for File Management service
│   ├── ...
│── object-storage/      # MinIO and storage service
│   ├── app/
│   ├── Dockerfile       # Dockerfile for Object Storage service
│   ├── ...
│── docker-compose.yml   # Docker Compose configuration for all services
│── Dockerfile-base      # Base Docker image for all microservices
│── Makefile             # Makefile for management commands

🔍 Technologies Used

  • PHP 8.4 and Laravel 11
  • Docker & Docker Compose
  • PostgreSQL 16
  • RabbitMQ 4 (Management Edition)
  • MinIO (AWS S3-compatible storage)

🏗️ Docker Compose Configuration

Service configurations:

  • Security Servicelocalhost:3000
  • License Servicelocalhost:3001
  • File Management Servicelocalhost:3002
  • Object Storage Servicelocalhost:3003
  • PostgreSQLlocalhost:5432
  • RabbitMQlocalhost:5672 (Management UI: localhost:15672)
  • MinIOlocalhost:9000 (Console: localhost:9001)

🔍 API Endpoints

Service Endpoint Method
Security /api/security/v1/users POST
/api/security/v1/login POST
/api/security/v1/me GET
File Management /api/fms/v1/files GET
/api/fms/v1/files POST
/api/fms/v1/files/{id}/delete DELETE
/api/fms/v1/files/{id}/download GET
License /api/license/v1/me GET

📌 Code Analysis (Static Code Analysis)

To ensure code quality and security, PHPStan is used for static code analysis. Run the following commands to perform static analysis for each service:

make security-static-code-analysis
make license-static-code-analysis
make file-management-static-code-analysis
make object-storage-static-code-analysis

📌 Testing

Run tests using the following commands:

make test-security

📌 Postman Collection Link: Microservice Architecture Case

About

This project is developed using a microservices architecture. The system consists of user security, license management, file management, and object storage services. Each service operates independently and is responsible for a specific function.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages