# sergioizq/gastosapp-backend architecture

> Architecture diagram of the GitHub repository sergioizq/gastosapp-backend, 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/sergioizq/gastosapp-backend
- Repository: https://github.com/sergioizq/gastosapp-backend

## Overview

##### Project type and purpose
- This solution (“AppG.sln”) contains three .NET-based components plus a Dockerfile:
- AppG: a .NET Core Web API that exposes a RESTful service for personal/professional expense management
- CronJobProgramado: a .NET Core console job that runs on a schedule to process “GastoProgramado” (scheduled expenses)
- NHTools: a Windows Forms desktop utility that uses NHibernate mappings against the same database
- The README confirms AppG is the backend for a personal finance frontend, exposing endpoints for ingresos, gastos, cuentas, categorías, conceptos, personas, clientes, proveedores, traspasos and a financial summary.

##### File structure
- Top level:
- AppG/ – API project: Controllers, Servicio (service layer), BBDD (domain & NHibernate mappings), Middleware, Exceptions, NHibernate config, Startup & Program
- CronJobProgramado/ – scheduled job: NHibernate helper, job class, config
- NHTools/ – WinForms app: Form1, NHibernate config, binaries
- Dockerfile – to containerize the API (likely AppG)
- Patterns: Layered architecture in AppG: Controller → Service interfaces & implementations → NHibernate ORM → PostgreSQL (Supabase).
CronJobProgramado follows a similar layer but focuses on scheduled tasks.
NHTools is a standalone NHibernate client.

##### README for additional insights
- Stack: Nginx + VPS, .NET Core API, Supabase (PostgreSQL), JWT for auth, Swagger for docs, CORS enabled.

##### Detail
- Call out external dependencies (Supabase, Nginx on VPS) explicitly.

## Diagram (Mermaid)

```mermaid
graph TB
    classDef frontend fill:#ADD8E6,stroke:#000;
    classDef backend fill:#90EE90,stroke:#000;
    classDef infra fill:#FFA500,stroke:#000;

    subgraph "External Clients"
        FE["Frontend (React/Vue)"]:::frontend
    end

    FE -->|"HTTPS/CORS"| Nginx["Nginx Reverse Proxy / Load Balancer"]:::infra

    subgraph "Backend Services"
        subgraph "Dockerized AppG Web API"
            Program["Program.cs"]:::backend
            Startup["Startup.cs"]:::backend
            Csproj["AppG.csproj"]:::backend
            Controllers["Controllers/"]:::backend
            ServicioInterfaces["Servicio Interfaces"]:::backend
            ServicioImpl["Servicio Implementations"]:::backend
            BBDD["BBDD (Entities & Mappings)"]:::backend
            NHConfig["NHibernate cfg"]:::backend
            Exceptions["Exceptions"]:::backend
            Middleware["ExceptionHandlingMiddleware"]:::backend
            AppSettings["appsettings.json"]:::backend
        end

        subgraph "CronJobProgramado Service"
            CJ_Program["Program.cs"]:::backend
            CJ_Startup["Startup.cs"]:::backend
            CJ_Csproj["CronJobProgramado.csproj"]:::backend
            CJ_Job["GastoProgramadoJob.cs"]:::backend
            CJ_NHHelper["NHibernateHelper.cs"]:::backend
            CJ_NHConfig["hibernate.cfg.xml"]:::backend
            CJ_AppSettings["appsettings.json"]:::backend
        end
    end

    Nginx -->|"Routes API calls"| Program
    Program -->|"Invokes Services & ORM"| BBDD

    DB["PostgreSQL (Supabase)"]:::infra
    Program -->|"NHibernate ORM"| DB
    CJ_Program -->|"Scheduled tasks via ORM"| DB

    subgraph "Admin Utility"
        NHTools_Program["Program.cs"]:::frontend
        Form1["Form1.cs"]:::frontend
        NHTools_Csproj["NHTools.csproj"]:::frontend
        NHTools_NHConfig["hibernate.cfg.xml"]:::frontend
    end

    NHTools_Program -->|"Direct DB Access"| DB

    Dockerfile["Dockerfile"]:::infra
    Dockerfile -.-> Program

    click Program "https://github.com/sergioizq/gastosapp-backend/blob/main/AppG/Program.cs"
    click Startup "https://github.com/sergioizq/gastosapp-backend/blob/main/AppG/Startup.cs"
    click Csproj "https://github.com/sergioizq/gastosapp-backend/blob/main/AppG/AppG.csproj"
    click Controllers "https://github.com/sergioizq/gastosapp-backend/tree/main/AppG/Controllers/"
    click ServicioInterfaces "https://github.com/sergioizq/gastosapp-backend/tree/main/AppG/Servicio/Interfaces/"
    click ServicioImpl "https://github.com/sergioizq/gastosapp-backend/tree/main/AppG/Servicio/Implementaciones/"
    click BBDD "https://github.com/sergioizq/gastosapp-backend/tree/main/AppG/BBDD/"
    click NHConfig "https://github.com/sergioizq/gastosapp-backend/blob/main/AppG/NHibernate/hibernate.cfg.xml"
    click Exceptions "https://github.com/sergioizq/gastosapp-backend/tree/main/AppG/Exceptions/"
    click Middleware "https://github.com/sergioizq/gastosapp-backend/blob/main/AppG/Middleware/ExceptionHandlingMiddleware.cs"
    click AppSettings "https://github.com/sergioizq/gastosapp-backend/blob/main/AppG/appsettings.json"

    click CJ_Program "https://github.com/sergioizq/gastosapp-backend/blob/main/CronJobProgramado/Program.cs"
    click CJ_Startup "https://github.com/sergioizq/gastosapp-backend/blob/main/CronJobProgramado/Startup.cs"
    click CJ_Csproj "https://github.com/sergioizq/gastosapp-backend/blob/main/CronJobProgramado/CronJobProgramado.csproj"
    click CJ_Job "https://github.com/sergioizq/gastosapp-backend/blob/main/CronJobProgramado/GastoProgramadoJob.cs"
    click CJ_NHHelper "https://github.com/sergioizq/gastosapp-backend/blob/main/CronJobProgramado/NHibernate/NHibernateHelper.cs"
    click CJ_NHConfig "https://github.com/sergioizq/gastosapp-backend/blob/main/CronJobProgramado/NHibernate/hibernate.cfg.xml"
    click CJ_AppSettings "https://github.com/sergioizq/gastosapp-backend/blob/main/CronJobProgramado/appsettings.json"

    click NHTools_Program "https://github.com/sergioizq/gastosapp-backend/blob/main/NHTools/Program.cs"
    click Form1 "https://github.com/sergioizq/gastosapp-backend/blob/main/NHTools/Form1.cs"
    click NHTools_Csproj "https://github.com/sergioizq/gastosapp-backend/blob/main/NHTools/NHTools.csproj"
    click NHTools_NHConfig "https://github.com/sergioizq/gastosapp-backend/blob/main/NHTools/hibernate.cfg.xml"

    click Dockerfile "https://github.com/sergioizq/gastosapp-backend/tree/main/Dockerfile"

    class FE frontend
    class Nginx infra
    class Program,CJ_Program,CJ_Job,CJ_Startup,CJ_Csproj,CJ_NHHelper,CJ_NHConfig,CJ_AppSettings backend
    class DB infra
```
