# jooecoodes/cs317-swe architecture

> Architecture diagram of the GitHub repository jooecoodes/cs317-swe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jooecoodes/cs317-swe
- Repository: https://github.com/jooecoodes/cs317-swe

## Overview

This repository implements a violation-tracking API for managing employees, violation types, issued records, and analytics, backed by SQLite. The principal workflow is API request → route handler → query operations → persisted records, with schemas shaping request and response data. The tree also contains a frontend and GPS/PT services, but the available README does not describe their roles or wiring; they are shown as separate components without inferred connections. Some routing and data-layer links are supported by excerpts or the SOURCE INDEX; unsampled behavior is not assumed.

Main entry points: [`app/main.py`](https://github.com/jooecoodes/cs317-swe/blob/main/app/main.py) (App setup), [`app/routers/employees.py`](https://github.com/jooecoodes/cs317-swe/blob/main/app/routers/employees.py) (Employee routes), [`app/deps.py`](https://github.com/jooecoodes/cs317-swe/blob/main/app/deps.py) (Request dependencies), [`queries.py`](https://github.com/jooecoodes/cs317-swe/blob/main/queries.py) (Domain queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_app["App setup<br/>[main.py]"]
  node_employees["Employee routes<br/>[employees.py]"]
  node_types["Type routes<br/>[violation_types.py]"]
  node_violations["Violation routes<br/>[violations.py]"]
  node_analytics["Analytics routes<br/>[analytics.py]"]
  node_errors["Error handlers<br/>[errors.py]"]
  node_employee_schema["Employee schemas<br/>[employee.py]"]
  node_violation_schema["Violation schemas<br/>[violation.py]"]
  node_analytics_schema["Analytics schemas<br/>[analytics.py]"]
  node_common_schema["Common schemas<br/>[common.py]"]
  node_deps["Request dependencies<br/>[deps.py]"]
end

subgraph group_domain["Domain and data"]
  node_session["Session lifecycle<br/>[session.py]"]
  node_queries["Domain queries<br/>[queries.py]"]
  node_models["ORM models<br/>[models.py]"]
  node_database[("SQLite database<br/>[db.py]")]
  node_bootstrap["Database bootstrap<br/>[bootstrap.py]"]
end

subgraph group_aux["Other services"]
  node_gps["GPS service<br/>[main.py]"]
  node_gps_archive["GPS archiver<br/>[archiver.py]"]
  node_pt["PT service<br/>[main.py]"]
end

subgraph group_client["Client"]
  node_frontend["Web frontend<br/>[script.js]"]
end

node_user(("API user"))
node_web_actor(("Web user"))

node_user -->|"sends requests"| node_app
node_app -->|"registers"| node_employees
node_app -->|"registers"| node_types
node_app -->|"registers"| node_violations
node_app -->|"registers"| node_analytics
node_app -->|"registers"| node_errors
node_employees -->|"calls"| node_queries
node_types -->|"calls"| node_queries
node_violations -->|"calls"| node_queries
node_analytics -->|"calls"| node_queries
node_employees -->|"uses"| node_deps
node_types -->|"uses"| node_deps
node_violations -->|"uses"| node_deps
node_analytics -->|"uses"| node_deps
node_employees -->|"validates and shapes"| node_employee_schema
node_employees -->|"shapes pages"| node_common_schema
node_types -->|"validates and shapes"| node_violation_schema
node_violations -->|"validates and shapes"| node_violation_schema
node_analytics -->|"shapes results"| node_analytics_schema
node_deps -->|"depends on"| node_session
node_session -->|"creates sessions"| node_database
node_queries -->|"queries"| node_models
node_database -.->|"maps tables"| node_models
node_bootstrap -->|"initializes"| node_models
node_bootstrap -->|"uses"| node_database
node_web_actor -.->|"uses"| node_frontend

click node_app "https://github.com/jooecoodes/cs317-swe/blob/main/app/main.py"
click node_employees "https://github.com/jooecoodes/cs317-swe/blob/main/app/routers/employees.py"
click node_types "https://github.com/jooecoodes/cs317-swe/blob/main/app/routers/violation_types.py"
click node_violations "https://github.com/jooecoodes/cs317-swe/blob/main/app/routers/violations.py"
click node_analytics "https://github.com/jooecoodes/cs317-swe/blob/main/app/routers/analytics.py"
click node_errors "https://github.com/jooecoodes/cs317-swe/blob/main/app/errors.py"
click node_employee_schema "https://github.com/jooecoodes/cs317-swe/blob/main/app/schemas/employee.py"
click node_violation_schema "https://github.com/jooecoodes/cs317-swe/blob/main/app/schemas/violation.py"
click node_analytics_schema "https://github.com/jooecoodes/cs317-swe/blob/main/app/schemas/analytics.py"
click node_common_schema "https://github.com/jooecoodes/cs317-swe/blob/main/app/schemas/common.py"
click node_deps "https://github.com/jooecoodes/cs317-swe/blob/main/app/deps.py"
click node_session "https://github.com/jooecoodes/cs317-swe/blob/main/app/session.py"
click node_queries "https://github.com/jooecoodes/cs317-swe/blob/main/queries.py"
click node_models "https://github.com/jooecoodes/cs317-swe/blob/main/models.py"
click node_database "https://github.com/jooecoodes/cs317-swe/blob/main/db.py"
click node_bootstrap "https://github.com/jooecoodes/cs317-swe/blob/main/bootstrap.py"
click node_gps "https://github.com/jooecoodes/cs317-swe/blob/main/gps_service/main.py"
click node_gps_archive "https://github.com/jooecoodes/cs317-swe/blob/main/gps_service/archiver.py"
click node_pt "https://github.com/jooecoodes/cs317-swe/blob/main/pt_service/main.py"
click node_frontend "https://github.com/jooecoodes/cs317-swe/blob/main/frontend/js/script.js"

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_app,node_employees,node_types,node_violations,node_analytics,node_errors,node_employee_schema,node_violation_schema,node_analytics_schema,node_common_schema,node_deps,node_user,node_web_actor toneBlue
class node_session,node_queries,node_models,node_database,node_bootstrap toneAmber
class node_gps,node_gps_archive,node_pt toneMint
class node_frontend toneRose
```

## Components

### API

- [App setup](https://github.com/jooecoodes/cs317-swe/blob/main/app/main.py): `app/main.py`
- [Employee routes](https://github.com/jooecoodes/cs317-swe/blob/main/app/routers/employees.py): `app/routers/employees.py`
- [Type routes](https://github.com/jooecoodes/cs317-swe/blob/main/app/routers/violation_types.py): `app/routers/violation_types.py`
- [Violation routes](https://github.com/jooecoodes/cs317-swe/blob/main/app/routers/violations.py): `app/routers/violations.py`
- [Analytics routes](https://github.com/jooecoodes/cs317-swe/blob/main/app/routers/analytics.py): `app/routers/analytics.py`
- [Error handlers](https://github.com/jooecoodes/cs317-swe/blob/main/app/errors.py): `app/errors.py`
- [Employee schemas](https://github.com/jooecoodes/cs317-swe/blob/main/app/schemas/employee.py): `app/schemas/employee.py`
- [Violation schemas](https://github.com/jooecoodes/cs317-swe/blob/main/app/schemas/violation.py): `app/schemas/violation.py`
- [Analytics schemas](https://github.com/jooecoodes/cs317-swe/blob/main/app/schemas/analytics.py): `app/schemas/analytics.py`
- [Common schemas](https://github.com/jooecoodes/cs317-swe/blob/main/app/schemas/common.py): `app/schemas/common.py`
- [Request dependencies](https://github.com/jooecoodes/cs317-swe/blob/main/app/deps.py): `app/deps.py`

### Domain and data

- [Session lifecycle](https://github.com/jooecoodes/cs317-swe/blob/main/app/session.py): `app/session.py`
- [Domain queries](https://github.com/jooecoodes/cs317-swe/blob/main/queries.py): `queries.py`
- [ORM models](https://github.com/jooecoodes/cs317-swe/blob/main/models.py): `models.py`
- [SQLite database](https://github.com/jooecoodes/cs317-swe/blob/main/db.py): `db.py`
- [Database bootstrap](https://github.com/jooecoodes/cs317-swe/blob/main/bootstrap.py): `bootstrap.py`

### Other services

- [GPS service](https://github.com/jooecoodes/cs317-swe/blob/main/gps_service/main.py): `gps_service/main.py`
- [GPS archiver](https://github.com/jooecoodes/cs317-swe/blob/main/gps_service/archiver.py): `gps_service/archiver.py`
- [PT service](https://github.com/jooecoodes/cs317-swe/blob/main/pt_service/main.py): `pt_service/main.py`

### Client

- [Web frontend](https://github.com/jooecoodes/cs317-swe/blob/main/frontend/js/script.js): `frontend/js/script.js`

### Other components

- **API user**
- **Web user**

## Connections

- API user → App setup: sends requests (evidence: `app/main.py`)
- App setup → Employee routes: registers (evidence: `app/main.py`)
- App setup → Type routes: registers (evidence: `app/main.py`)
- App setup → Violation routes: registers (evidence: `app/main.py`)
- App setup → Analytics routes: registers (evidence: `app/main.py`)
- App setup → Error handlers: registers (evidence: `app/main.py`)
- Employee routes → Domain queries: calls (evidence: `app/routers/employees.py`)
- Type routes → Domain queries: calls (evidence: `app/routers/violation_types.py`)
- Violation routes → Domain queries: calls (evidence: `app/routers/violations.py`)
- Analytics routes → Domain queries: calls (evidence: `app/routers/analytics.py`)
- Employee routes → Request dependencies: uses (evidence: `app/routers/employees.py`)
- Type routes → Request dependencies: uses (evidence: `app/routers/violation_types.py`)
- Violation routes → Request dependencies: uses (evidence: `app/routers/violations.py`)
- Analytics routes → Request dependencies: uses (evidence: `app/routers/analytics.py`)
- Employee routes → Employee schemas: validates and shapes (evidence: `app/routers/employees.py`)
- Employee routes → Common schemas: shapes pages (evidence: `app/routers/employees.py`)
- Type routes → Violation schemas: validates and shapes (evidence: `app/routers/violation_types.py`)
- Violation routes → Violation schemas: validates and shapes (evidence: `app/routers/violations.py`)
- Analytics routes → Analytics schemas: shapes results (evidence: `app/routers/analytics.py`)
- Request dependencies → Session lifecycle: depends on (evidence: `app/deps.py`)
- Session lifecycle → SQLite database: creates sessions (evidence: `app/session.py`)
- Domain queries → ORM models: queries (evidence: `queries.py`)
- SQLite database → ORM models: maps tables
- Database bootstrap → ORM models: initializes (evidence: `bootstrap.py`)
- Database bootstrap → SQLite database: uses (evidence: `bootstrap.py`)
- Web user → Web frontend: uses
