# ensophann-sudo/wetelegram-v1 architecture

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

- Interactive diagram: https://gitdiagram.com/ensophann-sudo/wetelegram-v1
- Repository: https://github.com/ensophann-sudo/wetelegram-v1

## Overview

TPM Training Management System combines a React control center with a FastAPI/PostgreSQL backend. The main user workflow is employee setup and controlled spreadsheet import, followed by training planning, sessions, participant assignment, attendance, assessment and follow-up, OJT approval, and reporting/audit. The excerpts show only some API stages; reports, reconciliation, exports, and several workflow details are documented capabilities rather than inspected implementations. Edges below reflect visible calls and README claims, not a complete route inventory.

Main entry points: [`api.py`](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.py) (API workflows), [`worker.py`](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/worker.py) (Notification worker), [`main.jsx`](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/main.jsx) (Role-based UI), [`api.js`](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Control center"]
  node_web["Role-based UI<br/>[main.jsx]"]
  node_client["API client<br/>[api.js]"]
end

subgraph group_api["API and access"]
  node_app["FastAPI application<br/>[main.py]"]
  node_routes["API workflows<br/>[api.py]"]
  node_access["Authentication and roles<br/>[security.py]"]
end

subgraph group_training["Training operations"]
  node_employees["Employee records<br/>[api.py]"]
  node_imports["Import preview and approval<br/>[imports.py]"]
  node_planning["Annual plan"]
  node_sessions["Training sessions<br/>[api.py]"]
  node_participants["Participants<br/>[api.py]"]
  node_attendance["Attendance<br/>[api.py]"]
  node_assessments["Assessments and follow-up"]
  node_ojt["OJT workflow<br/>[api.py]"]
end

subgraph group_data["Data and oversight"]
  node_reports["Reports and reconciliation"]
  node_audit["Audit history<br/>[audit.py]"]
  node_models["Domain records<br/>[models.py]"]
  node_database[("PostgreSQL")]
end

subgraph group_integrations["Notifications"]
  node_worker["Notification worker<br/>[worker.py]"]
  node_telegram["Telegram"]
end

node_user(("Training staff"))

node_user -->|"uses"| node_web
node_web -->|"calls"| node_client
node_client -->|"requests"| node_app
node_app -->|"registers"| node_routes
node_routes -->|"checks access"| node_access
node_routes -->|"handles"| node_employees
node_routes -->|"previews"| node_imports
node_routes -->|"creates"| node_sessions
node_routes -->|"assigns"| node_participants
node_routes -->|"records"| node_attendance
node_routes -->|"submits and decides"| node_ojt
node_routes -->|"logs actions"| node_audit
node_routes -->|"reads and writes"| node_database
node_imports -->|"stores previews"| node_database
node_models -.->|"maps records"| node_database
node_worker -->|"loads queue"| node_database
node_worker -->|"sends messages"| node_telegram
node_routes -.->|"supports workflow"| node_planning
node_routes -.->|"supports workflow"| node_assessments
node_routes -.->|"supports reporting"| node_reports

click node_web "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/main.jsx"
click node_client "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.js"
click node_app "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/main.py"
click node_routes "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.py"
click node_access "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/security.py"
click node_employees "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.py"
click node_imports "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/imports.py"
click node_sessions "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.py"
click node_participants "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.py"
click node_attendance "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.py"
click node_ojt "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.py"
click node_audit "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/audit.py"
click node_models "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/models.py"
click node_worker "https://github.com/ensophann-sudo/wetelegram-v1/blob/main/worker.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,node_client toneBlue
class node_app,node_routes,node_access toneAmber
class node_employees,node_imports,node_planning,node_sessions,node_participants,node_attendance,node_assessments,node_ojt toneMint
class node_reports,node_audit,node_models,node_database toneRose
class node_worker,node_telegram,node_user toneIndigo
```

## Components

### Control center

- [Role-based UI](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/main.jsx): `main.jsx`
- [API client](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.js): `api.js`

### API and access

- [FastAPI application](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/main.py): `main.py`
- [API workflows](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.py): `api.py`
- [Authentication and roles](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/security.py): `security.py`

### Training operations

- [Employee records](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.py): `api.py`
- [Import preview and approval](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/imports.py): `imports.py`
- **Annual plan**
- [Training sessions](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.py): `api.py`
- [Participants](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.py): `api.py`
- [Attendance](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.py): `api.py`
- **Assessments and follow-up**
- [OJT workflow](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/api.py): `api.py`

### Data and oversight

- **Reports and reconciliation**
- [Audit history](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/audit.py): `audit.py`
- [Domain records](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/models.py): `models.py`
- **PostgreSQL**

### Notifications

- [Notification worker](https://github.com/ensophann-sudo/wetelegram-v1/blob/main/worker.py): `worker.py`
- **Telegram**

### Other components

- **Training staff**

## Connections

- Training staff → Role-based UI: uses (evidence: `README.md`)
- Role-based UI → API client: calls (evidence: `main.jsx`)
- API client → FastAPI application: requests (evidence: `api.js`)
- FastAPI application → API workflows: registers (evidence: `main.py`)
- API workflows → Authentication and roles: checks access (evidence: `api.py`)
- API workflows → Employee records: handles (evidence: `api.py`)
- API workflows → Import preview and approval: previews (evidence: `api.py`)
- API workflows → Training sessions: creates (evidence: `api.py`)
- API workflows → Participants: assigns (evidence: `api.py`)
- API workflows → Attendance: records (evidence: `api.py`)
- API workflows → OJT workflow: submits and decides (evidence: `api.py`)
- API workflows → Audit history: logs actions (evidence: `api.py`)
- API workflows → PostgreSQL: reads and writes (evidence: `api.py`)
- Import preview and approval → PostgreSQL: stores previews
- Domain records → PostgreSQL: maps records
- Notification worker → PostgreSQL: loads queue (evidence: `worker.py`)
- Notification worker → Telegram: sends messages (evidence: `worker.py`)
- API workflows → Annual plan: supports workflow (evidence: `README.md`)
- API workflows → Assessments and follow-up: supports workflow (evidence: `README.md`)
- API workflows → Reports and reconciliation: supports reporting (evidence: `README.md`)
