# ogumakouta/shift-calendar architecture

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

- Interactive diagram: https://gitdiagram.com/ogumakouta/shift-calendar
- Repository: https://github.com/ogumakouta/shift-calendar

## Overview

##### Project Type and Purpose
- This is a full-stack web application (“Shift Calendar”) that unifies work-shift scheduling and personal event management.
- Users register/log in, configure workplaces, add/edit/delete shifts and private events, manage event labels, and view monthly salary calculations.

##### File Structure Analysis
- Top level:
- backend/ – NestJS API service (TypeScript, Prisma ORM, JWT auth)
- frontend/ – Next.js UI (TypeScript, React, Tailwind CSS)
- nginx/ – Nginx reverse-proxy configuration
- docker-compose.yml & docker-compose.prod.yml – container orchestration
- backend/src modules: auth, user, workplace, event, event-label, prisma service
- frontend: app routes under src/app (calendar, login, signup, setting), reusable React components
- Prisma migrations & schema define MySQL tables and relations
- Dockerfiles in both backend and frontend, plus Compose files, point to containerized deployment

##### Key Architectural Elements from README
- API endpoints (REST) for auth, user, workplace, event, event-label
- Database: MySQL 8.0, connected via Prisma
- Authentication: JWT + bcrypt
- Frontend SSR/CSR via Next.js, calling BACKEND_PORT=8000
- Infrastructure: Docker Compose network, Nginx for routing static assets and API calls

##### Main Components
a. Client Layer
- Browser/Device running Next.js pages (calendar, login, signup, settings)
- React components invoking Fetch API
b. Reverse Proxy Layer
- Nginx container forwarding requests to frontend (port 3000) and backend (port 8000)
c. Application Layer
- Frontend Service container (Next.js)
- Backend Service container (NestJS)
- Internal modules: Auth, User, Workplace, Event, Event-Label
- Prisma Service for DB access
d. Data Layer
- MySQL database container
- Prisma migrations and schema
e. Orchestration & Networking
- Docker network linking all containers
- docker-compose.yml for dev, docker-compose.prod.yml for prod

##### Relationships & Data Flows
- User’s browser → HTTP/HTTPS → Nginx
- Static asset requests → Frontend container
- API calls (/auth, /create, /getEvents, etc.) → Backend container
- Backend container → SQL queries → MySQL container via Prisma
- Backend issues JWTs to client; client includes JWT in Authorization header
- docker-compose manages service startup order, shared network

##### Architectural Patterns & Principles
- Layered architecture: presentation (UI) → API layer → persistence
- Module-based organization in backend (NestJS modules)
- Infrastructure-as-code: containerization, environment separation (dev vs prod)
- Single monolithic API (not microservices) but clear module boundaries
- CI/CD readiness: docker-compose for deployment

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Docker Network" 
        direction TB
        Browser(["Browser/Device"]):::client
        nginx{"Nginx Reverse Proxy"}:::proxy
        subgraph "Frontend Container\nNext.js Service" 
            direction TB
            frontend["Next.js Frontend Service"]:::frontend
            pages_calendar["Calendar Page"] 
            pages_login["Login Page"]
            pages_signup["Signup Page"]
            pages_setting["Settings Page"]
            components["Reusable React Components"] 
        end
        subgraph "Backend Container\nNestJS API Service" 
            direction TB
            backend["NestJS API Service"]:::backend
            subgraph Modules
                direction TB
                auth["Auth Module"]
                user["User Module"]
                workplace["Workplace Module"]
                event["Event Module"]
                eventLabel["Event-Label Module"]
                prisma["Prisma Service"]:::prisma
            end
        end
        db[(MySQL Database)]:::database
    end

    subgraph "Infrastructure as Code"
        direction TB
        devCompose["Docker Compose (Dev)"]:::infra
        prodCompose["Docker Compose (Prod)"]:::infra
    end

    %% Connections
    Browser -->|"HTTP/HTTPS"| nginx
    nginx -->|"Static (HTTP 3000)"| frontend
    nginx -->|"API (HTTP 8000)"| backend
    frontend -->|"Fetch API (HTTP 8000)"| backend
    auth -->|"uses Prisma"| prisma
    user -->|"uses Prisma"| prisma
    workplace -->|"uses Prisma"| prisma
    event -->|"uses Prisma"| prisma
    eventLabel -->|"uses Prisma"| prisma
    prisma -->|"SQL (TCP 3306)"| db
    devCompose -->|"manages network"| Browser
    devCompose --> nginx
    devCompose --> frontend
    devCompose --> backend
    devCompose --> db
    prodCompose -->|"manages network"| Browser
    prodCompose --> nginx
    prodCompose --> frontend
    prodCompose --> backend
    prodCompose --> db

    %% Click Events
    click frontend "https://github.com/ogumakouta/shift-calendar/tree/main/frontend/Dockerfile"
    click pages_calendar "https://github.com/ogumakouta/shift-calendar/blob/main/frontend/src/app/calendar/page.tsx"
    click pages_login "https://github.com/ogumakouta/shift-calendar/blob/main/frontend/src/app/login/page.tsx"
    click pages_signup "https://github.com/ogumakouta/shift-calendar/blob/main/frontend/src/app/signup/page.tsx"
    click pages_setting "https://github.com/ogumakouta/shift-calendar/blob/main/frontend/src/app/setting/page.tsx"
    click components "https://github.com/ogumakouta/shift-calendar/tree/main/frontend/components/"
    click nginx "https://github.com/ogumakouta/shift-calendar/blob/main/nginx/default.conf"
    click devCompose "https://github.com/ogumakouta/shift-calendar/blob/main/docker-compose.yml"
    click prodCompose "https://github.com/ogumakouta/shift-calendar/blob/main/docker-compose.prod.yml"
    click backend "https://github.com/ogumakouta/shift-calendar/tree/main/backend/Dockerfile"
    click auth "https://github.com/ogumakouta/shift-calendar/tree/main/backend/src/auth/"
    click user "https://github.com/ogumakouta/shift-calendar/tree/main/backend/src/user/"
    click workplace "https://github.com/ogumakouta/shift-calendar/tree/main/backend/src/workplace/"
    click event "https://github.com/ogumakouta/shift-calendar/tree/main/backend/src/event/"
    click eventLabel "https://github.com/ogumakouta/shift-calendar/tree/main/backend/src/event-label/"
    click prisma "https://github.com/ogumakouta/shift-calendar/blob/main/backend/src/prisma/prisma.service.ts"
    click db "https://github.com/ogumakouta/shift-calendar/blob/main/backend/prisma/schema.prisma"
    %% Note: Prisma migrations directory
    click db "https://github.com/ogumakouta/shift-calendar/tree/main/backend/prisma/migrations/"

    %% Styles
    classDef client fill:#D6EAF8,stroke:#1B4F72,stroke-width:2px;
    classDef proxy fill:#F9E79F,stroke:#B7950B,stroke-width:2px,stroke-dasharray: 5 5;
    classDef frontend fill:#D5F5E3,stroke:#1D8348,stroke-width:2px;
    classDef backend fill:#FADBD8,stroke:#922B21,stroke-width:2px;
    classDef database fill:#EBDEF0,stroke:#6C3483,stroke-width:2px;
    classDef prisma fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
    classDef infra fill:#F4ECF7,stroke:#512E5F,stroke-width:2px,stroke-dasharray: 5 5;
```
