# mutual-de-servicios-al-policia/muserpol-ms architecture

> Architecture diagram of the GitHub repository mutual-de-servicios-al-policia/muserpol-ms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mutual-de-servicios-al-policia/muserpol-ms
- Repository: https://github.com/mutual-de-servicios-al-policia/muserpol-ms

## Overview

The project is clearly a microservices-based system where each major functionality is split into its own isolated service. The file structure shows several microservice directories (auth-microservice, beneficiary-microservice, general-microservice, kiosk-microservice) along with a microservice-gateway that likely acts as the API gateway or reverse proxy to orchestrate requests among these services. The README further confirms that each microservice is maintained as a Git submodule, which emphasizes a distributed development approach. Docker Compose files (for development and production) indicate that the entire system is containerized.

##### Main Components
- API Gateway (microservice-gateway): This is likely the primary entry point for client requests and routes them to the appropriate microservice.
- Individual Microservices:
- Auth Service (auth-microservice): Manages authentication and possibly authorization.
- Beneficiary Service (beneficiary-microservice): Handles operations related to beneficiaries.
- General Service (general-microservice): Likely takes care of common/shared functionalities.
- Kiosk Service (kiosk-microservice): Manages functionalities related to kiosk operations.
- Database(s): Although not present as a directory, the README’s mention about ensuring the database has the required schemas for each microservice implies that each microservice might have its own schema or even its own database. Represent these explicitly.
- Supporting Infrastructure: Docker environments (using docker-compose for development and production) and environment configurations (.env files).

##### Relationships and Interactions
- API Gateway as the façade that receives external requests and routes these to corresponding microservices.
- Each microservice should be depicted as a separate container that communicates via REST, RPC, or messaging as per your implementation details.
- Relationship with the database(s) – each service connects to its designated schema/database.

##### Architectural Patterns
- Microservices architecture with containerization (Docker).
- Use of Git submodules indicates modularity and independent version control for each microservice.
- The separation into different environments (development vs. production) shows environmental configuration and deployment separation.

##### Relevant Technologies and Frameworks
- Docker Compose for container orchestration.
- Environment configuration management through .env files.
- Git submodules for managing distributed repositories; this also might impact CI/CD pipelines if present.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client["External Client"]:::external

    %% API Gateway Layer
    subgraph "API Layer"
        APIGateway["API Gateway"]:::gateway
    end

    %% Microservices Layer
    subgraph "Microservices Layer"
        AuthService["Auth Service"]:::microservice
        BeneficiaryService["Beneficiary Service"]:::microservice
        GeneralService["General Service"]:::microservice
        KioskService["Kiosk Service"]:::microservice
    end

    %% Databases Layer
    subgraph "Databases"
        AuthDB(("Auth Database")):::database
        BeneficiaryDB(("Beneficiary Database")):::database
        GeneralDB(("General Database")):::database
        KioskDB(("Kiosk Database")):::database
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        DockerDev["Development Docker Environment"]:::docker
        DockerProd["Production Docker Environment"]:::docker
        EnvConfig["Environment Configuration"]:::env
        GitSubmodules["Git Submodules Management"]:::git
    end

    %% External Request Flow
    Client -->|"requests"| APIGateway

    %% API Gateway Routing
    APIGateway -->|"routes"| AuthService
    APIGateway -->|"routes"| BeneficiaryService
    APIGateway -->|"routes"| GeneralService
    APIGateway -->|"routes"| KioskService

    %% Microservices to Databases
    AuthService -->|"connects"| AuthDB
    BeneficiaryService -->|"connects"| BeneficiaryDB
    GeneralService -->|"connects"| GeneralDB
    KioskService -->|"connects"| KioskDB

    %% Inter-service Communication (e.g., Auth Service token verification)
    AuthService -.->|"verifies"| BeneficiaryService
    AuthService -.->|"verifies"| GeneralService
    AuthService -.->|"verifies"| KioskService

    %% Infrastructure Orchestration and Configuration
    DockerDev ---|"orchestrates"| APIGateway
    DockerDev ---|"orchestrates"| AuthService
    DockerDev ---|"orchestrates"| BeneficiaryService
    DockerDev ---|"orchestrates"| GeneralService
    DockerDev ---|"orchestrates"| KioskService

    DockerProd ---|"orchestrates"| APIGateway
    DockerProd ---|"orchestrates"| AuthService
    DockerProd ---|"orchestrates"| BeneficiaryService
    DockerProd ---|"orchestrates"| GeneralService
    DockerProd ---|"orchestrates"| KioskService

    EnvConfig ---|"configures"| APIGateway
    EnvConfig ---|"configures"| AuthService
    EnvConfig ---|"configures"| BeneficiaryService
    EnvConfig ---|"configures"| GeneralService
    EnvConfig ---|"configures"| KioskService

    GitSubmodules ---|"manages"| APIGateway
    GitSubmodules ---|"manages"| AuthService
    GitSubmodules ---|"manages"| BeneficiaryService
    GitSubmodules ---|"manages"| GeneralService
    GitSubmodules ---|"manages"| KioskService

    %% Styles
    classDef external fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef gateway fill:#66ccff,stroke:#333,stroke-width:2px;
    classDef microservice fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef database fill:#ff9999,stroke:#333,stroke-width:2px, font-style:italic;
    classDef docker fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef env fill:#ffccff,stroke:#333,stroke-width:2px;
    classDef git fill:#ffffcc,stroke:#333,stroke-width:2px;

    %% Click Events for Component Mapping
    click APIGateway "https://github.com/mutual-de-servicios-al-policia/muserpol-ms/tree/main/microservice-gateway"
    click AuthService "https://github.com/mutual-de-servicios-al-policia/muserpol-ms/tree/main/auth-microservice"
    click BeneficiaryService "https://github.com/mutual-de-servicios-al-policia/muserpol-ms/tree/main/beneficiary-microservice"
    click GeneralService "https://github.com/mutual-de-servicios-al-policia/muserpol-ms/tree/main/general-microservice"
    click KioskService "https://github.com/mutual-de-servicios-al-policia/muserpol-ms/tree/main/kiosk-microservice"
    click DockerDev "https://github.com/mutual-de-servicios-al-policia/muserpol-ms/blob/main/docker-compose.yml"
    click DockerProd "https://github.com/mutual-de-servicios-al-policia/muserpol-ms/blob/main/docker-compose.prod.yml"
    click EnvConfig "https://github.com/mutual-de-servicios-al-policia/muserpol-ms/blob/main/.env.example"
    click GitSubmodules "https://github.com/mutual-de-servicios-al-policia/muserpol-ms/blob/main/.gitmodules"
```
