# estigar95/electiva3 architecture

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

- Interactive diagram: https://gitdiagram.com/estigar95/electiva3
- Repository: https://github.com/estigar95/electiva3

## Overview

##### Project type and purpose
- This is a backend-only, monolithic REST API service written in Node.js/Express, with PostgreSQL as its data store.
- Its purpose is to implement a customer loyalty program: point wallets, promotions, challenges, rules for assigning and expiring points, etc., all exposed via HTTP endpoints (tested with Postman).

##### File structure
- Top level contains package.json, README.md, Git artifacts.
- src/index.js boots the Express server.
- src/config/config.js holds the DB connection parameters (loaded via environment variables).
- src/routers/* define Express routing per resource (cliente, bolsaPuntos, usoPuntos, conceptoUso, gamificacion, promocion, reglasAsignacion, vencimientoPuntos).
- src/controllers/* implement the business logic for each resource.
- No separate “service” or “model” layer folders—controllers talk directly to the DB via the “pg” module.

##### README for additional insights
- Confirms use of Express, pg, moment, nodemon.
- PostgreSQL is the sole external service.
- Interactions are purely via REST endpoints (CRUD-style).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    HTTPClient["HTTP Client\n(Postman/any HTTP client)"]:::external

    %% API Entry Point
    HTTPClient -->|"HTTP/JSON (port 3000)"| APIEntry
    APIEntry["Express API\n(src/index.js)"]:::api

    %% Configuration Loader
    CFG["Config Loader\n(src/config/config.js)"]:::config

    %% Routers Layer
    subgraph "Routers"
        direction TB
        CLI["Cliente Router"]:::api
        BPR["BolsaPuntos Router"]:::api
        UPR["UsoPuntos Router"]:::api
        CUR["ConceptoUso Router"]:::api
        GMR["Gamificacion Router"]:::api
        PMR["Promocion Router"]:::api
        RAR["ReglasAsignacion Router"]:::api
        VPR["VencimientoPuntos Router"]:::api
        IR["Index Router"]:::api
    end

    APIEntry --> CLI
    APIEntry --> BPR
    APIEntry --> UPR
    APIEntry --> CUR
    APIEntry --> GMR
    APIEntry --> PMR
    APIEntry --> RAR
    APIEntry --> VPR
    APIEntry --> IR

    %% Controllers Layer
    subgraph "Controllers"
        direction TB
        CLC["Cliente Controller"]:::business
        BPC["BolsaPuntos Controller"]:::business
        UPC["UsoPuntos Controller"]:::business
        CUC["ConceptoUso Controller"]:::business
        GMC["Gamificacion Controller"]:::business
        PMC["Promocion Controller"]:::business
        RAC["ReglasAsignacion Controller"]:::business
        VPC["VencimientoPuntos Controller"]:::business
        IC["Index Controller"]:::business
    end

    CLI --> CLC
    BPR --> BPC
    UPR --> UPC
    CUR --> CUC
    GMR --> GMC
    PMR --> PMC
    RAR --> RAC
    VPR --> VPC
    IR --> IC

    %% Data Access and Database
    CLC --> PGClient
    BPC --> PGClient
    UPC --> PGClient
    CUC --> PGClient
    GMC --> PGClient
    PMC --> PGClient
    RAC --> PGClient
    VPC --> PGClient
    IC --> PGClient

    CFG --> PGClient
    PGClient["pg Client"]:::dataaccess
    PGClient -->|"SQL/Port 5432"| DB
    DB["PostgreSQL Database"]:::datastore

    %% Project Metadata
    subgraph "Project Metadata & Scripts"
        direction TB
        PMD["package.json"]:::config
        RM["README.md"]:::config
    end

    %% Click Events
    click APIEntry "https://github.com/estigar95/electiva3/blob/main/src/index.js"
    click CFG "https://github.com/estigar95/electiva3/blob/main/src/config/config.js"
    click CLI "https://github.com/estigar95/electiva3/blob/main/src/routers/clienteRouter.js"
    click BPR "https://github.com/estigar95/electiva3/blob/main/src/routers/bolsaPuntosRouter.js"
    click UPR "https://github.com/estigar95/electiva3/blob/main/src/routers/usoPuntosRouter.js"
    click CUR "https://github.com/estigar95/electiva3/blob/main/src/routers/conceptoUsoRouter.js"
    click GMR "https://github.com/estigar95/electiva3/blob/main/src/routers/gamificacion.js"
    click PMR "https://github.com/estigar95/electiva3/blob/main/src/routers/promocion.js"
    click RAR "https://github.com/estigar95/electiva3/blob/main/src/routers/reglasAsignacionRouter.js"
    click VPR "https://github.com/estigar95/electiva3/blob/main/src/routers/vencimientoPuntosRouter.js"
    click IR "https://github.com/estigar95/electiva3/blob/main/src/routers/indexRouter.js"
    click CLC "https://github.com/estigar95/electiva3/blob/main/src/controllers/clienteController.js"
    click BPC "https://github.com/estigar95/electiva3/blob/main/src/controllers/bolsaPuntosController.js"
    click UPC "https://github.com/estigar95/electiva3/blob/main/src/controllers/usoPuntosController.js"
    click CUC "https://github.com/estigar95/electiva3/blob/main/src/controllers/conceptoUsoController.js"
    click GMC "https://github.com/estigar95/electiva3/blob/main/src/controllers/gamificacionController.js"
    click PMC "https://github.com/estigar95/electiva3/blob/main/src/controllers/promocionController.js"
    click RAC "https://github.com/estigar95/electiva3/blob/main/src/controllers/reglasAsignacionController.js"
    click VPC "https://github.com/estigar95/electiva3/blob/main/src/controllers/vencimientoPuntosController.js"
    click IC "https://github.com/estigar95/electiva3/blob/main/src/controllers/indexController.js"
    click PMD "https://github.com/estigar95/electiva3/blob/main/package.json"
    click RM "https://github.com/estigar95/electiva3/blob/main/README.md"

    %% Styles
    classDef external fill:#f2f2f2,stroke:#333,stroke-width:1px
    classDef api fill:#bbdefb,stroke:#333,stroke-width:1px
    classDef business fill:#c8e6c9,stroke:#333,stroke-width:1px
    classDef datastore fill:#ffcc80,stroke:#333,stroke-width:1px
    classDef config fill:#fff9c4,stroke:#333,stroke-width:1px
    classDef dataaccess fill:#b3e5fc,stroke:#333,stroke-width:1px
```
