# notlath/guitara-scheduling-system architecture

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

- Interactive diagram: https://gitdiagram.com/notlath/guitara-scheduling-system
- Repository: https://github.com/notlath/guitara-scheduling-system

## Overview

##### Project Type and Purpose
- This is a full-stack web application called “GUITARA,” a scheduling management system built with a Django REST back end (including Django Channels for real-time) and a React/Redux front end.
- Purpose: automate appointment booking, staff coordination, inventory and payment tracking for Royal Care Home Service Massage.

##### Main Components
a. Frontend (royal-care-frontend)
- React SPA served by Vite
- Redux Toolkit for state (authSlice, schedulingSlice)
- Axios HTTP client (src/services/api.js)
- WebSocket service (src/services/webSocketService.js) for real-time updates
- CSS Modules for styling, role-based dashboards & pages.
b. Backend (guitara/)
- Django REST Framework with Django REST Knox for token auth
- Django Channels (asgi.py, routing.py, consumers.py) for WebSocket connections
- Core Django apps: authentication, core, registration, scheduling
- Models → Serializers → Views → URLs (MVC pattern)
- apply_migration script, manage.py entry point
c. Database
- PostgreSQL (production) / SQLite (development)
- Migrations under each app (guitara/*/migrations/)
d. External Services
- SMTP (Gmail) for 2FA email workflows
- GCash payment gateway API for cashless transactions
- (Optional) Redis as Channels layer backend
e. Deployment & Tooling
- Docker (future)
- pytest for tests (TBD)

##### Component Relationships & Data Flow
- Browser → React SPA → Redux store → API & WebSocket services
- Axios calls → Django REST endpoints (authentication/, core/, registration/, scheduling/)
- WebSocket client → Django Channels consumer (scheduling/consumers.py) for real-time slot availability & notifications
- Django ORM → PostgreSQL
- Django email backend → SMTP server
- Django payment endpoints → GCash API → backend validates via SHA-256 receipts

##### Architectural Patterns & Principles
- Backend: Traditional MVC + layered service (Views → Serializers → Models), separation of concerns per app.
- Real-time: publish-subscribe model via Channels (consumers + routing + channel layer).
- Frontend: Component-based UI with container/presentational split, unidirectional data flow (Redux).
- Security: token-based authentication, 2FA workflows, role-based permissions.

##### Detail Checklist
- ASGI server layer for Channels alongside WSGI for normal REST.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (royal-care-frontend)" 
        direction TB
        SPAEntry["SPA Entry\n(main.jsx,\nindex.html,\nvite.config.js)"]:::frontend
        StateMgmt["State Management\n(authSlice,\nschedulingSlice,\nstore.js)"]:::frontend
        Services["Services\n(api.js,\nwebSocketService.js,\nauth.js,\nnotification.js)"]:::frontend
        Pages["Pages & Dashboards\n(src/pages/,\nDriverDashboard.jsx,\nOperatorDashboard.jsx,\nTherapistDashboard.jsx,\nSchedulingDashboard.jsx)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (guitara)" 
        direction TB
        EntryPoints["Entry Points\n(manage.py,\napply_migration.py)"]:::backend
        ProjectConfig["Django Project\n(settings.py,\nurls.py,\nasgi.py,\nwsgi.py)"]:::backend
        subgraph "Apps"
            direction TB
            AuthApp["Authentication App\n(models.py,\nserializers.py,\nviews.py,\nurls.py)"]:::backend
            CoreApp["Core App\n(models.py,\npermissions.py,\nserializers.py,\nviews.py,\nurls.py)"]:::backend
            RegApp["Registration App\n(models.py,\nserializers.py,\nviews.py,\nurls.py)"]:::backend
            SchedApp["Scheduling App\n(models.py,\nserializers.py,\nviews.py,\nurls.py,\nconsumers.py,\nrouting.py,\nmiddleware.py)"]:::backend
        end
    end

    %% Database
    Database["PostgreSQL / SQLite"]:::db

    %% External Services
    subgraph "External Services"
        direction TB
        SMTP["SMTP (Gmail)"]:::external
        GCash["GCash API"]:::external
        Redis["Redis (optional)"]:::external
    end

    %% Connections
    User["User (Browser)"]:::external
    User -->|"loads SPA"| SPAEntry
    SPAEntry -->|"initializes"| StateMgmt
    StateMgmt --> Services
    Services -->|"HTTP/HTTPS"| ProjectConfig
    Services -->|WS/WSS| SchedApp
    ProjectConfig --> AuthApp
    ProjectConfig --> CoreApp
    ProjectConfig --> RegApp
    ProjectConfig --> SchedApp
    AuthApp --> Database
    CoreApp --> Database
    RegApp --> Database
    SchedApp --> Database
    AuthApp -->|"SMTP"| SMTP
    SchedApp -->|"HTTP/HTTPS"| GCash
    SchedApp -->|"Pub/Sub"| Redis

    %% Click Events - Frontend
    click SPAEntry "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/src/main.jsx"
    click SPAEntry "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/index.html"
    click SPAEntry "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/vite.config.js"
    click StateMgmt "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/src/features/auth/authSlice.js"
    click StateMgmt "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/src/features/scheduling/schedulingSlice.js"
    click StateMgmt "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/src/store.js"
    click Services "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/src/services/api.js"
    click Services "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/src/services/webSocketService.js"
    click Services "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/src/services/auth.js"
    click Services "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/src/services/notification.js"
    click Pages "https://github.com/notlath/guitara-scheduling-system/tree/main/royal-care-frontend/src/pages/"
    click Pages "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/src/components/DriverDashboard.jsx"
    click Pages "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/src/components/OperatorDashboard.jsx"
    click Pages "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/src/components/TherapistDashboard.jsx"
    click Pages "https://github.com/notlath/guitara-scheduling-system/blob/main/royal-care-frontend/src/components/scheduling/SchedulingDashboard.jsx"

    %% Click Events - Backend
    click EntryPoints "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/manage.py"
    click EntryPoints "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/apply_migration.py"
    click ProjectConfig "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/guitara/settings.py"
    click ProjectConfig "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/guitara/urls.py"
    click ProjectConfig "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/guitara/asgi.py"
    click ProjectConfig "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/guitara/wsgi.py"
    click AuthApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/authentication/models.py"
    click AuthApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/authentication/serializers.py"
    click AuthApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/authentication/views.py"
    click AuthApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/authentication/urls.py"
    click CoreApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/core/models.py"
    click CoreApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/core/permissions.py"
    click CoreApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/core/serializers.py"
    click CoreApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/core/views.py"
    click CoreApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/core/urls.py"
    click RegApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/registration/models.py"
    click RegApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/registration/serializers.py"
    click RegApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/registration/views.py"
    click RegApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/registration/urls.py"
    click SchedApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/scheduling/models.py"
    click SchedApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/scheduling/serializers.py"
    click SchedApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/scheduling/views.py"
    click SchedApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/scheduling/urls.py"
    click SchedApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/scheduling/consumers.py"
    click SchedApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/scheduling/routing.py"
    click SchedApp "https://github.com/notlath/guitara-scheduling-system/blob/main/guitara/scheduling/middleware.py"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#005cbf,color:#005cbf
    classDef backend fill:#d4edda,stroke:#198754,color:#198754
    classDef db fill:#ffe5b4,stroke:#ff8c00,color:#ff8c00
    classDef external fill:#e2d5f7,stroke:#6f42c1,color:#6f42c1
```
