# 2kdietga/pbl6 architecture

> Architecture diagram of the GitHub repository 2kdietga/pbl6, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/2kdietga/pbl6
- Repository: https://github.com/2kdietga/pbl6

## Overview

This is a Django driver-management and driving-monitoring system: drivers and administrators use the web application, while Raspberry Pi devices use device APIs. The documented end-to-end workflow covers driver/profile and licence approval, vehicle assignment, identity and eligibility checks, driving sessions, then violation review and driver appeals. The source also shows profile-image processing and session/shift services. The README distinguishes implemented features from planned ones; violation ingestion and appeals UI are not yet implemented, and some subsystem links below rely on README-level documentation rather than sampled call sites.

Main entry points: [`frontend/views.py`](https://github.com/2kdietga/pbl6/blob/main/frontend/views.py) (Web interface), [`driving/session_services.py`](https://github.com/2kdietga/pbl6/blob/main/driving/session_services.py) (Session lifecycle), [`accounts/profile_services.py`](https://github.com/2kdietga/pbl6/blob/main/accounts/profile_services.py) (Profile services), [`accounts/media_services.py`](https://github.com/2kdietga/pbl6/blob/main/accounts/media_services.py) (Media and embeddings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_web_ui["Web interface<br/>[views.py]"]
  node_web_forms["Web forms<br/>[forms.py]"]
end

subgraph group_identity["Driver identity"]
  node_profiles["Profile services"]
  node_media["Media and embeddings<br/>[media_services.py]"]
  node_identity_data[("Accounts and profiles<br/>[models.py]")]
end

subgraph group_fleet["Fleet and scheduling"]
  node_fleet_data[("Vehicles and assignments<br/>[models.py]")]
  node_licensing["Licence eligibility<br/>[licensing.py]"]
  node_shift_services["Shift scheduling<br/>[shift_services.py]"]
end

subgraph group_device["Device and sessions"]
  node_device_api["Device API<br/>[device_api.py]"]
  node_protocol["Device protocol<br/>[device_protocol.py]"]
  node_session_services["Session lifecycle"]
  node_session_data[("Driving sessions<br/>[models.py]")]
end

subgraph group_violations["Violations and review"]
  node_violation_api["Device violation API<br/>[device_api.py]"]
  node_violation_review["Violation review<br/>[services.py]"]
  node_violation_data[("Violations and appeals<br/>[models.py]")]
end

node_driver(("Driver"))
node_admin(("Administrator"))
node_face_api["Face embedding API"]
node_device(("Raspberry Pi"))
node_cloudinary["Cloudinary"]

node_driver -->|"uses"| node_web_ui
node_admin -->|"uses"| node_web_ui
node_web_ui -->|"submits"| node_web_forms
node_web_forms -->|"saves profile"| node_profiles
node_profiles -->|"updates"| node_identity_data
node_profiles -->|"extracts and uploads"| node_media
node_media -->|"requests embeddings"| node_face_api
node_media -->|"uploads images"| node_cloudinary
node_web_ui -->|"manages fleet"| node_fleet_data
node_web_ui -->|"manages shifts"| node_shift_services
node_shift_services -->|"locks assignments"| node_fleet_data
node_device -->|"calls"| node_device_api
node_device_api -->|"uses errors"| node_protocol
node_device_api -->|"starts and ends"| node_session_services
node_session_services -->|"checks driver"| node_identity_data
node_session_services -->|"checks device and assignment"| node_fleet_data
node_session_services -->|"checks licence fit"| node_licensing
node_session_services -->|"selects shift"| node_shift_services
node_session_services -->|"creates and ends"| node_session_data
node_device -.->|"may send violations"| node_violation_api
node_violation_api -.->|"would record"| node_violation_data
node_admin -->|"reviews violations"| node_violation_review
node_driver -->|"views and appeals"| node_web_ui
node_violation_review -->|"records decisions"| node_violation_data
node_web_ui -->|"displays violations"| node_violation_data

click node_web_ui "https://github.com/2kdietga/pbl6/blob/main/frontend/views.py"
click node_web_forms "https://github.com/2kdietga/pbl6/blob/main/frontend/forms.py"
click node_profiles "https://github.com/2kdietga/pbl6/blob/main/accounts/profile_services.py"
click node_media "https://github.com/2kdietga/pbl6/blob/main/accounts/media_services.py"
click node_identity_data "https://github.com/2kdietga/pbl6/blob/main/accounts/models.py"
click node_fleet_data "https://github.com/2kdietga/pbl6/blob/main/vehicles/models.py"
click node_licensing "https://github.com/2kdietga/pbl6/blob/main/vehicles/licensing.py"
click node_shift_services "https://github.com/2kdietga/pbl6/blob/main/driving/shift_services.py"
click node_device_api "https://github.com/2kdietga/pbl6/blob/main/driving/device_api.py"
click node_protocol "https://github.com/2kdietga/pbl6/blob/main/driving/device_protocol.py"
click node_session_services "https://github.com/2kdietga/pbl6/blob/main/driving/session_services.py"
click node_session_data "https://github.com/2kdietga/pbl6/blob/main/driving/models.py"
click node_violation_api "https://github.com/2kdietga/pbl6/blob/main/violations/device_api.py"
click node_violation_review "https://github.com/2kdietga/pbl6/blob/main/violations/services.py"
click node_violation_data "https://github.com/2kdietga/pbl6/blob/main/violations/models.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web_ui,node_web_forms toneBlue
class node_profiles,node_media,node_identity_data toneAmber
class node_fleet_data,node_licensing,node_shift_services,node_face_api toneMint
class node_device_api,node_protocol,node_session_services,node_session_data toneRose
class node_violation_api,node_violation_review,node_violation_data,node_driver,node_admin,node_device,node_cloudinary toneIndigo
```

## Components

### Web application

- [Web interface](https://github.com/2kdietga/pbl6/blob/main/frontend/views.py): `frontend/views.py`
- [Web forms](https://github.com/2kdietga/pbl6/blob/main/frontend/forms.py): `frontend/forms.py`

### Driver identity

- [Profile services](https://github.com/2kdietga/pbl6/blob/main/accounts/profile_services.py): `accounts/profile_services.py`
- [Media and embeddings](https://github.com/2kdietga/pbl6/blob/main/accounts/media_services.py): `accounts/media_services.py`
- [Accounts and profiles](https://github.com/2kdietga/pbl6/blob/main/accounts/models.py): `accounts/models.py`

### Fleet and scheduling

- [Vehicles and assignments](https://github.com/2kdietga/pbl6/blob/main/vehicles/models.py): `vehicles/models.py`
- [Licence eligibility](https://github.com/2kdietga/pbl6/blob/main/vehicles/licensing.py): `vehicles/licensing.py`
- [Shift scheduling](https://github.com/2kdietga/pbl6/blob/main/driving/shift_services.py): `driving/shift_services.py`

### Device and sessions

- [Device API](https://github.com/2kdietga/pbl6/blob/main/driving/device_api.py): `driving/device_api.py`
- [Device protocol](https://github.com/2kdietga/pbl6/blob/main/driving/device_protocol.py): `driving/device_protocol.py`
- [Session lifecycle](https://github.com/2kdietga/pbl6/blob/main/driving/session_services.py): `driving/session_services.py`
- [Driving sessions](https://github.com/2kdietga/pbl6/blob/main/driving/models.py): `driving/models.py`

### Violations and review

- [Device violation API](https://github.com/2kdietga/pbl6/blob/main/violations/device_api.py): `violations/device_api.py`
- [Violation review](https://github.com/2kdietga/pbl6/blob/main/violations/services.py): `violations/services.py`
- [Violations and appeals](https://github.com/2kdietga/pbl6/blob/main/violations/models.py): `violations/models.py`

### Other components

- **Driver**
- **Administrator**
- **Face embedding API**
- **Raspberry Pi**
- **Cloudinary**

## Connections

- Driver → Web interface: uses
- Administrator → Web interface: uses
- Web interface → Web forms: submits (evidence: `frontend/views.py`)
- Web forms → Profile services: saves profile (evidence: `accounts/profile_services.py`)
- Profile services → Accounts and profiles: updates (evidence: `accounts/profile_services.py`)
- Profile services → Media and embeddings: extracts and uploads (evidence: `accounts/profile_services.py`)
- Media and embeddings → Face embedding API: requests embeddings (evidence: `accounts/media_services.py`)
- Media and embeddings → Cloudinary: uploads images (evidence: `accounts/media_services.py`)
- Web interface → Vehicles and assignments: manages fleet (evidence: `frontend/views.py`)
- Web interface → Shift scheduling: manages shifts
- Shift scheduling → Vehicles and assignments: locks assignments (evidence: `driving/shift_services.py`)
- Raspberry Pi → Device API: calls
- Device API → Device protocol: uses errors (evidence: `driving/device_api.py`)
- Device API → Session lifecycle: starts and ends (evidence: `driving/device_api.py`)
- Session lifecycle → Accounts and profiles: checks driver (evidence: `driving/session_services.py`)
- Session lifecycle → Vehicles and assignments: checks device and assignment (evidence: `driving/session_services.py`)
- Session lifecycle → Licence eligibility: checks licence fit (evidence: `driving/session_services.py`)
- Session lifecycle → Shift scheduling: selects shift (evidence: `driving/session_services.py`)
- Session lifecycle → Driving sessions: creates and ends (evidence: `driving/session_services.py`)
- Raspberry Pi → Device violation API: may send violations
- Device violation API → Violations and appeals: would record
- Administrator → Violation review: reviews violations
- Driver → Web interface: views and appeals
- Violation review → Violations and appeals: records decisions (evidence: `violations/services.py`)
- Web interface → Violations and appeals: displays violations (evidence: `frontend/views.py`)
