# jhoni161/sheab-backend architecture

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

- Interactive diagram: https://gitdiagram.com/jhoni161/sheab-backend
- Repository: https://github.com/jhoni161/sheab-backend

## Overview

##### Main Components

a. Core Application Layer:
- Authentication/Authorization Module (auth/)
- User Management Module (usuario/)
- Role Management Module (rol/)
- Audit System (auditoria/)

b. Domain-Specific Modules:
- Resolution Management (resolucion/)
- Healthcare Provider Management (prestador/)
- SIC Module (sic/)
- SP Module (sp/)
- PAMEC Module (pamec/)

c. Support Services:
- PDF Generation Service (generarpdf/)
- Excel Generation Service (generar_excel/)
- Image Management Service (controlar_imagenes/)
- Database Backup Service (backup_bd/)

##### Architecture Patterns to Highlight

a. Module-based Architecture:
- Clear separation between modules using distinct containers
- Modular structure following NestJS patterns

b. Data Layer:
- Entity repositories
- Database connections
- Data flow patterns

##### Specific Design Elements

**[Client Applications]**
- ↓
**[API Gateway Layer]**

- ↓    ↓    ↓
**[Auth] [Users] [Roles]**

- ┴────┘
- ↓
**[Core Business Logic Layer]**
- [Resolution Module]
- Evaluation
- Services
- Requirements
- [Healthcare Provider Module]
- Provider Management
- Location Management
- [Audit Module]
- ↓
**[Support Services Layer]**
- [Document Generation]
- [File Management]
- [Backup Services]
- ↓
**[Data Persistence Layer]**

##### Integration Points

- External service connections
- API endpoints
- Authentication boundaries
- File storage interactions

##### Security Layer

- JWT implementation
- Role-based access control
- Audit logging points

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        CL[Client Applications]
    end

    subgraph API_Gateway
        API[API Gateway]:::gateway
    end

    subgraph Security
        Auth["Authentication Module"]:::security
        click Auth "https://github.com/jhoni161/sheab-backend/tree/master/src/auth/"
        Guards["Security Guards"]:::security
        click Guards "https://github.com/jhoni161/sheab-backend/tree/master/src/guards/"
        Decorators["Auth Decorators"]:::security
        click Decorators "https://github.com/jhoni161/sheab-backend/tree/master/src/decorators/"
    end

    subgraph Core_Management
        Users["User Management"]:::core
        click Users "https://github.com/jhoni161/sheab-backend/tree/master/src/usuario/"
        Roles["Role Management"]:::core
        click Roles "https://github.com/jhoni161/sheab-backend/tree/master/src/rol/"
        Audit["Audit System"]:::core
        click Audit "https://github.com/jhoni161/sheab-backend/tree/master/src/auditoria/"
    end

    subgraph Healthcare_Modules
        Resolution["Resolution Management"]:::health
        click Resolution "https://github.com/jhoni161/sheab-backend/tree/master/src/resolucion/"
        Provider["Healthcare Provider"]:::health
        click Provider "https://github.com/jhoni161/sheab-backend/tree/master/src/prestador/"
        SIC["SIC Module"]:::health
        click SIC "https://github.com/jhoni161/sheab-backend/tree/master/src/sic/"
        SP["SP Module"]:::health
        click SP "https://github.com/jhoni161/sheab-backend/tree/master/src/sp/"
        PAMEC["PAMEC Module"]:::health
        click PAMEC "https://github.com/jhoni161/sheab-backend/tree/master/src/pamec/"
    end

    subgraph Support_Services
        PDF["PDF Generation"]:::support
        click PDF "https://github.com/jhoni161/sheab-backend/tree/master/src/generarpdf/"
        Excel["Excel Generation"]:::support
        click Excel "https://github.com/jhoni161/sheab-backend/tree/master/src/generar_excel/"
        Images["Image Management"]:::support
        click Images "https://github.com/jhoni161/sheab-backend/tree/master/src/controlar_imagenes/"
        Backup["Database Backup"]:::support
        click Backup "https://github.com/jhoni161/sheab-backend/tree/master/src/backup_bd/"
    end

    subgraph Data_Layer
        DB[(Database)]:::database
    end

    %% Connections
    CL --> API
    API --> Auth
    Auth --> |Validates| Guards
    Auth --> |Uses| Decorators
    
    Guards --> Users
    Guards --> Roles
    
    Users --> Healthcare_Modules
    Roles --> Healthcare_Modules
    
    Healthcare_Modules --> Support_Services
    Healthcare_Modules --> Audit
    
    Healthcare_Modules --> DB
    Support_Services --> DB
    Core_Management --> DB

    %% Styles
    classDef gateway fill:#6E6E6E,stroke:#333,stroke-width:2px
    classDef security fill:#FFD700,stroke:#333,stroke-width:2px
    classDef core fill:#4169E1,stroke:#333,stroke-width:2px
    classDef health fill:#32CD32,stroke:#333,stroke-width:2px
    classDef support fill:#A9A9A9,stroke:#333,stroke-width:2px
    classDef database fill:#FF6347,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1[Gateway]:::gateway
        L2[Security Components]:::security
        L3[Core Services]:::core
        L4[Healthcare Services]:::health
        L5[Support Services]:::support
        L6[(Database)]:::database
    end
```
