# softwaredelta/gnp architecture

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

- Interactive diagram: https://gitdiagram.com/softwaredelta/gnp
- Repository: https://github.com/softwaredelta/gnp

## Overview

##### Project type and purpose
- From the file tree and README, this is a full-stack web application (“Delta Software | GNP (RAM)”) composed of:
- A React/TypeScript frontend (in ram-front)
- A Node.js/TypeScript backend (in ram-back) following a clean/hexagonal architecture (layers: arch, app/use-cases, controller, infra)
- An infrastructure module (in ram-infra) describing CI/CD, Docker, AWS, Fly.io deployment, load-testing, and supervision

##### File structure
- Top-level folders:
- ram-front (single-page React app with Vite, Recoil, hooks, components, pages, API wrappers)
- ram-back (Express-style HTTP controllers, domain “app” services, entities, database client, S3 client, Jest tests)
- ram-infra (Dockerfile, AWS CloudFormation/YAML, Fly.io config, buildspec, supervisord, Locust scripts)
- Patterns:
- Backend uses a layered/hexagonal pattern—“arch” for low-level ports (db-client, s3-client), “app” for business logic, “controller” for HTTP adapters, “entities” for ORM models.
- Frontend is structured by features (auth, deliveries, prospects) with generic UI atoms, API wrappers under src/lib/api, routing under src/routes, global state under src/recoil.

##### README for additional insights
- Quickstart script (“dev”) to launch both front and back locally
- Links to infra, local environment, and production‐deployment documentation—indicates a multi-environment deployment pipeline

##### Final advice
- Be exhaustive in identifying every external/infrastructure dependency (S3, database, CI/CD, load-tester).
- Clean architecture layering inside the backend to guide maintainers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Entities
    subgraph "External"
        Dev["Developer"]:::external
        Browser["User's Browser"]:::external
        GitHub["GitHub"]:::external
        Postgres["Postgres (RDS)"]:::external
        S3["AWS S3"]:::external
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline" 
        FrontCI["Front CI"]:::infra
        BackCI["Back CI"]:::infra
        Sonar["SonarCloud"]:::infra
        StageDeploy["Staging/Prod Deploy"]:::infra
    end

    %% Frontend
    subgraph "ram-front (Frontend)"
        ReactApp["React SPA"]:::frontend
        RoutingPriv["Private Routes"]:::frontend
        RoutingPub["Public Routes"]:::frontend
        StateMgmt["Recoil State"]:::frontend
        APIBase["API Wrappers"]:::frontend
        ViteConfig["Vite Config"]:::frontend
    end

    %% Backend
    subgraph "ram-back (Backend)"
        HTTPServer["HTTP Server"]:::backend
        ControllersIndex["Controller Index"]:::backend
        ControllersRoutes["Controller Routes"]:::backend
        UseCases["Business Logic (app)"]:::backend
        PortsDB["DB Client"]:::backend
        PortsS3["S3 Client"]:::backend
        Entities["Entities"]:::backend
        Seeds["Seed Data"]:::backend
        Utils["Utils (Hash)"]:::backend
    end

    %% Infrastructure
    subgraph "ram-infra (Infrastructure)"
        Dockerfile["Dockerfile"]:::infra
        FlyConfig["fly.toml"]:::infra
        AWSCloud["AWS CloudFormation"]:::infra
        Supervisor["supervisord.conf"]:::infra
        BuildSpec["buildspec.yml"]:::infra
        Locustfile["locustfile.py"]:::infra
    end

    %% Connections - Code & Deploy
    Dev -->|"push code"| GitHub
    GitHub -->|triggers| FrontCI
    GitHub -->|triggers| BackCI
    GitHub -->|triggers| Sonar
    GitHub -->|triggers| StageDeploy
    StageDeploy -->|build image| Dockerfile
    StageDeploy -->|apply infra| AWSCloud
    StageDeploy -->|deploy to Fly.io| FlyConfig
    StageDeploy -->|start supervisord| Supervisor

    %% Deploy to externals
    FrontCI -->|deploy frontend| FlyConfig
    BackCI -->|deploy backend| Dockerfile

    %% User Flow
    Browser -->|HTTP/HTTPS| ReactApp
    ReactApp -->|routes| RoutingPriv
    ReactApp -->|routes| RoutingPub
    ReactApp -->|state| StateMgmt
    ReactApp -->|api calls| APIBase
    APIBase -->|REST API| ControllersRoutes

    ControllersIndex -->|serves routes| ControllersRoutes
    ControllersRoutes -->|calls use-cases| UseCases
    UseCases -->|query/update| Entities
    UseCases -->|SQL queries| PortsDB
    UseCases -->|S3 API| PortsS3
    PortsDB -->|connect| Postgres
    PortsS3 -->|connect| S3

    %% Load Testing
    Locustfile -->|load test| HTTPServer

    %% CI/CD to BuildSpec
    BuildSpec -->|CodeBuild| AWSCloud

    %% Click Events - Frontend
    click ReactApp "https://github.com/softwaredelta/gnp/tree/develop/ram-front/src"
    click RoutingPriv "https://github.com/softwaredelta/gnp/blob/develop/ram-front/src/routes/privates.tsx"
    click RoutingPub "https://github.com/softwaredelta/gnp/blob/develop/ram-front/src/routes/public.tsx"
    click StateMgmt "https://github.com/softwaredelta/gnp/tree/develop/ram-front/src/recoil"
    click APIBase "https://github.com/softwaredelta/gnp/blob/develop/ram-front/src/lib/api/api-base.ts"
    click ViteConfig "https://github.com/softwaredelta/gnp/blob/develop/ram-front/vite.config.ts"

    %% Click Events - Backend
    click HTTPServer "https://github.com/softwaredelta/gnp/blob/develop/ram-back/src/index.ts"
    click ControllersIndex "https://github.com/softwaredelta/gnp/blob/develop/ram-back/src/controller/index.ts"
    click ControllersRoutes "https://github.com/softwaredelta/gnp/blob/develop/ram-back/src/controller/routes.ts"
    click UseCases "https://github.com/softwaredelta/gnp/tree/develop/ram-back/src/app"
    click PortsDB "https://github.com/softwaredelta/gnp/blob/develop/ram-back/src/arch/db-client.ts"
    click PortsS3 "https://github.com/softwaredelta/gnp/blob/develop/ram-back/src/arch/s3-client.ts"
    click Entities "https://github.com/softwaredelta/gnp/tree/develop/ram-back/src/entities"
    click Seeds "https://github.com/softwaredelta/gnp/blob/develop/ram-back/src/seeds/index.ts"
    click Utils "https://github.com/softwaredelta/gnp/blob/develop/ram-back/src/utils/hash.ts"

    %% Click Events - Infrastructure
    click Dockerfile "https://github.com/softwaredelta/gnp/tree/develop/ram-infra/Dockerfile"
    click FlyConfig "https://github.com/softwaredelta/gnp/blob/develop/fly.toml"
    click AWSCloud "https://github.com/softwaredelta/gnp/blob/develop/ram-infra/aws.yml"
    click Supervisor "https://github.com/softwaredelta/gnp/blob/develop/ram-infra/supervisord.conf"
    click BuildSpec "https://github.com/softwaredelta/gnp/blob/develop/ram-infra/buildspec.yml"
    click Locustfile "https://github.com/softwaredelta/gnp/blob/develop/ram-infra/locustfile.py"

    %% Click Events - CI/CD
    click FrontCI "https://github.com/softwaredelta/gnp/blob/develop/.github/workflows/front-ci.yml"
    click BackCI "https://github.com/softwaredelta/gnp/blob/develop/.github/workflows/back-ci.yml"
    click Sonar "https://github.com/softwaredelta/gnp/blob/develop/.github/workflows/sonarcloud.yml"
    click StageDeploy "https://github.com/softwaredelta/gnp/blob/develop/.github/workflows/staging-deployment.yml"

    %% Styles
    classDef frontend fill:#D6E4FF,stroke:#1E3A8A,stroke-width:1px
    classDef backend fill:#D1FAE5,stroke:#065F46,stroke-width:1px
    classDef infra fill:#FEF3C7,stroke:#92400E,stroke-width:1px
    classDef external fill:#E5E7EB,stroke:#374151,stroke-width:1px
```
