# oucmaroua-max/sonatrch-maintenance architecture

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

- Interactive diagram: https://gitdiagram.com/oucmaroua-max/sonatrch-maintenance
- Repository: https://github.com/oucmaroua-max/sonatrch-maintenance

## Overview

Sonatrach Maintenance is a maintenance-work-order management application. Users authenticate, create and assign work within their organizational scope, track progress, and submit completed work for supervisory feedback; administrators manage users, organization structure, and interim assignments. The React SPA calls an Express REST API backed by PostgreSQL/Drizzle. The README documents the overall client/API/database boundary and major features; source excerpts confirm route dispatch, work-scope handling, notification calls, and schema setup. Some frontend-to-API and controller-to-storage details are not shown, so those links are omitted.

Main entry points: [`Backend/src/app.ts`](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/app.ts) (Express API), [`Sonatrach-bolt-main/src/App.tsx`](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Sonatrach-bolt-main/src/App.tsx) (Page routing), [`Backend/src/controllers/work.controller.ts`](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/controllers/work.controller.ts) (Work-order handling), [`Backend/src/db/client.ts`](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/db/client.ts) (Drizzle database client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_react["React SPA<br/>[main.tsx]"]
  node_routing["Page routing<br/>[App.tsx]"]
  node_workpages["Work-order screens<br/>[WorkOrdersPage.tsx]"]
  node_dashboard["Dashboard<br/>[DashboardPage.tsx]"]
  node_profile["Personal profile<br/>[ProfilePage.tsx]"]
  node_adminpages["Admin screens<br/>[AdminUsersPage.tsx]"]
end

subgraph group_api["Backend API"]
  node_express["Express API<br/>[app.ts]"]
  node_auth["Authentication<br/>[auth.controller.ts]"]
end

subgraph group_domain["Work and delegation"]
  node_work["Work-order handling<br/>[work.controller.ts]"]
  node_interim["Interim handling"]
  node_notifications["Notifications"]
end

subgraph group_admin["Administration"]
  node_users["User administration<br/>[user.controller.ts]"]
  node_orgadmin["Organization management<br/>[org.controller.ts]"]
end

subgraph group_persistence["Persistence and scope"]
  node_scope["Organizational scope<br/>[orgScope.ts]"]
  node_effective["Interim effective scope<br/>[effectiveScope.ts]"]
  node_dbclient["Drizzle database client<br/>[client.ts]"]
  node_schema["Domain schema<br/>[schema.ts]"]
end

node_user(("Maintenance user"))
node_postgres[("PostgreSQL")]

node_user -->|"uses"| node_react
node_react -->|"renders"| node_routing
node_routing -->|"routes"| node_workpages
node_routing -->|"routes"| node_dashboard
node_routing -->|"routes"| node_profile
node_routing -->|"routes"| node_adminpages
node_react -->|"calls REST API"| node_express
node_express -->|"routes authentication"| node_auth
node_express -->|"routes work orders"| node_work
node_express -->|"routes interim requests"| node_interim
node_express -->|"routes notifications"| node_notifications
node_express -->|"routes user management"| node_users
node_express -->|"routes organization"| node_orgadmin
node_work -->|"checks visibility"| node_scope
node_work -->|"resolves acting scope"| node_effective
node_interim -->|"resolves acting scope"| node_effective
node_work -->|"sends assignment updates"| node_notifications
node_interim -->|"sends interim updates"| node_notifications
node_users -->|"sends admin alerts"| node_notifications
node_dbclient -->|"configures Drizzle"| node_schema
node_work -->|"queries work data"| node_dbclient
node_scope -->|"queries organization"| node_dbclient
node_effective -->|"reads interim scope"| node_dbclient
node_dbclient -->|"persists data"| node_postgres

click node_react "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Sonatrach-bolt-main/src/main.tsx"
click node_routing "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Sonatrach-bolt-main/src/App.tsx"
click node_workpages "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Sonatrach-bolt-main/src/pages/WorkOrdersPage.tsx"
click node_dashboard "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Sonatrach-bolt-main/src/pages/DashboardPage.tsx"
click node_profile "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Sonatrach-bolt-main/src/pages/ProfilePage.tsx"
click node_adminpages "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Sonatrach-bolt-main/src/pages/admin/AdminUsersPage.tsx"
click node_express "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/app.ts"
click node_auth "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/controllers/auth.controller.ts"
click node_work "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/controllers/work.controller.ts"
click node_interim "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/controllers/interim.controller.ts"
click node_notifications "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/controllers/notification.controller.ts"
click node_users "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/controllers/user.controller.ts"
click node_orgadmin "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/controllers/org.controller.ts"
click node_scope "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/utils/orgScope.ts"
click node_effective "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/utils/effectiveScope.ts"
click node_dbclient "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/db/client.ts"
click node_schema "https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/db/schema.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_react,node_routing,node_workpages,node_dashboard,node_profile,node_adminpages,node_user toneBlue
class node_express,node_auth,node_postgres toneAmber
class node_work,node_interim,node_notifications toneMint
class node_users,node_orgadmin toneRose
class node_scope,node_effective,node_dbclient,node_schema toneIndigo
```

## Components

### Web application

- [React SPA](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Sonatrach-bolt-main/src/main.tsx): `Sonatrach-bolt-main/src/main.tsx`
- [Page routing](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Sonatrach-bolt-main/src/App.tsx): `Sonatrach-bolt-main/src/App.tsx`
- [Work-order screens](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Sonatrach-bolt-main/src/pages/WorkOrdersPage.tsx): `Sonatrach-bolt-main/src/pages/WorkOrdersPage.tsx`
- [Dashboard](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Sonatrach-bolt-main/src/pages/DashboardPage.tsx): `Sonatrach-bolt-main/src/pages/DashboardPage.tsx`
- [Personal profile](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Sonatrach-bolt-main/src/pages/ProfilePage.tsx): `Sonatrach-bolt-main/src/pages/ProfilePage.tsx`
- [Admin screens](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Sonatrach-bolt-main/src/pages/admin/AdminUsersPage.tsx): `Sonatrach-bolt-main/src/pages/admin/AdminUsersPage.tsx`

### Backend API

- [Express API](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/app.ts): `Backend/src/app.ts`
- [Authentication](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/controllers/auth.controller.ts): `Backend/src/controllers/auth.controller.ts`

### Work and delegation

- [Work-order handling](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/controllers/work.controller.ts): `Backend/src/controllers/work.controller.ts`
- [Interim handling](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/controllers/interim.controller.ts): `Backend/src/controllers/interim.controller.ts`
- [Notifications](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/controllers/notification.controller.ts): `Backend/src/controllers/notification.controller.ts`

### Administration

- [User administration](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/controllers/user.controller.ts): `Backend/src/controllers/user.controller.ts`
- [Organization management](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/controllers/org.controller.ts): `Backend/src/controllers/org.controller.ts`

### Persistence and scope

- [Organizational scope](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/utils/orgScope.ts): `Backend/src/utils/orgScope.ts`
- [Interim effective scope](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/utils/effectiveScope.ts): `Backend/src/utils/effectiveScope.ts`
- [Drizzle database client](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/db/client.ts): `Backend/src/db/client.ts`
- [Domain schema](https://github.com/oucmaroua-max/sonatrch-maintenance/blob/main/Backend/src/db/schema.ts): `Backend/src/db/schema.ts`

### Other components

- **Maintenance user**
- **PostgreSQL**

## Connections

- Maintenance user → React SPA: uses
- React SPA → Page routing: renders (evidence: `Sonatrach-bolt-main/src/main.tsx`)
- Page routing → Work-order screens: routes (evidence: `Sonatrach-bolt-main/src/App.tsx`)
- Page routing → Dashboard: routes (evidence: `Sonatrach-bolt-main/src/App.tsx`)
- Page routing → Personal profile: routes (evidence: `Sonatrach-bolt-main/src/App.tsx`)
- Page routing → Admin screens: routes (evidence: `Sonatrach-bolt-main/src/App.tsx`)
- React SPA → Express API: calls REST API
- Express API → Authentication: routes authentication (evidence: `Backend/src/app.ts`)
- Express API → Work-order handling: routes work orders (evidence: `Backend/src/app.ts`)
- Express API → Interim handling: routes interim requests (evidence: `Backend/src/app.ts`)
- Express API → Notifications: routes notifications (evidence: `Backend/src/app.ts`)
- Express API → User administration: routes user management (evidence: `Backend/src/app.ts`)
- Express API → Organization management: routes organization (evidence: `Backend/src/app.ts`)
- Work-order handling → Organizational scope: checks visibility (evidence: `Backend/src/controllers/work.controller.ts`)
- Work-order handling → Interim effective scope: resolves acting scope (evidence: `Backend/src/controllers/work.controller.ts`)
- Interim handling → Interim effective scope: resolves acting scope (evidence: `Backend/src/controllers/interim.controller.ts`)
- Work-order handling → Notifications: sends assignment updates (evidence: `Backend/src/controllers/work.controller.ts`)
- Interim handling → Notifications: sends interim updates (evidence: `Backend/src/controllers/interim.controller.ts`)
- User administration → Notifications: sends admin alerts (evidence: `Backend/src/controllers/user.controller.ts`)
- Drizzle database client → Domain schema: configures Drizzle (evidence: `Backend/src/db/client.ts`)
- Work-order handling → Drizzle database client: queries work data (evidence: `Backend/src/controllers/work.controller.ts`)
- Organizational scope → Drizzle database client: queries organization (evidence: `Backend/src/utils/orgScope.ts`)
- Interim effective scope → Drizzle database client: reads interim scope (evidence: `Backend/src/utils/effectiveScope.ts`)
- Drizzle database client → PostgreSQL: persists data
