# melaldrinr-star/fiinal-v5 architecture

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

- Interactive diagram: https://gitdiagram.com/melaldrinr-star/fiinal-v5
- Repository: https://github.com/melaldrinr-star/fiinal-v5

## Overview

BMDC is a multi-tenant trainee management and attendance system. A user enters through the React application, authenticates, then uses role-protected screens to manage programs, enrollments, trainee records, and attendance; the frontend communicates with Next.js API routes backed by Supabase. Separate product capabilities include inventory lending, certificates, reporting, notifications, and tenant administration. The README documents these workflows and integrations; source excerpts additionally confirm frontend routing and the requirement-definition statistics helper. Most individual routes and services were not sampled, so their internal call relationships are not asserted.

Main entry points: [`Backend/src/services`](https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/services) (Business services), [`Frontend/src/App.tsx`](https://github.com/melaldrinr-star/fiinal-v5/blob/main/Frontend/src/App.tsx) (React application), [`Frontend/src/contexts/AuthContext.tsx`](https://github.com/melaldrinr-star/fiinal-v5/blob/main/Frontend/src/contexts/AuthContext.tsx) (Auth context), [`Frontend/src/components/ProtectedRoute.tsx`](https://github.com/melaldrinr-star/fiinal-v5/blob/main/Frontend/src/components/ProtectedRoute.tsx) (Role-protected routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_webapp["React application<br/>[App.tsx]"]
end

subgraph group_identity["Identity and access"]
  node_authcontext["Auth context<br/>[AuthContext.tsx]"]
  node_protectedroute["Role-protected routes<br/>[ProtectedRoute.tsx]"]
  node_authservice["Authentication service<br/>[authService.ts]"]
  node_accounts["Registration and accounts<br/>[route.ts]"]
end

subgraph group_training["Training operations"]
  node_trainees["Trainee management"]
  node_programs["Programs and enrollment"]
  node_enrollments["Enrollment service"]
  node_attendance["Attendance tracking"]
  node_requirements["Training requirements<br/>[route.ts]"]
  node_certificates["Certificates"]
end

subgraph group_operations["Platform operations"]
  node_inventory["Inventory and lending"]
  node_reporting["Reports and activity"]
  node_communications["Notifications and email"]
  node_tenantadmin["Tenant administration"]
end

subgraph group_infrastructure["Backend infrastructure"]
  node_apis["Next.js API routes"]
  node_services["Business services"]
  node_database[("Supabase PostgreSQL")]
end

node_trainee(("Trainee or staff"))

node_trainee -->|"uses"| node_webapp
node_webapp -->|"provides context"| node_authcontext
node_webapp -->|"routes through"| node_protectedroute
node_protectedroute -->|"checks access"| node_authcontext
node_authcontext -->|"authenticates with"| node_authservice
node_authservice -.->|"calls API"| node_apis
node_trainee -->|"registers"| node_accounts
node_accounts -.->|"processes account"| node_services
node_apis -.->|"delegates business logic"| node_services
node_services -->|"reads and writes"| node_database
node_trainee -->|"browses and enrolls"| node_programs
node_programs -.->|"manages enrollment"| node_enrollments
node_trainee -->|"marks attendance"| node_attendance
node_trainee -.->|"submits requirements"| node_requirements
node_requirements -->|"calculates statistics"| node_services
node_trainee -->|"manages profile"| node_trainees
node_trainees -->|"tracks certification"| node_certificates
node_trainee -.->|"uses lending"| node_inventory
node_trainee -.->|"views reports"| node_reporting
node_services -.->|"sends notifications"| node_communications
node_tenantadmin -.->|"administers tenant data"| node_database

click node_webapp "https://github.com/melaldrinr-star/fiinal-v5/blob/main/Frontend/src/App.tsx"
click node_authcontext "https://github.com/melaldrinr-star/fiinal-v5/blob/main/Frontend/src/contexts/AuthContext.tsx"
click node_protectedroute "https://github.com/melaldrinr-star/fiinal-v5/blob/main/Frontend/src/components/ProtectedRoute.tsx"
click node_authservice "https://github.com/melaldrinr-star/fiinal-v5/blob/main/Frontend/src/services/authService.ts"
click node_accounts "https://github.com/melaldrinr-star/fiinal-v5/blob/main/Backend/src/app/api/registrations/route.ts"
click node_trainees "https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/trainees"
click node_programs "https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/programs"
click node_enrollments "https://github.com/melaldrinr-star/fiinal-v5/blob/main/Backend/src/services/enrollmentRequirementService.ts"
click node_attendance "https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/attendance"
click node_requirements "https://github.com/melaldrinr-star/fiinal-v5/blob/main/Backend/src/app/api/requirement-definitions/route.ts"
click node_certificates "https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/certificates"
click node_inventory "https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/items"
click node_reporting "https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/reports"
click node_communications "https://github.com/melaldrinr-star/fiinal-v5/blob/main/Backend/src/services/notificationService.ts"
click node_tenantadmin "https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/admin/tenants"
click node_apis "https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api"
click node_services "https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/services"

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_webapp toneBlue
class node_authcontext,node_protectedroute,node_authservice,node_accounts toneAmber
class node_trainees,node_programs,node_enrollments,node_attendance,node_requirements,node_certificates toneMint
class node_inventory,node_reporting,node_communications,node_tenantadmin toneRose
class node_apis,node_services,node_database,node_trainee toneIndigo
```

## Components

### Web application

- [React application](https://github.com/melaldrinr-star/fiinal-v5/blob/main/Frontend/src/App.tsx): `Frontend/src/App.tsx`

### Identity and access

- [Auth context](https://github.com/melaldrinr-star/fiinal-v5/blob/main/Frontend/src/contexts/AuthContext.tsx): `Frontend/src/contexts/AuthContext.tsx`
- [Role-protected routes](https://github.com/melaldrinr-star/fiinal-v5/blob/main/Frontend/src/components/ProtectedRoute.tsx): `Frontend/src/components/ProtectedRoute.tsx`
- [Authentication service](https://github.com/melaldrinr-star/fiinal-v5/blob/main/Frontend/src/services/authService.ts): `Frontend/src/services/authService.ts`
- [Registration and accounts](https://github.com/melaldrinr-star/fiinal-v5/blob/main/Backend/src/app/api/registrations/route.ts): `Backend/src/app/api/registrations/route.ts`

### Training operations

- [Trainee management](https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/trainees): `Backend/src/app/api/trainees`
- [Programs and enrollment](https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/programs): `Backend/src/app/api/programs`
- [Enrollment service](https://github.com/melaldrinr-star/fiinal-v5/blob/main/Backend/src/services/enrollmentRequirementService.ts): `Backend/src/services/enrollmentRequirementService.ts`
- [Attendance tracking](https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/attendance): `Backend/src/app/api/attendance`
- [Training requirements](https://github.com/melaldrinr-star/fiinal-v5/blob/main/Backend/src/app/api/requirement-definitions/route.ts): `Backend/src/app/api/requirement-definitions/route.ts`
- [Certificates](https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/certificates): `Backend/src/app/api/certificates`

### Platform operations

- [Inventory and lending](https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/items): `Backend/src/app/api/items`
- [Reports and activity](https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/reports): `Backend/src/app/api/reports`
- [Notifications and email](https://github.com/melaldrinr-star/fiinal-v5/blob/main/Backend/src/services/notificationService.ts): `Backend/src/services/notificationService.ts`
- [Tenant administration](https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api/admin/tenants): `Backend/src/app/api/admin/tenants`

### Backend infrastructure

- [Next.js API routes](https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/app/api): `Backend/src/app/api`
- [Business services](https://github.com/melaldrinr-star/fiinal-v5/tree/main/Backend/src/services): `Backend/src/services`
- **Supabase PostgreSQL**

### Other components

- **Trainee or staff**

## Connections

- Trainee or staff → React application: uses (evidence: `README.md`)
- React application → Auth context: provides context (evidence: `Frontend/src/App.tsx`)
- React application → Role-protected routes: routes through (evidence: `Frontend/src/App.tsx`)
- Role-protected routes → Auth context: checks access (evidence: `Frontend/src/components/ProtectedRoute.tsx`)
- Auth context → Authentication service: authenticates with (evidence: `Frontend/src/contexts/AuthContext.tsx`)
- Authentication service → Next.js API routes: calls API
- Trainee or staff → Registration and accounts: registers (evidence: `README.md`)
- Registration and accounts → Business services: processes account
- Next.js API routes → Business services: delegates business logic
- Business services → Supabase PostgreSQL: reads and writes (evidence: `README.md`)
- Trainee or staff → Programs and enrollment: browses and enrolls (evidence: `README.md`)
- Programs and enrollment → Enrollment service: manages enrollment
- Trainee or staff → Attendance tracking: marks attendance (evidence: `README.md`)
- Trainee or staff → Training requirements: submits requirements
- Training requirements → Business services: calculates statistics (evidence: `Backend/src/app/api/requirement-definitions/route.ts`)
- Trainee or staff → Trainee management: manages profile (evidence: `README.md`)
- Trainee management → Certificates: tracks certification (evidence: `README.md`)
- Trainee or staff → Inventory and lending: uses lending
- Trainee or staff → Reports and activity: views reports
- Business services → Notifications and email: sends notifications
- Tenant administration → Supabase PostgreSQL: administers tenant data
