# yannhallage/server-client architecture

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

- Interactive diagram: https://gitdiagram.com/yannhallage/server-client
- Repository: https://github.com/yannhallage/server-client

## Overview

##### Project type and purpose
- This is a full-stack client-server web application.
- The README confirms it follows the classic “client requests data, server responds” model.
- The client is a React (Vite) front-end with UI components and API hooks; the server is a Node/Express back-end exposing REST endpoints and interacting with a database.

##### File structure
- Top-level folders:
- client/ – React application
- server/ – Node/Express API
- client/ contains:
- src/api – API wrappers (api_post.jsx)
- src/components/ui – Reusable UI primitives (button, dialog, toast, etc.)
- src/context, src/hooks – State and side-effect management (apiContext, use-toast)
- myComponents – Demo or feature components using the UI library
- build/config files (vite.config.js, tsconfig.json, tailwind.config.js)
- server/ contains:
- config/db.js – Database connection setup
- models/ – Data schemas (account, personnel, notifications)
- controllers/ – Business logic for each resource
- routes/ – Express routers binding controllers to endpoints
- app.js/server.js – Express app initialization and server startup

##### README for additional insights
- The README simply states the client-server paradigm.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    subgraph "User Layer"
        Browser["Browser"]:::external
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        Main["main.jsx"]:::frontend
        App["App.jsx"]:::frontend
        SPA["React SPA"]:::frontend
        APIClient["api_post.jsx"]:::frontend
        UILib["UI Primitives"]:::frontend
        Features["Feature Components"]:::frontend
        Context["apiContext.jsx"]:::frontend
        Hooks["use-toast.ts"]:::frontend
        Utils["utils.ts"]:::frontend
    end

    subgraph "Config Files"
        ViteConfig["vite.config.js"]:::frontend
        TailwindConfig["tailwind.config.js"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        ExpressApp["app.js"]:::backend
        ServerStart["server.js"]:::backend
        DBConfig["db.js"]:::backend
        Env[".env"]:::backend
        subgraph "Models"
            AccountModel["account.model.js"]:::backend
            PersonnelModel["personnel.model.js"]:::backend
            NotificationsModel["notifications.model.js"]:::backend
        end
        subgraph "Controllers"
            AccountCtrl["account.controller.js"]:::backend
            PersonnelCtrl["crudPersonnel.controller.js"]:::backend
            NotificationsCtrl["notifications.controller.js"]:::backend
        end
        subgraph "Routes"
            PersonnelRoute["crudPresonnel.route.js"]:::backend
            NotificationsRoute["notifications.route.js"]:::backend
        end
    end

    %% Database
    subgraph "Database"
        DB["Database"]:::database
    end

    %% External Services
    subgraph "External Services"
        NotificationSvc["Notification Service"]:::external
    end

    %% Connections
    Browser -->|"loads"| SPA
    Main -->|"bootstraps"| SPA
    SPA -->|"renders"| App
    SPA -->|"uses"| UILib
    SPA -->|"renders"| Features
    App -->|"provides context"| Context
    App -->|"uses hooks"| Hooks
    SPA -->|"calls"| APIClient
    APIClient -->|"HTTP request"| ExpressApp
    ViteConfig -->|"configures"| ViteDev["Vite Dev Server"]:::frontend
    TailwindConfig -->|"styles"| SPA
    ViteDev -->|"serves"| SPA

    ExpressApp -->|"initializes routes"| PersonnelRoute
    ExpressApp -->|"initializes routes"| NotificationsRoute
    PersonnelRoute -->|"routes to"| PersonnelCtrl
    NotificationsRoute -->|"routes to"| NotificationsCtrl
    PersonnelCtrl -->|"uses model"| PersonnelModel
    AccountCtrl -->|"uses model"| AccountModel
    NotificationsCtrl -->|"uses model"| NotificationsModel
    PersonnelCtrl -->|"DB operations"| DB
    AccountCtrl -->|"DB operations"| DB
    NotificationsCtrl -->|"DB operations"| DB
    DBConfig -->|"connects to"| DB
    Env -->|"provides credentials"| DBConfig
    NotificationsCtrl -->|"pushes to"| NotificationSvc

    %% Click Events
    click Main "https://github.com/yannhallage/server-client/blob/main/client/src/main.jsx"
    click App "https://github.com/yannhallage/server-client/blob/main/client/src/App.jsx"
    click APIClient "https://github.com/yannhallage/server-client/blob/main/client/src/api/api_post.jsx"
    click UILib "https://github.com/yannhallage/server-client/tree/main/client/src/components/ui"
    click Features "https://github.com/yannhallage/server-client/tree/main/client/src/myComponents"
    click Context "https://github.com/yannhallage/server-client/blob/main/client/src/context/apiContext.jsx"
    click Hooks "https://github.com/yannhallage/server-client/blob/main/client/src/hooks/use-toast.ts"
    click Utils "https://github.com/yannhallage/server-client/blob/main/client/src/lib/utils.ts"
    click ViteConfig "https://github.com/yannhallage/server-client/blob/main/client/vite.config.js"
    click TailwindConfig "https://github.com/yannhallage/server-client/blob/main/client/tailwind.config.js"
    click ExpressApp "https://github.com/yannhallage/server-client/blob/main/server/app.js"
    click ServerStart "https://github.com/yannhallage/server-client/blob/main/server/server.js"
    click DBConfig "https://github.com/yannhallage/server-client/blob/main/server/config/db.js"
    click AccountModel "https://github.com/yannhallage/server-client/blob/main/server/models/account.model.js"
    click PersonnelModel "https://github.com/yannhallage/server-client/blob/main/server/models/personnel.model.js"
    click NotificationsModel "https://github.com/yannhallage/server-client/blob/main/server/models/notifications.model.js"
    click AccountCtrl "https://github.com/yannhallage/server-client/blob/main/server/controllers/account.controller.js"
    click PersonnelCtrl "https://github.com/yannhallage/server-client/blob/main/server/controllers/crudPersonnel.controller.js"
    click NotificationsCtrl "https://github.com/yannhallage/server-client/blob/main/server/controllers/notifications.controller.js"
    click PersonnelRoute "https://github.com/yannhallage/server-client/blob/main/server/routes/crudPresonnel.route.js"
    click NotificationsRoute "https://github.com/yannhallage/server-client/blob/main/server/routes/notifications.route.js"
    click Env "https://github.com/yannhallage/server-client/blob/main/server/.env"

    %% Styles
    classDef frontend fill:#BBDEFB,stroke:#1E88E5
    classDef backend fill:#C8E6C9,stroke:#388E3C
    classDef database fill:#FFF9C4,stroke:#FBC02D
    classDef external fill:#FFE0B2,stroke:#FB8C00
```
