# alnasrstarsecurity-nss/nss-reporting architecture

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

- Interactive diagram: https://gitdiagram.com/alnasrstarsecurity-nss/nss-reporting
- Repository: https://github.com/alnasrstarsecurity-nss/nss-reporting

## Overview

##### What this project is (type + purpose)
From the file tree and README, this is a **static, client-side web application** for **NSS (Al Nasr Star Security) reporting**. It’s composed of multiple HTML pages, CSS stylesheets, and JavaScript files. There is **no backend/server code in this repo** (no `server/`, `api/`, `package.json`, etc.), so any persistence/authentication is either:
- purely client-side (e.g., localStorage), and/or

##### Data storage / API integration
- Search in `js/*.js` for: `fetch(`, `XMLHttpRequest`, `axios`, `firebase`, `firestore`, `database`, `supabase`, `appwrite`, URLs, API keys.
##### Authentication mechanism
- In `auth.js`, check whether it uses:
- Firebase Auth / OAuth providers
- A custom REST endpoint
- Hard-coded credentials
- localStorage/sessionStorage tokens
##### Shared state + navigation
- Does `menu.html` load the same scripts and rely on shared session state?
##### Entity model
- What objects exist? (Deviation, Violation, Patrolling report, Fire incident)
- What fields are captured and where they are saved/sent?

##### Relationships & interactions to highlight (data-flow centric)
For accuracy and usefulness, show **primary user journeys** as labeled flows:

##### Login / Session Establishment
- User enters credentials → `auth.js` → Auth Provider → token/session stored → redirect to `menu.html` or feature page

##### Create Deviation Report
- User opens `Deviation.html` → `deviation.js` loads → validates form → attaches metadata (user/time/location if present) → sends to Data Store/API → success UI state

##### Create Violation Report
- Same pattern via `Violation.html` + `violation.js`

##### Create Patrolling Report
- `Patrolling.html` + `patrolling.js` (may involve periodic logs/time entries—note if code shows timers/geolocation)

##### Fire/Incident
- If `fire.js` is invoked by one of the pages (or dynamically), show which page triggers it and its data sink

- “Authenticate”
- “Submit deviation report”
- “Store report record”
- “Read current user session”
- “Upload attachment” (if relevant)

##### Architectural patterns likely used (and how to represent them)
- **Multi-Page Application (MPA)**: multiple HTML entry points, each with its own JS module.
- **Feature-per-file JS modules**: each report type has a dedicated script.
- **Direct-to-service architecture** (potentially): the browser may talk directly to Auth/DB services.

- showing each page/module separately (instead of one “Frontend” blob)
- showing external services as first-class nodes (since they replace an internal backend)

##### Checklist to ensure “best and most accurate”
- [ ] External dependencies are named exactly (vendor + product)
- [ ] Data objects are named (Deviation/Violation/Patrol/Fire) and shown going to storage
- [ ] Auth boundary is clear: what requires login, where tokens live, how pages enforce it

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% =========================
    %% System Context (Level 1)
    %% =========================
    subgraph "System Context"
        direction TB

        Guard["Security Staff / Guard"]:::actor
        Admin["Supervisor / Admin (If roles exist)"]:::actor

        WebApp["NSS Reporting Web App (Static Site)"]:::system

        AuthProvider["External Authentication Provider (TBD from js/auth.js)"]:::external
        DataService["External Data Store / API Service (TBD from js/*.js)"]:::external
        FileStorage["External File/Photo Storage (Only if code confirms)"]:::external

        Guard -->|"Uses"| WebApp
        Admin -->|"Uses"| WebApp

        WebApp -->|"Authenticate(Login/Logout)"| AuthProvider
        WebApp -->|"Create/ReadReports"| DataService
        WebApp -.->|"UploadAttachments(If any)"| FileStorage
    end

    %% =========================
    %% Container View (Level 2)
    %% =========================
    subgraph "Container View"
        direction TB

        StaticHost["Static Web Host (GitHub Pages/IIS/S3/etc.)"]:::runtime
        Browser["Browser (Client Runtime)"]:::runtime

        StaticHost -->|"ServesHTML/CSS/JS"| Browser

        Browser -->|"DirectCalls(If implemented)"| AuthProvider
        Browser -->|"DirectCalls(If implemented)"| DataService
        Browser -.->|"DirectCalls(If implemented)"| FileStorage
    end

    %% =========================
    %% Component View (Level 3) - Browser App
    %% =========================
    subgraph "Browser App Components (Multi-Page Application)"
        direction TB

        subgraph "UI Pages (HTML)"
            direction TB
            Index["Entry / Landing Page"]:::ui
            Menu["Navigation / Menu Page"]:::ui
            DeviationPage["Deviation Reporting Page"]:::ui
            ViolationPage["Violation Reporting Page"]:::ui
            PatrollingPage["Patrolling Reporting Page"]:::ui
        end

        subgraph "Shared UI Styling (CSS)"
            direction TB
            Style1["Primary Stylesheet"]:::css
            Style2["Additional Stylesheet"]:::css
        end

        subgraph "Client Logic Modules (JavaScript)"
            direction TB
            AppJS["Shared App Bootstrap / Common Utilities"]:::js
            AuthJS["Authentication / Session Handling"]:::js

            subgraph "Feature Workflow Modules"
                direction TB
                DeviationJS["Deviation Workflow / UI Handlers"]:::js
                ViolationJS["Violation Workflow / UI Handlers"]:::js
                PatrollingJS["Patrolling Workflow / UI Handlers"]:::js
                FireJS["Fire / Incident Workflow"]:::js
            end
        end

        %% Page -> JS bindings
        Index -->|"Loads/Initializes"| AppJS
        Index -->|"Login/SessionChecks"| AuthJS

        Menu -->|"Loads/Initializes"| AppJS
        Menu -->|"ShowUser/Logout"| AuthJS

        DeviationPage -->|"Loads"| DeviationJS
        ViolationPage -->|"Loads"| ViolationJS
        PatrollingPage -->|"Loads"| PatrollingJS

        %% Shared dependencies
        DeviationJS -->|"UsesHelpers"| AppJS
        ViolationJS -->|"UsesHelpers"| AppJS
        PatrollingJS -->|"UsesHelpers"| AppJS
        FireJS -->|"UsesHelpers"| AppJS

        DeviationJS -->|"ReadsCurrentUser/RequiresLogin"| AuthJS
        ViolationJS -->|"ReadsCurrentUser/RequiresLogin"| AuthJS
        PatrollingJS -->|"ReadsCurrentUser/RequiresLogin"| AuthJS
        FireJS -->|"ReadsCurrentUser/RequiresLogin"| AuthJS

        %% Styling usage
        Index -->|"StyledBy"| Style1
        Menu -->|"StyledBy"| Style1
        DeviationPage -->|"StyledBy"| Style1
        ViolationPage -->|"StyledBy"| Style1
        PatrollingPage -->|"StyledBy"| Style1

        Index -.->|"StyledBy"| Style2
        Menu -.->|"StyledBy"| Style2
        DeviationPage -.->|"StyledBy"| Style2
        ViolationPage -.->|"StyledBy"| Style2
        PatrollingPage -.->|"StyledBy"| Style2

        %% Data flows to external dependencies (must be verified in code)
        AuthJS -->|"AuthenticateTokens/Sessions(TBD)"| AuthProvider
        DeviationJS -->|"SubmitDeviationReport(TBD)"| DataService
        ViolationJS -->|"SubmitViolationReport(TBD)"| DataService
        PatrollingJS -->|"SubmitPatrollingReport(TBD)"| DataService
        FireJS -.->|"SubmitFireIncident(TBD)"| DataService
        FireJS -.->|"UploadAttachments(If any)"| FileStorage
    end

    %% Link System node to container/app components
    WebApp -->|"ImplementedAs"| StaticHost
    WebApp -->|"RunsIn"| Browser
    Browser -->|"Renders"| Index

    %% =========================
    %% Click Events (from component_mapping)
    %% =========================
    click WebApp "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/index.html"
    click Index "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/index.html"
    click Menu "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/menu.html"
    click DeviationPage "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/Deviation.html"
    click ViolationPage "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/Violation.html"
    click PatrollingPage "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/Patrolling.html"

    click AppJS "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/js/app.js"
    click AuthJS "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/js/auth.js"
    click DeviationJS "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/js/deviation.js"
    click ViolationJS "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/js/violation.js"
    click PatrollingJS "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/js/patrolling.js"
    click FireJS "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/js/fire.js"

    click Style1 "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/css/style.css"
    click Style2 "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/css/style2.css"

    click StaticHost "https://github.com/alnasrstarsecurity-nss/nss-reporting/blob/main/README.md"

    %% =========================
    %% Styles
    %% =========================
    classDef actor fill:#F3F4F6,stroke:#6B7280,color:#111827,stroke-width:1px
    classDef system fill:#DBEAFE,stroke:#1D4ED8,color:#0B1F44,stroke-width:2px
    classDef runtime fill:#E5E7EB,stroke:#374151,color:#111827,stroke-width:1px
    classDef ui fill:#BFDBFE,stroke:#1D4ED8,color:#0B1F44,stroke-width:1px
    classDef js fill:#BBF7D0,stroke:#16A34A,color:#052E16,stroke-width:1px
    classDef css fill:#C7D2FE,stroke:#4338CA,color:#1E1B4B,stroke-width:1px
    classDef external fill:#FED7AA,stroke:#C2410C,color:#431407,stroke-width:1px
```
