# captthirumalai/vyomsena architecture

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

- Interactive diagram: https://gitdiagram.com/captthirumalai/vyomsena
- Repository: https://github.com/captthirumalai/vyomsena

## Overview

#### Purpose and Entry Points
This is a static, modular aviation operations application covering dashboard, crew, dispatch, flight operations, EFB, FDTL, maintenance, safety, training, weather, reporting, and settings. Browser startup is rooted at `index.html`, with application orchestration in `js/app.js`; Firebase initialization is separated in `firebase-config.js` and `js/firebase.js`.

#### Application Shell, Routing, and Module Lifecycle
The client shell appears to load feature modules dynamically through the router and shared module contract. `js/router.js` determines navigation, `shared/routes.js` defines route mappings, and `shared/BaseModule.js` provides a common module lifecycle. Each feature follows a deployable unit pattern: a `manifest.js`, HTML view, JavaScript controller, and CSS—for example `modules/dashboard/manifest.js`, `modules/dashboard/dashboard.html`, and `modules/dashboard/dashboard.js`.

#### UI Foundation and Cross-Cutting State
Reusable UI primitives are isolated from business modules: `components/Button/button.js`, `components/Modal/modal.js`, and `components/Notification/index.js`. Global layout, theme, loading, and notification behavior reside in `core/layout.js`, `core/theme.js`, `core/loader.js`, and `core/notifications.js`. Shared auth and theme state are represented by `stores/authStore.js` and `stores/themeStore.js`, while `services/eventBus.js` likely decouples cross-module events.

#### Authentication, Authorization, and Organization Boundary
Authentication and user/session handling are centered on `js/auth.js`, `services/authService.js`, and `stores/authStore.js`. Authorization is a distinct service layer via `services/permissionService.js`; organization/company context is handled through `services/organizationService.js` and `services/companyService.js`. This establishes a material tenant/security boundary before operational modules access data. Supporting design and policy references are in `docs/permissions.md` and `docs/firestorerules.md`.

#### Data, Documents, and Firebase Services
Firebase is the primary external platform, with service wrappers separating application code from Firestore and Storage: `services/firebaseService.js`, `services/firestoreService.js`, `services/storageService.js`, and `services/documentService.js`. Domain records are represented by model files such as `models/Flight.js`, `models/Aircraft.js`, and `models/UserDocument.js`. Crew-document synchronization and upload constraints are specialized concerns in `services/crewDocumentSyncService.js` and `services/uploadLimits.js`; Firebase access controls are documented in `docs/firestorerules.md` and `docs/storagerules.md`.

#### Operational Domain Modules
Feature modules own their page rendering and workflows. Crew management is the most decomposed domain, coordinated through `modules/crew/crew.js` and local state in `modules/crew/state.js`, with separate directory, profile, document, compliance, linking, bulk, and queue workflows. Flight-time/duty-limit processing is isolated as a service subsystem—`services/fdtl/index.js`, `services/fdtl/fdpEngine.js`, and `services/fdtl/fatigue.js`—and surfaced by `modules/fdtl/fdtl.js`. Other operational boundaries include dispatch (`modules/dispatch/dispatch.js`), flight operations (`modules/flightops/flightops.js`), and maintenance (`modules/maintenance/maintenance.js`).

#### Configuration and Documentation
Runtime/application settings are centralized in `config/app.config.js` and `js/config.js`. The repository includes architecture and data-contract documentation that should guide changes to the service and module boundaries: `docs/architecture.md`, `docs/database.md`, and `services/schemaContract.js`. A legacy standalone implementation remains under `backup_v1/app.js` and should not be treated as the current application path without verification.

Main entry points: [`js/router.js`](https://github.com/captthirumalai/vyomsena/blob/main/js/router.js) (Router), [`services/firestoreService.js`](https://github.com/captthirumalai/vyomsena/blob/main/services/firestoreService.js) (Firestore Service), [`js/app.js`](https://github.com/captthirumalai/vyomsena/blob/main/js/app.js) (App Orchestrator), [`modules/crew/crew.js`](https://github.com/captthirumalai/vyomsena/blob/main/modules/crew/crew.js) (Crew Module)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["Client Shell"]
  node_browser["Browser Entry<br/>HTML entry<br/>[index.html]"]
  node_app["App Orchestrator<br/>client bootstrap<br/>[app.js]"]
  node_router["Router<br/>navigation<br/>[router.js]"]
  node_routes["Route Registry<br/>route map<br/>[routes.js]"]
  node_base_module["Base Module<br/>module contract<br/>[BaseModule.js]"]
  node_ui_core["UI Core<br/>layout and feedback<br/>[layout.js]"]
  node_event_bus["Event Bus<br/>cross-module events<br/>[eventBus.js]"]
end

subgraph group_security["Identity &amp; Tenant"]
  node_auth["Authentication<br/>session service<br/>[authService.js]"]
  node_auth_store["Auth Store<br/>shared state<br/>[authStore.js]"]
  node_permissions["Authorization<br/>permission service"]
  node_organization["Organization Context<br/>tenant service"]
end

subgraph group_platform["Data Platform"]
  node_firebase_init["Firebase Init<br/>platform bootstrap<br/>[firebase-config.js]"]
  node_firebase_service["Firebase Gateway<br/>platform wrapper<br/>[firebaseService.js]"]
  node_firestore[("Firestore Service<br/>record persistence")]
  node_storage[("Storage Service<br/>file persistence<br/>[storageService.js]")]
  node_documents["Document Service<br/>document workflows<br/>[documentService.js]"]
end

subgraph group_operations["Operational Modules"]
  node_dashboard["Dashboard Module<br/>feature module<br/>[dashboard.js]"]
  node_crew["Crew Module<br/>feature module<br/>[crew.js]"]
  node_fdtl["FDTL Service<br/>duty-limit engine<br/>[index.js]"]
  node_fdtl_ui["FDTL Module<br/>feature module<br/>[fdtl.js]"]
  node_flightops["Flight Operations<br/>feature module<br/>[flightops.js]"]
  node_dispatch["Dispatch Module<br/>feature module<br/>[dispatch.js]"]
  node_maintenance["Maintenance Module<br/>feature module<br/>[maintenance.js]"]
end

node_browser -->|"starts"| node_app
node_app -->|"initializes"| node_firebase_init
node_app -->|"sets up"| node_router
node_app -->|"uses"| node_ui_core
node_router -->|"resolves"| node_routes
node_router -->|"loads modules by"| node_base_module
node_router -->|"navigates to"| node_dashboard
node_router -->|"navigates to"| node_crew
node_router -->|"navigates to"| node_fdtl_ui
node_router -->|"navigates to"| node_flightops
node_router -->|"navigates to"| node_dispatch
node_router -->|"navigates to"| node_maintenance
node_auth -->|"updates session"| node_auth_store
node_auth -->|"authenticates through"| node_firebase_service
node_permissions -->|"evaluates identity"| node_auth_store
node_organization -->|"scopes tenant"| node_auth_store
node_firebase_init -->|"configures"| node_firebase_service
node_firebase_service -->|"provides access"| node_firestore
node_firebase_service -->|"provides access"| node_storage
node_documents -->|"stores metadata"| node_firestore
node_documents -->|"stores files"| node_storage
node_crew -->|"manages crew documents"| node_documents
node_fdtl_ui -->|"uses calculations"| node_fdtl
node_crew -->|"reads and writes"| node_firestore
node_flightops -->|"reads and writes"| node_firestore
node_dispatch -->|"reads and writes"| node_firestore
node_maintenance -->|"reads and writes"| node_firestore
node_crew -.->|"publishes events"| node_event_bus
node_ui_core -.->|"shows feedback from"| node_event_bus

click node_browser "https://github.com/captthirumalai/vyomsena/blob/main/index.html"
click node_app "https://github.com/captthirumalai/vyomsena/blob/main/js/app.js"
click node_router "https://github.com/captthirumalai/vyomsena/blob/main/js/router.js"
click node_routes "https://github.com/captthirumalai/vyomsena/blob/main/shared/routes.js"
click node_base_module "https://github.com/captthirumalai/vyomsena/blob/main/shared/BaseModule.js"
click node_ui_core "https://github.com/captthirumalai/vyomsena/blob/main/core/layout.js"
click node_event_bus "https://github.com/captthirumalai/vyomsena/blob/main/services/eventBus.js"
click node_firebase_init "https://github.com/captthirumalai/vyomsena/blob/main/firebase-config.js"
click node_auth "https://github.com/captthirumalai/vyomsena/blob/main/services/authService.js"
click node_auth_store "https://github.com/captthirumalai/vyomsena/blob/main/stores/authStore.js"
click node_permissions "https://github.com/captthirumalai/vyomsena/blob/main/services/permissionService.js"
click node_organization "https://github.com/captthirumalai/vyomsena/blob/main/services/organizationService.js"
click node_firebase_service "https://github.com/captthirumalai/vyomsena/blob/main/services/firebaseService.js"
click node_firestore "https://github.com/captthirumalai/vyomsena/blob/main/services/firestoreService.js"
click node_storage "https://github.com/captthirumalai/vyomsena/blob/main/services/storageService.js"
click node_documents "https://github.com/captthirumalai/vyomsena/blob/main/services/documentService.js"
click node_dashboard "https://github.com/captthirumalai/vyomsena/blob/main/modules/dashboard/dashboard.js"
click node_crew "https://github.com/captthirumalai/vyomsena/blob/main/modules/crew/crew.js"
click node_fdtl "https://github.com/captthirumalai/vyomsena/blob/main/services/fdtl/index.js"
click node_fdtl_ui "https://github.com/captthirumalai/vyomsena/blob/main/modules/fdtl/fdtl.js"
click node_flightops "https://github.com/captthirumalai/vyomsena/blob/main/modules/flightops/flightops.js"
click node_dispatch "https://github.com/captthirumalai/vyomsena/blob/main/modules/dispatch/dispatch.js"
click node_maintenance "https://github.com/captthirumalai/vyomsena/blob/main/modules/maintenance/maintenance.js"

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_browser,node_app,node_router,node_routes,node_base_module,node_ui_core,node_event_bus toneBlue
class node_auth,node_auth_store,node_permissions,node_organization toneAmber
class node_firebase_init,node_firebase_service,node_firestore,node_storage,node_documents toneMint
class node_dashboard,node_crew,node_fdtl,node_fdtl_ui,node_flightops,node_dispatch,node_maintenance toneRose
```

## Components

### Client Shell

- [Browser Entry](https://github.com/captthirumalai/vyomsena/blob/main/index.html): HTML entry · `index.html`
- [App Orchestrator](https://github.com/captthirumalai/vyomsena/blob/main/js/app.js): client bootstrap · `js/app.js`
- [Router](https://github.com/captthirumalai/vyomsena/blob/main/js/router.js): navigation · `js/router.js`
- [Route Registry](https://github.com/captthirumalai/vyomsena/blob/main/shared/routes.js): route map · `shared/routes.js`
- [Base Module](https://github.com/captthirumalai/vyomsena/blob/main/shared/BaseModule.js): module contract · `shared/BaseModule.js`
- [UI Core](https://github.com/captthirumalai/vyomsena/blob/main/core/layout.js): layout and feedback · Layout, theme, loader, and notifications. · `core/layout.js`
- [Event Bus](https://github.com/captthirumalai/vyomsena/blob/main/services/eventBus.js): cross-module events · `services/eventBus.js`

### Identity & Tenant

- [Authentication](https://github.com/captthirumalai/vyomsena/blob/main/services/authService.js): session service · `services/authService.js`
- [Auth Store](https://github.com/captthirumalai/vyomsena/blob/main/stores/authStore.js): shared state · `stores/authStore.js`
- [Authorization](https://github.com/captthirumalai/vyomsena/blob/main/services/permissionService.js): permission service · `services/permissionService.js`
- [Organization Context](https://github.com/captthirumalai/vyomsena/blob/main/services/organizationService.js): tenant service · `services/organizationService.js`

### Data Platform

- [Firebase Init](https://github.com/captthirumalai/vyomsena/blob/main/firebase-config.js): platform bootstrap · `firebase-config.js`
- [Firebase Gateway](https://github.com/captthirumalai/vyomsena/blob/main/services/firebaseService.js): platform wrapper · `services/firebaseService.js`
- [Firestore Service](https://github.com/captthirumalai/vyomsena/blob/main/services/firestoreService.js): record persistence · `services/firestoreService.js`
- [Storage Service](https://github.com/captthirumalai/vyomsena/blob/main/services/storageService.js): file persistence · `services/storageService.js`
- [Document Service](https://github.com/captthirumalai/vyomsena/blob/main/services/documentService.js): document workflows · `services/documentService.js`

### Operational Modules

- [Dashboard Module](https://github.com/captthirumalai/vyomsena/blob/main/modules/dashboard/dashboard.js): feature module · `modules/dashboard/dashboard.js`
- [Crew Module](https://github.com/captthirumalai/vyomsena/blob/main/modules/crew/crew.js): feature module · Owns crew workflows and local state. · `modules/crew/crew.js`
- [FDTL Service](https://github.com/captthirumalai/vyomsena/blob/main/services/fdtl/index.js): duty-limit engine · Calculates FDP and fatigue constraints. · `services/fdtl/index.js`
- [FDTL Module](https://github.com/captthirumalai/vyomsena/blob/main/modules/fdtl/fdtl.js): feature module · `modules/fdtl/fdtl.js`
- [Flight Operations](https://github.com/captthirumalai/vyomsena/blob/main/modules/flightops/flightops.js): feature module · `modules/flightops/flightops.js`
- [Dispatch Module](https://github.com/captthirumalai/vyomsena/blob/main/modules/dispatch/dispatch.js): feature module · `modules/dispatch/dispatch.js`
- [Maintenance Module](https://github.com/captthirumalai/vyomsena/blob/main/modules/maintenance/maintenance.js): feature module · `modules/maintenance/maintenance.js`

## Connections

- Browser Entry → App Orchestrator: starts
- App Orchestrator → Firebase Init: initializes
- App Orchestrator → Router: sets up
- App Orchestrator → UI Core: uses
- Router → Route Registry: resolves
- Router → Base Module: loads modules by
- Router → Dashboard Module: navigates to
- Router → Crew Module: navigates to
- Router → FDTL Module: navigates to
- Router → Flight Operations: navigates to
- Router → Dispatch Module: navigates to
- Router → Maintenance Module: navigates to
- Authentication → Auth Store: updates session
- Authentication → Firebase Gateway: authenticates through
- Authorization → Auth Store: evaluates identity
- Organization Context → Auth Store: scopes tenant
- Firebase Init → Firebase Gateway: configures
- Firebase Gateway → Firestore Service: provides access
- Firebase Gateway → Storage Service: provides access
- Document Service → Firestore Service: stores metadata
- Document Service → Storage Service: stores files
- Crew Module → Document Service: manages crew documents
- FDTL Module → FDTL Service: uses calculations
- Crew Module → Firestore Service: reads and writes
- Flight Operations → Firestore Service: reads and writes
- Dispatch Module → Firestore Service: reads and writes
- Maintenance Module → Firestore Service: reads and writes
- Crew Module → Event Bus: publishes events
- UI Core → Event Bus: shows feedback from
