# mrarcs/fullstack-menu-management architecture

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

- Interactive diagram: https://gitdiagram.com/mrarcs/fullstack-menu-management
- Repository: https://github.com/mrarcs/fullstack-menu-management

## Overview

##### Project Type and Purpose
- Full-stack, monorepo web application for hierarchical menu management.
- Frontend: Next.js 15 (App Router) + TailwindCSS + Redux.
- Backend: NestJS + Prisma + PostgreSQL.
- Infrastructure: Docker Compose multi-service, Caddy reverse proxy with SSL, security headers, rate limiting.

##### File Structure Analysis
- Top-level:
– caddy/ (Caddyfile, Dockerfile)
– nst-backend/ (NestJS service, Prisma schema/migrations)
– nxt-frontend/ (Next.js app, Redux slices, shared utils)
– docker-compose.yml(.dev), deploy.sh, init-db.sh
- Patterns:
– Monorepo governed by root package.json and workspace scripts.
– Backend uses MVC (controllers/services/modules).
– Frontend uses App Router (src/app) and component hierarchy.
– Infrastructure as code via Dockerfiles and Compose files.

##### Key Insights from README
- Components: NestJS API (port 3001), Next.js frontend (port 3000), PostgreSQL, Caddy reverse proxy.
- Security: HTTPS, HSTS, CSP, rate limiting.
- Dev vs Prod: Separate Compose files and Caddy configs.
- Health checks and logging configured for every service.

a. Main Components
– User Browser (React SPA pages and API calls)
– Caddy Reverse Proxy
– Next.js Frontend Service (container)
– NestJS Backend Service (container)
– PostgreSQL Database (container)
– External Services (Let’s Encrypt for certificates)
b. Relationships & Data Flows
1. User → HTTPS request → Caddy
2. Caddy routes
- “/api/*” → NestJS API
- Static & SSR pages → Next.js server
3. Frontend fetches REST endpoints (GET/POST /api/v1/menus)
4. NestJS → Prisma client → PostgreSQL
5. Health checks: Caddy polls Next.js, NestJS, Postgres
6. Let’s Encrypt CA ↔ Caddy (auto-renewal)
c. Architectural Patterns & Principles
– Monorepo workspace for shared scripts and type safety
– MVC pattern in NestJS (controllers, services, modules)
– API-first design with RESTful endpoints and DTO validation
– App Router in Next.js for server and client components
– Containerized micro-services via Docker Compose
– Infrastructure-as-code for reproducible environments
d. Key Technologies to Annotate
– Caddy (reverse proxy, SSL/TLS, security headers, rate limiting)
– Docker & Docker Compose (multi-service orchestration, custom networks)
– NestJS (TypeScript, Prisma ORM, validation, CORS, rate limiter)
– PostgreSQL (health-monitored, connection pooling)
– Next.js (App Router, TailwindCSS, shadcn/ui, Redux Toolkit)
– Let’s Encrypt (certificate provisioning)

##### Detailed Capture Checklist
– Caddy reverse proxy at the edge with two routes (frontend vs API)
– Let’s Encrypt integration for SSL certs and auto-renewal
– Next.js SSR/static build, Redux store, component tree
– NestJS modules: menus module, Prisma service, health module
– Database: migrations folder, schema.prisma, connection pooling
– Docker Compose: service definitions, shared network, volumes
– Dev vs Prod configs: Caddyfile.dev, docker-compose.dev.yml
– Security and performance features (gzip, HSTS, CSP, rate limit)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and External
    Browser["User Browser"]:::frontend
    LE["Let's Encrypt"]:::external

    %% Core Services in Docker Compose Network
    subgraph "Docker Compose Network"
        Caddy["Caddy Reverse Proxy\nports: 80/443"]:::infra
        Next["Next.js Frontend\nport: 3000"]:::frontend
        Nest["NestJS Backend\nport: 3001"]:::backend
        DB["PostgreSQL\nport: 5432"]:::database
    end

    %% Orchestration & Scripts
    Compose["Docker Compose\nmulti-service"]:::infra
    InitDB["init-db.sh"]:::infra
    Deploy["deploy.sh"]:::infra

    %% NestJS Internal Modules
    subgraph "NestJS Details"
        AppModule["app.module.ts"]:::backend
        AppController["app.controller.ts"]:::backend
        AppService["app.service.ts"]:::backend
        MainFile["main.ts"]:::backend
        MenusModule["Menus Module"]:::backend
        PrismaService["Prisma Service"]:::backend
    end

    %% Relationships
    Browser -->|"HTTPS request"| Caddy
    Caddy -->|"route: /api/*"| Nest
    Caddy -->|"route: pages/SSR"| Next
    Next -->|"REST GET/POST /api/v1/menus"| Nest
    Nest -->|"Prisma client queries"| DB
    Caddy -->|"health check"| Next
    Caddy -->|"health check"| Nest
    Caddy -->|"health check"| DB
    LE <--> Caddy
    Compose --> Caddy
    Compose --> Next
    Compose --> Nest
    Compose --> DB
    Compose --> InitDB
    Compose --> Deploy
    AppModule -->|uses| Nest
    AppController -->|handles| Nest
    AppService -->|provides| Nest
    MainFile -->|boots| Nest
    MenusModule -->|module| Nest
    PrismaService -->|injects| Nest

    %% Click Events for Caddy
    click Caddy "https://github.com/mrarcs/fullstack-menu-management/tree/main/caddy/Caddyfile"
    click Caddy "https://github.com/mrarcs/fullstack-menu-management/blob/main/caddy/Caddyfile.dev"
    click Caddy "https://github.com/mrarcs/fullstack-menu-management/tree/main/caddy/Dockerfile"

    %% Click Events for Next.js Frontend
    click Next "https://github.com/mrarcs/fullstack-menu-management/tree/main/nxt-frontend/Dockerfile"
    click Next "https://github.com/mrarcs/fullstack-menu-management/blob/main/nxt-frontend/next.config.ts"
    click Next "https://github.com/mrarcs/fullstack-menu-management/tree/main/nxt-frontend/src/app"
    click Next "https://github.com/mrarcs/fullstack-menu-management/tree/main/nxt-frontend/src/components"
    click Next "https://github.com/mrarcs/fullstack-menu-management/tree/main/nxt-frontend/src/lib"
    click Next "https://github.com/mrarcs/fullstack-menu-management/blob/main/nxt-frontend/src/providers/redux-provider.tsx"
    click Next "https://github.com/mrarcs/fullstack-menu-management/blob/main/nxt-frontend/src/store/index.ts"
    click Next "https://github.com/mrarcs/fullstack-menu-management/blob/main/nxt-frontend/src/store/slices/menuSlice.ts"

    %% Click Events for NestJS Backend
    click Nest "https://github.com/mrarcs/fullstack-menu-management/tree/main/nst-backend/Dockerfile"
    click AppModule "https://github.com/mrarcs/fullstack-menu-management/blob/main/nst-backend/src/app.module.ts"
    click AppController "https://github.com/mrarcs/fullstack-menu-management/blob/main/nst-backend/src/app.controller.ts"
    click AppService "https://github.com/mrarcs/fullstack-menu-management/blob/main/nst-backend/src/app.service.ts"
    click MainFile "https://github.com/mrarcs/fullstack-menu-management/blob/main/nst-backend/src/main.ts"

    %% Click Events for Menus Module
    click MenusModule "https://github.com/mrarcs/fullstack-menu-management/blob/main/nst-backend/src/menus/menus.module.ts"
    click MenusModule "https://github.com/mrarcs/fullstack-menu-management/blob/main/nst-backend/src/menus/menus.controller.ts"
    click MenusModule "https://github.com/mrarcs/fullstack-menu-management/blob/main/nst-backend/src/menus/menus.service.ts"
    click MenusModule "https://github.com/mrarcs/fullstack-menu-management/tree/main/nst-backend/src/menus/dto"
    click MenusModule "https://github.com/mrarcs/fullstack-menu-management/tree/main/nst-backend/src/menus/entities"

    %% Click Events for Prisma ORM
    click PrismaService "https://github.com/mrarcs/fullstack-menu-management/blob/main/nst-backend/prisma/schema.prisma"
    click PrismaService "https://github.com/mrarcs/fullstack-menu-management/tree/main/nst-backend/prisma/migrations"
    click PrismaService "https://github.com/mrarcs/fullstack-menu-management/blob/main/nst-backend/src/prisma/prisma.service.ts"

    %% Click Events for Docker Compose & Scripts
    click Compose "https://github.com/mrarcs/fullstack-menu-management/blob/main/docker-compose.yml"
    click Compose "https://github.com/mrarcs/fullstack-menu-management/blob/main/docker-compose.dev.yml"
    click InitDB "https://github.com/mrarcs/fullstack-menu-management/blob/main/init-db.sh"
    click Deploy "https://github.com/mrarcs/fullstack-menu-management/blob/main/deploy.sh"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#3399ff,color:#002244,stroke-width:1px;
    classDef backend fill:#d4f4dd,stroke:#3ca34d,color:#0a4725,stroke-width:1px;
    classDef database fill:#ffe5b4,stroke:#ff9933,color:#663300,stroke-width:1px;
    classDef infra fill:#e0e0e0,stroke:#999999,color:#333333,stroke-width:1px;
    classDef external fill:#f3e5ff,stroke:#a64ca6,color:#4a0a47,stroke-width:1px;
```
