# ghalass/multi_tenant architecture

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

- Interactive diagram: https://gitdiagram.com/ghalass/multi_tenant
- Repository: https://github.com/ghalass/multi_tenant

## Overview

This is a multi-tenant GMAO (maintenance and fleet-management) web application. Users manage fleet assets and operational records, enter usage and failure data, plan preventive maintenance, then consult reports and statistics. Separate capabilities include lubricant tracking, spreadsheet imports, access administration, and database backup/restore. The graph emphasizes documented page-to-service and route-to-import relationships; many listed subsystems were not sampled, so their internal calls are omitted rather than inferred.

Main entry points: [`app/api/independent-batch-import/route.ts`](https://github.com/ghalass/multi_tenant/blob/main/app/api/independent-batch-import/route.ts) (Batch import endpoint), [`app/api/import/route.ts`](https://github.com/ghalass/multi_tenant/blob/main/app/api/import/route.ts) (Import endpoint), [`services/importService.ts`](https://github.com/ghalass/multi_tenant/blob/main/services/importService.ts) (Import dispatcher), [`server/database-backup-actions.ts`](https://github.com/ghalass/multi_tenant/blob/main/server/database-backup-actions.ts) (Backup actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operations["Fleet operations"]
  node_fleet_ui["Fleet records<br/>[page.tsx]"]
  node_failure_ui["Failure records<br/>[page.tsx]"]
  node_backlog_ui["Backlog records<br/>[page.tsx]"]
  node_usage_ui["HIM entries<br/>[page.tsx]"]
  node_hrm_ui["HRM entries<br/>[page.tsx]"]
  node_fleet_services["Fleet services"]
  node_backlog_service["Backlog service<br/>[backlogs.ts]"]
  node_him_service["HIM service<br/>[saisie_him.ts]"]
end

subgraph group_maintenance["Maintenance workflows"]
  node_preventive["Preventive maintenance"]
  node_lubricants["Lubricant tracking<br/>[page.tsx]"]
end

subgraph group_insights["Reporting and imports"]
  node_reports["Reports and statistics"]
  node_him_stats["HIM statistics<br/>[page.tsx]"]
  node_imports_ui["Spreadsheet import<br/>[page.tsx]"]
  node_import_api["Import endpoint<br/>[route.ts]"]
  node_import_service["Import dispatcher<br/>[importService.ts]"]
  node_batch_api["Batch import endpoint<br/>[route.ts]"]
  node_batch_service["Batch import engine"]
end

subgraph group_platform["Identity and administration"]
  node_login["Authentication<br/>[auth.ts]"]
  node_rbac["Access control<br/>[middleware.ts]"]
  node_backups["Database backups"]
  node_backup_actions["Backup actions"]
  node_backup_service["Backup service<br/>[database-backup.ts]"]
end

node_user(("User"))

node_user -.->|"signs in"| node_login
node_failure_ui -->|"loads records"| node_fleet_services
node_backlog_ui -->|"loads records"| node_backlog_service
node_usage_ui -->|"loads records"| node_him_service
node_him_stats -->|"loads statistics"| node_him_service
node_imports_ui -.->|"uploads data"| node_import_api
node_import_api -->|"dispatches import"| node_import_service
node_import_service -->|"imports records"| node_fleet_services
node_batch_api -->|"runs batches"| node_batch_service
node_batch_api -->|"checks permission"| node_rbac
node_backups -->|"requests backup actions"| node_backup_actions
node_backup_actions -->|"manages archives"| node_backup_service

click node_fleet_ui "https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/engins/page.tsx"
click node_failure_ui "https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/pannes/page.tsx"
click node_backlog_ui "https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/backlogs/page.tsx"
click node_usage_ui "https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/saisie-him/page.tsx"
click node_hrm_ui "https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/saisie-hrm/page.tsx"
click node_fleet_services "https://github.com/ghalass/multi_tenant/tree/main/server"
click node_backlog_service "https://github.com/ghalass/multi_tenant/blob/main/server/backlogs.ts"
click node_him_service "https://github.com/ghalass/multi_tenant/blob/main/server/saisie_him.ts"
click node_preventive "https://github.com/ghalass/multi_tenant/tree/main/app/%5Blocale%5D/(main)/maintenance-preventive"
click node_lubricants "https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/saisie-lubrifiants/page.tsx"
click node_reports "https://github.com/ghalass/multi_tenant/tree/main/app/%5Blocale%5D/(main)/rapports"
click node_him_stats "https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/saisie_hrm_stats/page.tsx"
click node_imports_ui "https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/import/page.tsx"
click node_import_api "https://github.com/ghalass/multi_tenant/blob/main/app/api/import/route.ts"
click node_import_service "https://github.com/ghalass/multi_tenant/blob/main/services/importService.ts"
click node_batch_api "https://github.com/ghalass/multi_tenant/blob/main/app/api/independent-batch-import/route.ts"
click node_batch_service "https://github.com/ghalass/multi_tenant/blob/main/services/independentBatchImportService.ts"
click node_login "https://github.com/ghalass/multi_tenant/blob/main/lib/auth.ts"
click node_rbac "https://github.com/ghalass/multi_tenant/blob/main/lib/rbac/middleware.ts"
click node_backups "https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/database-backups/database-backups-client.tsx"
click node_backup_actions "https://github.com/ghalass/multi_tenant/blob/main/server/database-backup-actions.ts"
click node_backup_service "https://github.com/ghalass/multi_tenant/blob/main/services/database-backup.ts"

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_fleet_ui,node_failure_ui,node_backlog_ui,node_usage_ui,node_hrm_ui,node_fleet_services,node_backlog_service,node_him_service,node_user toneBlue
class node_preventive,node_lubricants toneAmber
class node_reports,node_him_stats,node_imports_ui,node_import_api,node_import_service,node_batch_api,node_batch_service toneMint
class node_login,node_rbac,node_backups,node_backup_actions,node_backup_service toneRose
```

## Components

### Fleet operations

- [Fleet records](https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/engins/page.tsx): `app/[locale]/(main)/engins/page.tsx`
- [Failure records](https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/pannes/page.tsx): `app/[locale]/(main)/pannes/page.tsx`
- [Backlog records](https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/backlogs/page.tsx): `app/[locale]/(main)/backlogs/page.tsx`
- [HIM entries](https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/saisie-him/page.tsx): `app/[locale]/(main)/saisie-him/page.tsx`
- [HRM entries](https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/saisie-hrm/page.tsx): `app/[locale]/(main)/saisie-hrm/page.tsx`
- [Fleet services](https://github.com/ghalass/multi_tenant/tree/main/server): `server`
- [Backlog service](https://github.com/ghalass/multi_tenant/blob/main/server/backlogs.ts): `server/backlogs.ts`
- [HIM service](https://github.com/ghalass/multi_tenant/blob/main/server/saisie_him.ts): `server/saisie_him.ts`

### Maintenance workflows

- [Preventive maintenance](https://github.com/ghalass/multi_tenant/tree/main/app/%5Blocale%5D/(main)/maintenance-preventive): `app/[locale]/(main)/maintenance-preventive`
- [Lubricant tracking](https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/saisie-lubrifiants/page.tsx): `app/[locale]/(main)/saisie-lubrifiants/page.tsx`

### Reporting and imports

- [Reports and statistics](https://github.com/ghalass/multi_tenant/tree/main/app/%5Blocale%5D/(main)/rapports): `app/[locale]/(main)/rapports`
- [HIM statistics](https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/saisie_hrm_stats/page.tsx): `app/[locale]/(main)/saisie_hrm_stats/page.tsx`
- [Spreadsheet import](https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/import/page.tsx): `app/[locale]/(main)/import/page.tsx`
- [Import endpoint](https://github.com/ghalass/multi_tenant/blob/main/app/api/import/route.ts): `app/api/import/route.ts`
- [Import dispatcher](https://github.com/ghalass/multi_tenant/blob/main/services/importService.ts): `services/importService.ts`
- [Batch import endpoint](https://github.com/ghalass/multi_tenant/blob/main/app/api/independent-batch-import/route.ts): `app/api/independent-batch-import/route.ts`
- [Batch import engine](https://github.com/ghalass/multi_tenant/blob/main/services/independentBatchImportService.ts): `services/independentBatchImportService.ts`

### Identity and administration

- [Authentication](https://github.com/ghalass/multi_tenant/blob/main/lib/auth.ts): `lib/auth.ts`
- [Access control](https://github.com/ghalass/multi_tenant/blob/main/lib/rbac/middleware.ts): `lib/rbac/middleware.ts`
- [Database backups](https://github.com/ghalass/multi_tenant/blob/main/app/%5Blocale%5D/(main)/database-backups/database-backups-client.tsx): `app/[locale]/(main)/database-backups/database-backups-client.tsx`
- [Backup actions](https://github.com/ghalass/multi_tenant/blob/main/server/database-backup-actions.ts): `server/database-backup-actions.ts`
- [Backup service](https://github.com/ghalass/multi_tenant/blob/main/services/database-backup.ts): `services/database-backup.ts`

### Other components

- **User**

## Connections

- User → Authentication: signs in
- Failure records → Fleet services: loads records (evidence: `app/[locale]/(main)/pannes/page.tsx`)
- Backlog records → Backlog service: loads records (evidence: `app/[locale]/(main)/backlogs/page.tsx`)
- HIM entries → HIM service: loads records (evidence: `app/[locale]/(main)/saisie-him/page.tsx`)
- HIM statistics → HIM service: loads statistics (evidence: `app/[locale]/(main)/saisie_hrm_stats/page.tsx`)
- Spreadsheet import → Import endpoint: uploads data
- Import endpoint → Import dispatcher: dispatches import (evidence: `app/api/import/route.ts`)
- Import dispatcher → Fleet services: imports records (evidence: `services/importService.ts`)
- Batch import endpoint → Batch import engine: runs batches (evidence: `app/api/independent-batch-import/route.ts`)
- Batch import endpoint → Access control: checks permission (evidence: `app/api/independent-batch-import/route.ts`)
- Database backups → Backup actions: requests backup actions (evidence: `app/[locale]/(main)/database-backups/database-backups-client.tsx`)
- Backup actions → Backup service: manages archives (evidence: `server/database-backup-actions.ts`)
