# hawerforerouniandes/electivamicroservicios architecture

> Architecture diagram of the GitHub repository hawerforerouniandes/electivamicroservicios, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hawerforerouniandes/electivamicroservicios
- Repository: https://github.com/hawerforerouniandes/electivamicroservicios

## Overview

##### Project type and purpose
- This is a microservices‐based backend example (“fotoalpes-microservices-examples”) split into three domain services: usuarios, productos, and ordenes.
- Each service exposes REST endpoints for CRUD operations on its resource and maintains its own database.
- Services communicate asynchronously via a messaging queue to propagate updates and maintain eventual consistency.
- An API Gateway sits in front of the trio to route incoming HTTP calls.

##### File structure
- Top‐level README.md describes all services and the asynchronous communication pattern.
- The usuarios directory contains:
- Dockerfile (to containerize the service)
- app.py (Flask or similar HTTP server)
- models.py (ORM definitions)
- instance/database.db (local SQLite store)
- requirements.txt (Python dependencies)
- __pycache__ (compiled bytecode)
- By analogy, productos and ordenes directories (not shown) follow the same layout.
- No frontend code or monolith—purely backend microservices.

##### README for additional insights
- Lists each domain’s operations (create, list, consult, modify).
- Specifies that each service keeps a copy of other services’ schemas in its DB and updates it via message bus.
- Mentions “API Gateway” but no implementation details inside this repo.

##### Elements
- Clear, human‐readable labels for every component (API Gateway, Service A, DB A, Message Broker, etc.).

##### Capturing essential details
- That each service has its own Docker container, code, and database.
- Which events trigger which updates (e.g., “usuarios publishes user.updated → ordenes updates its user copy”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    Client["Client"]:::client

    %% API Gateway
    APIGateway["API Gateway"]:::gateway

    %% Project Documentation
    README["Project README"]:::doc

    %% Microservices Layer
    subgraph "Microservices"
        subgraph "Usuarios Service"
            direction TB
            UApp["app.py"]:::file
            UModels["models.py"]:::file
            UReq["requirements.txt"]:::file
            UDocker["Dockerfile"]:::file
            UDBfile["database.db"]:::file
        end
        US_DB["Usuarios DB"]:::db

        subgraph "Productos Service"
            PS["Productos Service"]:::service
        end
        PP["Productos DB"]:::db

        subgraph "Ordenes Service"
            OS["Ordenes Service"]:::service
        end
        OP["Ordenes DB"]:::db
    end

    %% Message Broker
    MB["Message Broker"]:::broker

    %% HTTP Flow
    Client -->|HTTP| APIGateway
    APIGateway -->|Route to Usuarios| UApp
    APIGateway -->|Route to Productos| PS
    APIGateway -->|Route to Ordenes| OS

    %% Service to their DB
    UApp -->|CRUD| US_DB
    PS -->|CRUD| PP
    OS -->|CRUD| OP

    %% Asynchronous Messaging
    UApp -.->|publish events| MB
    PS   -.->|publish events| MB
    OS   -.->|publish events| MB

    MB   -.->|user events| PS
    MB   -.->|user events| OP
    MB   -.->|product events| UApp
    MB   -.->|product events| OP
    MB   -.->|order events| UApp
    MB   -.->|order events| PS

    %% Click Events
    click UApp "https://github.com/hawerforerouniandes/electivamicroservicios/blob/master/usuarios/app.py"
    click UModels "https://github.com/hawerforerouniandes/electivamicroservicios/blob/master/usuarios/models.py"
    click UReq "https://github.com/hawerforerouniandes/electivamicroservicios/blob/master/usuarios/requirements.txt"
    click UDocker "https://github.com/hawerforerouniandes/electivamicroservicios/tree/master/usuarios/Dockerfile"
    click UDBfile "https://github.com/hawerforerouniandes/electivamicroservicios/blob/master/usuarios/instance/database.db"
    click README "https://github.com/hawerforerouniandes/electivamicroservicios/blob/master/README.md"

    %% Styles
    classDef client fill:#f8d7da,stroke:#721c24
    classDef gateway fill:#e2e3e5,stroke:#6c757d
    classDef service fill:#cce5ff,stroke:#004085
    classDef db fill:#d4edda,stroke:#155724
    classDef broker fill:#fff3cd,stroke:#856404
    classDef file fill:#f0f0f0,stroke:#343a40,stroke-dasharray: 2 2
    classDef doc fill:#e8daef,stroke:#6f42c1,stroke-dasharray: 2 2
```
