# aldotestino/vctmang architecture

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

- Interactive diagram: https://gitdiagram.com/aldotestino/vctmang
- Repository: https://github.com/aldotestino/vctmang

## Overview

##### Main architectural components
- Frontend (client/)
- React.js + TypeScript single‑page app built with Vite
- Uses Chakra‑UI for styling
- Manages local state (Zustand stores in src/store)
- Communicates with backend via REST and Socket.io
- Backend (server/)
- Node.js + Express.js HTTP API
- Socket.io for real‑time updates
- Controllers (src/controllers/*) implement business logic (orders, menu, users)
- Prisma ORM (src/lib/prisma.ts + schema.prisma) for database access
- Seeds initial data (seed.ts) and exposes public images (src/public/images)
- Database
- MongoDB Replica Set (mongodb_replica/) for high availability
- Configured via Dockerfile in mongodb_replica/
- Orchestration & Infrastructure
- docker‑compose-dev.yml / docker‑compose.yml define three services:
– client (frontend container)
– server (API container)
– mongodb (replica set container)

##### Interactions and data flows
- Client → Server (HTTP REST): CRUD operations on menu, orders, users
- Server → Client (WebSocket via Socket.io): realtime order status, cook/admin notifications, transaction updates
- Server → MongoDB: queries & mutations via Prisma
- Docker‑Compose: brings up all services on a common Docker network

##### Architectural patterns
- Full‑stack MVC‑style backend: controllers → services → database
- Single‑page application (SPA) frontend decoupled from backend
- Event‑driven real‑time layer (WebSocket) alongside REST API
- Containerization (Docker) and multi‑container orchestration

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    External["External Clients\n(Web Browser)"]:::external

    subgraph "Docker-Compose Network" 
        direction TB
        style DockerCompose stroke:#999,stroke-dasharray: 5 5

        subgraph "Frontend (SPA)" 
            direction TB
            Frontend["React.js + TypeScript SPA\n(Vite, Chakra-UI, Zustand, SocketProvider)"]:::frontend
        end

        subgraph "Backend (API + WebSocket)"
            direction TB
            Backend["Node.js + Express\nSocket.io, Prisma, Controllers, Seed Logic"]:::backend
        end

        subgraph "MongoDB Replica Set"
            direction TB
            DBReplica["MongoDB Replica Set"]:::db
        end
    end

    %% Data Flows
    External -->|"loads SPA"| Frontend
    Frontend -->|"REST API Calls"| Backend
    Frontend -->|"WebSocket Connection"| Backend
    Backend -->|"Prisma ORM Queries"| DBReplica

    %% Click Events - Frontend
    click Frontend "https://github.com/aldotestino/vctmang/tree/main/client/"
    click Frontend "https://github.com/aldotestino/vctmang/blob/main/client/src/App.tsx"
    click Frontend "https://github.com/aldotestino/vctmang/blob/main/client/src/SocketProvider.tsx"
    click Frontend "https://github.com/aldotestino/vctmang/blob/main/client/src/store/cartStore.ts"
    click Frontend "https://github.com/aldotestino/vctmang/blob/main/client/src/components/Avatar.tsx"

    %% Click Events - Backend
    click Backend "https://github.com/aldotestino/vctmang/blob/main/server/src/index.ts"
    click Backend "https://github.com/aldotestino/vctmang/blob/main/server/src/controllers/orderController.ts"
    click Backend "https://github.com/aldotestino/vctmang/blob/main/server/src/lib/prisma.ts"

    %% Click Events - Database
    click DBReplica "https://github.com/aldotestino/vctmang/tree/main/mongodb_replica/"

    %% Click Events - Compose Files
    click DockerCompose "https://github.com/aldotestino/vctmang/blob/main/docker-compose.yml"

    %% Styles
    classDef frontend fill:#e0f7fa,stroke:#0288d1,stroke-width:2px
    classDef backend fill:#e8f5e9,stroke:#43a047,stroke-width:2px
    classDef db fill:#fff3e0,stroke:#fb8c00,stroke-width:2px
    classDef external fill:#f5f5f5,stroke:#9e9e9e,stroke-width:2px,stroke-dasharray: 2 2px
```
