# islammagdi/rangerforcessystem architecture

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

- Interactive diagram: https://gitdiagram.com/islammagdi/rangerforcessystem
- Repository: https://github.com/islammagdi/rangerforcessystem

## Overview

Ranger Forces System is a browser-based personnel administration application. Users enter through login and a routed dashboard, then work across personnel intake and review, individual records, unit reporting, letters, mail archives, and other administrative areas. The source index confirms Supabase-backed authentication and data access, permission checks, audit logging, and unsaved-change/draft support. Several major pages are represented from the file tree and index rather than inspected source; links to those areas are limited to documented routes.

Main entry points: [`src/app/routes.tsx`](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/routes.tsx) (Page routing), [`src/lib/supabase.ts`](https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/supabase.ts) (Supabase client), [`src/app/pages/IndividualQueryPage.tsx`](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/IndividualQueryPage.tsx) (Personnel query), [`src/app/pages/IssueLetterPage.tsx`](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/IssueLetterPage.tsx) (Letter workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_app["Application shell<br/>[App.tsx]"]
  node_routing["Page routing<br/>[routes.tsx]"]
  node_login["Login<br/>[LoginPage.tsx]"]
  node_dashboard["Dashboard<br/>[DashboardHome.tsx]"]
end

subgraph group_personnel["Personnel management"]
  node_intake["Personnel intake"]
  node_groupreview["Group review"]
  node_individual["Personnel query"]
  node_soldierdetail["Personnel details"]
  node_soldieredit["Edit personnel"]
  node_dailyreports["Daily reports"]
  node_unitdetail["Unit details<br/>[UnitDetailPage.tsx]"]
  node_reserve["Reserve batches"]
end

subgraph group_correspondence["Correspondence"]
  node_letters["Letter workflow"]
  node_letterengine["Letter rules"]
  node_mailarchive["Mail archive<br/>[mailArchive.ts]"]
end

subgraph group_platform["Shared services"]
  node_session["Session manager<br/>[SessionManager.tsx]"]
  node_permissions["Permissions<br/>[usePermissions.ts]"]
  node_audit["Activity logging<br/>[logActivity.ts]"]
  node_drafts["Draft protection<br/>[unsavedChanges.tsx]"]
  node_letterdraft["Letter drafts<br/>[letterDraft.ts]"]
  node_supabase[("Supabase client<br/>[supabase.ts]")]
end

node_user(("Staff user"))

node_user -->|"uses"| node_app
node_app -->|"provides routes"| node_routing
node_routing -->|"routes to"| node_login
node_routing -->|"routes to"| node_dashboard
node_routing -->|"routes to"| node_intake
node_routing -->|"routes to"| node_groupreview
node_routing -->|"routes to"| node_individual
node_routing -->|"routes to"| node_soldierdetail
node_routing -->|"routes to"| node_soldieredit
node_routing -->|"routes to"| node_dailyreports
node_routing -->|"routes to"| node_unitdetail
node_routing -->|"routes to"| node_reserve
node_routing -->|"routes to"| node_letters
node_session -->|"authenticates through"| node_supabase
node_individual -->|"checks access"| node_permissions
node_individual -->|"records actions"| node_audit
node_groupreview -->|"records actions"| node_audit
node_intake -->|"reads and writes"| node_supabase
node_drafts -->|"saves and resets"| node_letterdraft
node_permissions -->|"loads roles"| node_supabase
node_audit -->|"inserts audit records"| node_supabase
node_mailarchive -->|"reads and writes"| node_supabase
node_letters -.->|"uses rules"| node_letterengine
node_letterengine -.->|"checks eligibility"| node_supabase
node_mailarchive -.->|"supports correspondence"| node_letters

click node_app "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/App.tsx"
click node_routing "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/routes.tsx"
click node_login "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/LoginPage.tsx"
click node_dashboard "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/DashboardHome.tsx"
click node_intake "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/AddNewSoldierPage.tsx"
click node_groupreview "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/GroupReviewPage.tsx"
click node_individual "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/IndividualQueryPage.tsx"
click node_soldierdetail "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/SoldierDetailPage.tsx"
click node_soldieredit "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/SoldierEditPage.tsx"
click node_dailyreports "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/DailyReportsPage.tsx"
click node_unitdetail "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/UnitDetailPage.tsx"
click node_reserve "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/ReserveBatchesPage.tsx"
click node_letters "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/IssueLetterPage.tsx"
click node_letterengine "https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/letterTypeEngine.ts"
click node_mailarchive "https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/mailArchive.ts"
click node_session "https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/components/auth/SessionManager.tsx"
click node_permissions "https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/usePermissions.ts"
click node_audit "https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/logActivity.ts"
click node_drafts "https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/unsavedChanges.tsx"
click node_letterdraft "https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/letterDraft.ts"
click node_supabase "https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/supabase.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_app,node_routing,node_login,node_dashboard,node_user toneBlue
class node_intake,node_groupreview,node_individual,node_soldierdetail,node_soldieredit,node_dailyreports,node_unitdetail,node_reserve toneAmber
class node_letters,node_letterengine,node_mailarchive toneMint
class node_session,node_permissions,node_audit,node_drafts,node_letterdraft,node_supabase toneRose
```

## Components

### Application entry

- [Application shell](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/App.tsx): `src/app/App.tsx`
- [Page routing](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/routes.tsx): `src/app/routes.tsx`
- [Login](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/LoginPage.tsx): `src/app/pages/LoginPage.tsx`
- [Dashboard](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/DashboardHome.tsx): `src/app/pages/DashboardHome.tsx`

### Personnel management

- [Personnel intake](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/AddNewSoldierPage.tsx): `src/app/pages/AddNewSoldierPage.tsx`
- [Group review](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/GroupReviewPage.tsx): `src/app/pages/GroupReviewPage.tsx`
- [Personnel query](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/IndividualQueryPage.tsx): `src/app/pages/IndividualQueryPage.tsx`
- [Personnel details](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/SoldierDetailPage.tsx): `src/app/pages/SoldierDetailPage.tsx`
- [Edit personnel](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/SoldierEditPage.tsx): `src/app/pages/SoldierEditPage.tsx`
- [Daily reports](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/DailyReportsPage.tsx): `src/app/pages/DailyReportsPage.tsx`
- [Unit details](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/UnitDetailPage.tsx): `src/app/pages/UnitDetailPage.tsx`
- [Reserve batches](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/ReserveBatchesPage.tsx): `src/app/pages/ReserveBatchesPage.tsx`

### Correspondence

- [Letter workflow](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/pages/IssueLetterPage.tsx): `src/app/pages/IssueLetterPage.tsx`
- [Letter rules](https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/letterTypeEngine.ts): `src/lib/letterTypeEngine.ts`
- [Mail archive](https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/mailArchive.ts): `src/lib/mailArchive.ts`

### Shared services

- [Session manager](https://github.com/islammagdi/rangerforcessystem/blob/main/src/app/components/auth/SessionManager.tsx): `src/app/components/auth/SessionManager.tsx`
- [Permissions](https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/usePermissions.ts): `src/lib/usePermissions.ts`
- [Activity logging](https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/logActivity.ts): `src/lib/logActivity.ts`
- [Draft protection](https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/unsavedChanges.tsx): `src/lib/unsavedChanges.tsx`
- [Letter drafts](https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/letterDraft.ts): `src/lib/letterDraft.ts`
- [Supabase client](https://github.com/islammagdi/rangerforcessystem/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`

### Other components

- **Staff user**

## Connections

- Staff user → Application shell: uses
- Application shell → Page routing: provides routes (evidence: `src/app/App.tsx`)
- Page routing → Login: routes to (evidence: `src/app/routes.tsx`)
- Page routing → Dashboard: routes to (evidence: `src/app/routes.tsx`)
- Page routing → Personnel intake: routes to (evidence: `src/app/routes.tsx`)
- Page routing → Group review: routes to (evidence: `src/app/routes.tsx`)
- Page routing → Personnel query: routes to (evidence: `src/app/routes.tsx`)
- Page routing → Personnel details: routes to (evidence: `src/app/routes.tsx`)
- Page routing → Edit personnel: routes to (evidence: `src/app/routes.tsx`)
- Page routing → Daily reports: routes to (evidence: `src/app/routes.tsx`)
- Page routing → Unit details: routes to (evidence: `src/app/routes.tsx`)
- Page routing → Reserve batches: routes to (evidence: `src/app/routes.tsx`)
- Page routing → Letter workflow: routes to (evidence: `src/app/routes.tsx`)
- Session manager → Supabase client: authenticates through (evidence: `src/app/components/auth/SessionManager.tsx`)
- Personnel query → Permissions: checks access (evidence: `src/app/pages/IndividualQueryPage.tsx`)
- Personnel query → Activity logging: records actions (evidence: `src/app/pages/IndividualQueryPage.tsx`)
- Group review → Activity logging: records actions (evidence: `src/app/pages/GroupReviewPage.tsx`)
- Personnel intake → Supabase client: reads and writes (evidence: `src/app/pages/AddNewSoldierPage.tsx`)
- Draft protection → Letter drafts: saves and resets (evidence: `src/lib/unsavedChanges.tsx`)
- Permissions → Supabase client: loads roles (evidence: `src/lib/usePermissions.ts`)
- Activity logging → Supabase client: inserts audit records (evidence: `src/lib/logActivity.ts`)
- Mail archive → Supabase client: reads and writes (evidence: `src/lib/mailArchive.ts`)
- Letter workflow → Letter rules: uses rules
- Letter rules → Supabase client: checks eligibility
- Mail archive → Letter workflow: supports correspondence
