# oasido/shift-scheduler architecture

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

- Interactive diagram: https://gitdiagram.com/oasido/shift-scheduler
- Repository: https://github.com/oasido/shift-scheduler

## Overview

##### Main Components

a) Client Layer (Frontend):
- React-based frontend application
- Key modules:
- Admin Control Panel
- User Dashboard
- Authentication Components
- Schedule Views (Desktop/Mobile)

b) Server Layer (Backend):
- Node.js/Express backend
- Key components:
- Authentication Service (Passport)
- Route Controllers
- Middleware

c) Database Layer:
- MongoDB database
- Collections:
- Users
- Shifts

d) Nginx Layer:
- Reverse proxy/load balancer
- Use a proxy server symbol

##### Component Relationships

**Client ←→ Nginx ←→ Backend ←→ MongoDB**

##### Detailed Component Breakdown

Frontend Components (Group these in a container):
- Authentication
- Login Component
- User Features
- Schedule Viewer
- Availability Management
- Request Management
- Admin Features
- User Management
- Schedule Generation
- Request Processing
- Schedule History

Backend Components (Group these in a container):
- Authentication Services
- Route Controllers
- Middleware
- Admin Authorization
- Models
- User
- Shift

##### Data Flow Indicators

Following key interactions:
- User authentication flow
- Schedule creation/viewing
- Request submission/approval
- Admin management operations

##### Infrastructure Layer

Docker containers:
- Frontend container
- Backend container
- MongoDB container
- Nginx container

##### Additional Elements

- Version/environment indicators
- Security boundaries
- Scalable components

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Infrastructure
        NGINX["Nginx Reverse Proxy"]:::proxy
        DOCKER["Docker Environment"]:::infra
    end

    subgraph "Frontend Container"
        CLIENT["React Frontend"]:::frontend
        subgraph "Admin Features"
            ADMIN["Admin Control Panel"]:::frontend
            USERMGMT["User Management"]:::frontend
            SCHEDMGMT["Schedule Management"]:::frontend
            REQMGMT["Request Management"]:::frontend
        end
        subgraph "User Features"
            DASH["User Dashboard"]:::frontend
            SCHED["Schedule Views"]:::frontend
            AVAIL["Employee Availability"]:::frontend
        end
        AUTH_COMP["Authentication Components"]:::auth
    end

    subgraph "Backend Container"
        SERVER["Node.js/Express Server"]:::backend
        AUTH_SERVICE["Authentication Service"]:::auth
        ROUTES["Route Controllers"]:::backend
        MID["Middleware"]:::backend
        subgraph "Models"
            USER_MODEL["User Model"]:::model
            SHIFT_MODEL["Shift Model"]:::model
        end
    end

    subgraph "Database Container"
        DB[(MongoDB)]:::database
    end

    %% Connections
    CLIENT --> NGINX
    NGINX --> SERVER
    SERVER --> DB
    AUTH_COMP --> AUTH_SERVICE
    ROUTES --> DB
    
    %% Component relationships
    ADMIN --> USERMGMT
    ADMIN --> SCHEDMGMT
    ADMIN --> REQMGMT
    DASH --> SCHED
    DASH --> AVAIL

    %% Click events
    click ADMIN "https://github.com/oasido/shift-scheduler/tree/master/frontend/src/components/AdminControlPanel/"
    click AUTH_COMP "https://github.com/oasido/shift-scheduler/tree/master/frontend/src/components/Login/"
    click SCHED "https://github.com/oasido/shift-scheduler/tree/master/frontend/src/components/WeekSchedule/"
    click DASH "https://github.com/oasido/shift-scheduler/tree/master/frontend/src/components/User/"
    click AUTH_SERVICE "https://github.com/oasido/shift-scheduler/tree/master/backend/passport/"
    click ROUTES "https://github.com/oasido/shift-scheduler/tree/master/backend/routes/"
    click MID "https://github.com/oasido/shift-scheduler/tree/master/backend/routes/middleware/"
    click USER_MODEL "https://github.com/oasido/shift-scheduler/blob/master/backend/models/User.js"
    click SHIFT_MODEL "https://github.com/oasido/shift-scheduler/blob/master/backend/models/Shift.js"
    click SERVER "https://github.com/oasido/shift-scheduler/blob/master/backend/server.js"
    click NGINX "https://github.com/oasido/shift-scheduler/blob/master/nginx.conf"
    click DOCKER "https://github.com/oasido/shift-scheduler/blob/master/docker-compose.prod.yml"
    click USERMGMT "https://github.com/oasido/shift-scheduler/tree/master/frontend/src/components/AdminControlPanel/Users/"
    click SCHEDMGMT "https://github.com/oasido/shift-scheduler/tree/master/frontend/src/components/AdminControlPanel/Schedule/"
    click REQMGMT "https://github.com/oasido/shift-scheduler/tree/master/frontend/src/components/AdminControlPanel/Requests/"
    click AVAIL "https://github.com/oasido/shift-scheduler/tree/master/frontend/src/components/User/EmployeeAvailability/"

    %% Styling
    classDef frontend fill:#4299e1,color:white
    classDef backend fill:#48bb78,color:white
    classDef database fill:#ecc94b,color:black
    classDef auth fill:#9f7aea,color:white
    classDef proxy fill:#718096,color:white
    classDef infra fill:#a0aec0,color:white
    classDef model fill:#38b2ac,color:white

    %% Legend
    subgraph Legend
        FRONT_L["Frontend"]:::frontend
        BACK_L["Backend"]:::backend
        DB_L["Database"]:::database
        AUTH_L["Authentication"]:::auth
        PROXY_L["Proxy"]:::proxy
        INFRA_L["Infrastructure"]:::infra
        MODEL_L["Models"]:::model
    end
```
