# chavezgaby08/neocdt-is02 architecture

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

- Interactive diagram: https://gitdiagram.com/chavezgaby08/neocdt-is02
- Repository: https://github.com/chavezgaby08/neocdt-is02

## Overview

##### Project type and purpose
- This is a single‐page web application (SPA) built with React and Vite.
- Purpose: A banking module (“NeoCDT”) that provides user authentication (login/register) and CRUD operations on “solicitudes” (CDT requests).

##### Main components
a. Client (Web Browser)
- Hosts the React application.
b. Frontend Application
- UI Layer: React pages and components (LoginPage, RegisterPage, Dashboard, SolicitudesList, DetalleSolicitud, EditSolicitud, SolicitudForm, Navbar, etc.).
- State Management Layer: AuthContext (manages auth token, user session).
- API Layer: authservice.js, solicitudService.js (HTTP clients for Auth API and Solicitudes API).
- Build/Dev Tool: Vite (serves the app in development and bundles for production).
- Testing: Jest + React Testing Library (unit tests under src/__tests__).
c. External Backend Services (not in this repo)
- Authentication API (login, register endpoints).
- Solicitudes API (create, read, update, delete endpoints).
- Underlying Database (e.g., PostgreSQL, MongoDB) behind the APIs.

##### Relationships and interactions
- User interacts with the React UI in the browser.
- On login/register, UI calls AuthContext methods → authservice.js → HTTP POST to Auth API → API returns JWT token → AuthContext stores token.
- On CRUD operations, components call solicitudService.js → HTTP requests with token in headers → Solicitudes API → Database.
- AuthContext provides token and user info to any component that needs to call secured endpoints or conditionally render routes.

##### Architectural patterns and design principles
- Separation of concerns:
- Presentation: React pages/components
- Business logic & state: Context + hooks
- Data access: API service modules
- Single source of truth for authentication (AuthContext).
- Component hierarchy: high-level pages delegate form/UI logic to child components.
- Modular file structure: clear separation of src/pages, src/components, src/api, src/context.
- Test-driven: Jest config at project root → ensures reliability.

- “UI Components & Pages”
- “AuthContext (State & Session)”
- “API Services (authservice.js, solicitudService.js)”
3. On the right, place “Auth API” and “Solicitudes API” side by side, and beneath them “Database.”
- UI → AuthContext → authservice → Auth API
- UI → solicitudService → Solicitudes API → Database
- Auth API returns JWT → AuthContext → UI
5. Notes labeling Vite (dev server/build tool) above the React container, and Jest (testing) below it.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser
    Browser["Web Browser"]:::external

    %% React App Container
    subgraph "React App" 
        direction TB
        %% Dev/Build Tool
        Vite["Vite (Dev Server / Build)"]:::note
        %% UI Components & Pages
        subgraph "UI Components & Pages"
            direction TB
            LoginPage["LoginPage"]:::presentation
            RegisterPage["RegisterPage"]:::presentation
            Dashboard["Dashboard"]:::presentation
            SolicitudesList["SolicitudesList"]:::presentation
            DetalleSolicitud["DetalleSolicitud"]:::presentation
            EditSolicitud["EditSolicitud"]:::presentation
            Navbar["Navbar"]:::presentation
            SolicitudForm["SolicitudForm"]:::presentation
        end
        %% State Management
        AuthContext["AuthContext"]:::state
        %% API Services
        subgraph "API Services"
            direction TB
            AuthService["authservice.js"]:::data
            SolicitudService["solicitudService.js"]:::data
        end
        %% Testing
        Jest["Jest (Testing)"]:::note
    end

    %% External Systems
    subgraph "External Backend Services"
        direction TB
        AuthAPI["Auth API"]:::external
        SolicitudesAPI["Solicitudes API"]:::external
        Database[(Database)]:::external
    end

    %% Connections
    Browser -->|"loads React App"| Vite
    Vite -->|"serves bundle"| Browser

    Browser -->|"renders UI"| LoginPage
    Browser -->|"renders UI"| RegisterPage
    Browser -->|"renders UI"| Dashboard
    Browser -->|"renders UI"| SolicitudesList

    LoginPage -->|"uses context"| AuthContext
    RegisterPage -->|"uses context"| AuthContext
    Dashboard -->|"uses context"| AuthContext

    AuthContext -->|"calls AuthService"| AuthService
    AuthService -->|"> POST /login, /register"| AuthAPI
    AuthAPI -->|"returns JWT"| AuthContext
    AuthContext -->|"provides token to UI"| Dashboard

    SolicitudesList -->|"calls API"| SolicitudService
    DetalleSolicitud -->|"calls API"| SolicitudService
    EditSolicitud -->|"calls API"| SolicitudService
    SolicitudForm -->|"uses context & service"| SolicitudService
    SolicitudService -->|"> CRUD requests"| SolicitudesAPI
    SolicitudesAPI -->|"reads/writes"| Database

    %% Click Events
    click LoginPage "https://github.com/chavezgaby08/neocdt-is02/blob/main/frontend/src/pages/LoginPage.jsx"
    click RegisterPage "https://github.com/chavezgaby08/neocdt-is02/blob/main/frontend/src/pages/RegisterPage.jsx"
    click Dashboard "https://github.com/chavezgaby08/neocdt-is02/blob/main/frontend/src/pages/Dashboard.jsx"
    click SolicitudesList "https://github.com/chavezgaby08/neocdt-is02/blob/main/frontend/src/pages/SolicitudesList.jsx"
    click DetalleSolicitud "https://github.com/chavezgaby08/neocdt-is02/blob/main/frontend/src/pages/DetalleSolicitud.jsx"
    click EditSolicitud "https://github.com/chavezgaby08/neocdt-is02/blob/main/frontend/src/pages/EditSolicitud.jsx"
    click Navbar "https://github.com/chavezgaby08/neocdt-is02/blob/main/frontend/src/components/Navbar.jsx"
    click SolicitudForm "https://github.com/chavezgaby08/neocdt-is02/blob/main/frontend/src/components/SolicitudForm.jsx"
    click AuthContext "https://github.com/chavezgaby08/neocdt-is02/blob/main/frontend/src/context/AuthContext.jsx"
    click AuthService "https://github.com/chavezgaby08/neocdt-is02/blob/main/frontend/src/api/authservice.js"
    click SolicitudService "https://github.com/chavezgaby08/neocdt-is02/blob/main/frontend/src/api/solicitudService.js"
    click Vite "https://github.com/chavezgaby08/neocdt-is02/blob/main/frontend/vite.config.js"
    click Jest "https://github.com/chavezgaby08/neocdt-is02/blob/main/frontend/jest.config.js"

    %% Styles
    classDef presentation fill:#D0E7FF,stroke:#888,stroke-width:1px
    classDef state fill:#D0FFD6,stroke:#888,stroke-width:1px
    classDef data fill:#FFE5B4,stroke:#888,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#888,stroke-width:1px
    classDef note fill:#F0F0F0,stroke:#666,stroke-width:1px,stroke-dasharray: 2 2comma2
```
