# chrizziboi/skapapp architecture

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

- Interactive diagram: https://gitdiagram.com/chrizziboi/skapapp
- Repository: https://github.com/chrizziboi/skapapp

## Overview

##### Project type and purpose
- This is a monolithic full-stack application built with FastAPI that serves server-side rendered HTML (Jinja2 templates) and manages an RFID-integrated locker system.
- Its purpose is to handle user login via RFID, dynamic/static locker reservation, role-based access (admin vs. standard user), logging, statistics, backup/restore, and asynchronous cleanup.

##### File structure
- Top-level entry point: main.py (FastAPI application)
- Database setup and backup utilities in database.py
- Business-logic layer in backend/Service and error handling in backend/Service/ErrorHandler.py
- ORM models under backend/model (AdminUser, StandardUser, Locker, LockerRoom, LockerLog, Statistic)
- Static assets (CSS) in static/ and server-side HTML templates in templates/
- Tests in tests/ but these are out of the runtime path

##### README for additional insights
- FastAPI + Uvicorn for the web server
- SQLite + SQLAlchemy for persistence and ORM
- Jinja2 for templating
- Endpoints for authentication, RFID scanning, reservation, CRUD, statistics, backup/restore, error handling, and an asynchronous cleanup task

##### Diagramming recommendations
- Related components (e.g., put all models in one cluster, all templates/static in another)

##### Detail without overcomplexity
- Every runtime component (router, services, models, DB, async tasks, error handler, file system)
- Asynchronous and synchronous flows distinctly

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["Browser / UI"]:::frontend
        Templates["Jinja2 Templates"]:::frontend
        Static["Static Assets (CSS)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        FastAPI["FastAPI App (Uvicorn)"]:::backend
        Routing["Routing Layer"]:::backend
        Service["Service Layer"]:::backend
        ErrorHandler["ErrorHandler"]:::backend
        BackgroundTasks["Background Task Scheduler"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        Models["ORM Models"]:::data
        SQLiteDB["SQLite Database"]:::data
        DBUtils["Database Utilities"]:::data
    end

    %% File System
    subgraph "File System"
        FSLogs["Logs & JSON Backups"]:::fs
    end

    %% Connections
    Browser -->|HTTP Requests| FastAPI
    FastAPI -->|routes requests| Routing
    Routing -->|calls| Service
    Service -->|reads/writes| Models
    Models -->|persists| SQLiteDB
    Routing -->|backup/restore| DBUtils
    DBUtils -->|writes/reads| FSLogs
    Service -->|writes| FSLogs
    Service -->|raises errors| ErrorHandler
    Routing -->|raises errors| ErrorHandler
    BackgroundTasks -->|invokes cleanup| Service
    FastAPI -->|schedules tasks| BackgroundTasks
    ErrorHandler -->|returns HTTPException| FastAPI

    %% Click Events
    click Templates "https://github.com/chrizziboi/skapapp/tree/main/templates/"
    click Static "https://github.com/chrizziboi/skapapp/tree/main/static/"
    click FastAPI "https://github.com/chrizziboi/skapapp/blob/main/main.py"
    click Routing "https://github.com/chrizziboi/skapapp/blob/main/main.py"
    click BackgroundTasks "https://github.com/chrizziboi/skapapp/blob/main/main.py"
    click Service "https://github.com/chrizziboi/skapapp/tree/main/backend/Service/"
    click ErrorHandler "https://github.com/chrizziboi/skapapp/blob/main/backend/Service/ErrorHandler.py"
    click Models "https://github.com/chrizziboi/skapapp/tree/main/backend/model/"
    click DBUtils "https://github.com/chrizziboi/skapapp/blob/main/database.py"

    %% Styles
    classDef frontend fill:#E5F5FF,stroke:#333,stroke-width:1px
    classDef backend fill:#FFF5E5,stroke:#333,stroke-width:1px
    classDef data fill:#E5FFE5,stroke:#333,stroke-width:1px
    classDef fs fill:#F5E5FF,stroke:#333,stroke-width:1px
```
