# manisha-athili/crime-safety-system architecture

> Architecture diagram of the GitHub repository manisha-athili/crime-safety-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manisha-athili/crime-safety-system
- Repository: https://github.com/manisha-athili/crime-safety-system

## Overview

##### Project type and purpose
- This is a client‑heavy, web‑based Crime and Reporting System.
- It uses static HTML/CSS/JS pages for the user interface and Firebase as a backend (hosting, authentication, database, possibly functions).
- Key user journeys: guest login/registration, submitting crime reports, viewing all reports with pagination & filters, viewing a map of incidents, sending feedback, and an officer dashboard for case management.

##### File structure
- Top‑level config:
- .firebaserc, firebase.json → Firebase hosting & services configurations
- package.json / node_modules → local dev tools or build scripts
- Frontend modules grouped in directories (each with its own HTML/CSS/JS):
- Authentication: loginIn/, signUp/
- Profile: profile/
- Crime reporting: crime-safety/reportForm/
- Reports listing: crime-safety/all_Reports/
- Officer view: officerDasboard/
- Feedback: feedback/
- Map/
- Shared UI: navbar/, pages/ (aboutUs, contactUs), index.html, script.js, style.css
- Data mocking: db.json (likely for json‑server in local dev)
- README indicates additional features: pagination, filters, sending confirmation emails, map UI, guest login, etc.

##### README for additional insights
- Two hard‑coded officer accounts for dashboard access
- Feature checklist: profile, pagination, guest login, mail notifications (signup complete), map UI, filters, feedback, report counts.

##### Main components & relationships
a. Frontend (hosted on Firebase Hosting)
- Authentication Module (loginIn/, signUp/) → Firebase Authentication
- User Profile Module (profile/)
- Crime Reporting Module (crime-safety/reportForm/) → writes to Firebase Database
- Reports Listing Module (crime-safety/all_Reports/) → reads from Firebase Database (with pagination & filters)
- Feedback Module (feedback/) → writes to Firebase Database
- Module (map/) → displays reports via Google Maps API + reads DB
- Officer Dashboard Module (officerDasboard/) → reads & updates cases in Firebase Database
- Shared UI Components (navbar/, pages/)
b. Backend (Firebase services)
- Firebase Hosting → serves the static site
- Firebase Authentication → user login/signup, officer login
- Firebase Realtime Database or Firestore → stores users, reports, feedback
- (Optional) Firebase Cloud Functions → send signup confirmation emails
c. External services
- Google Maps API → map visualization
- Email Service (via Cloud Functions or external SMTP)

##### Architectural patterns & design principles
- Modular Static Site Architecture: each feature lives in its own folder, clear separation of concerns
- BaaS model: Firebase handles hosting, auth, data storage, and serverless logic
- Client‑driven flows: front‑end code directly interacts with Firebase SDK
- Progressive enhancement: static pages enhanced with JS for dynamic behavior

##### Final checklist
- Distinct components for UI modules, backend services, and external services
- Real‑time or serverless interactions

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Global entities
    Browser["Browser"]:::external

    %% Backend services
    subgraph "Firebase Services"
        Hosting["Firebase Hosting"]:::backend
        Auth["Firebase Authentication"]:::backend
        Database["Firebase Database"]:::database
        Functions["Firebase Cloud Functions"]:::functions
    end

    %% External services
    subgraph "External APIs"
        Maps["Google Maps API"]:::external
        EmailSvc["Email Service"]:::external
    end

    %% Frontend modules
    subgraph "Frontend Static Site"
        subgraph "Authentication Module"
            Login["Login (loginIn)"]:::frontend
            SignUp["Sign Up (signUp)"]:::frontend
        end
        Profile["Profile Module"]:::frontend
        CrimeForm["Crime Report Form"]:::frontend
        ReportsList["Reports Listing"]:::frontend
        Feedback["Feedback Module"]:::frontend
        MapMod["Map Module"]:::frontend
        OfficerDash["Officer Dashboard"]:::frontend
        subgraph "Shared UI"
            Navbar["Navbar Component"]:::frontend
            Pages["Static Pages (aboutUs, contactUs)"]:::frontend
            Root["Root Entry (index.html)"]:::frontend
        end
    end

    %% Connections
    Browser -->|"HTTP GET HTML/CSS/JS"| Hosting
    Hosting -->|"Serves Static Site"| Browser

    Browser -->|"SDK: Auth"| Auth
    Browser -->|"SDK: Database"| Database
    Browser -->|"Calls Functions"| Functions
    Browser -->|"Requests Tiles & Data"| Maps
    Functions -->|"Sends Email"| EmailSvc

    Browser --> Login
    Browser --> SignUp
    Browser --> Profile
    Browser --> CrimeForm
    Browser --> ReportsList
    Browser --> Feedback
    Browser --> MapMod
    Browser --> OfficerDash
    Browser --> Navbar
    Browser --> Pages
    Browser --> Root

    %% Module interactions
    CrimeForm -->|"Save report"| Database
    ReportsList -->|"Fetch reports"| Database
    Feedback -->|"Submit feedback"| Database
    OfficerDash -->|"CRUD cases"| Database
    MapMod -->|"Load incident data"| Database

    %% Click Events
    click Login "https://github.com/manisha-athili/crime-safety-system/blob/main/loginIn/login.html"
    click SignUp "https://github.com/manisha-athili/crime-safety-system/blob/main/signUp/signUp.html"
    click Profile "https://github.com/manisha-athili/crime-safety-system/blob/main/profile/profile.html"
    click CrimeForm "https://github.com/manisha-athili/crime-safety-system/blob/main/crime-safety/reportForm/crime-report.html"
    click ReportsList "https://github.com/manisha-athili/crime-safety-system/blob/main/crime-safety/all_Reports/allReports.html"
    click Feedback "https://github.com/manisha-athili/crime-safety-system/blob/main/feedback/feedback.html"
    click MapMod "https://github.com/manisha-athili/crime-safety-system/blob/main/map/map.html"
    click OfficerDash "https://github.com/manisha-athili/crime-safety-system/blob/main/officerDasboard/officerDashboard.html"
    click Navbar "https://github.com/manisha-athili/crime-safety-system/blob/main/navbar/navbar.js"
    click Pages "https://github.com/manisha-athili/crime-safety-system/tree/main/pages/"
    click Root "https://github.com/manisha-athili/crime-safety-system/blob/main/index.html"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#1f78b4,color:#000
    classDef backend fill:#98FB98,stroke:#2E8B57,color:#000
    classDef database fill:#7FFFD4,stroke:#20B2AA,color:#000
    classDef functions fill:#FFEFD5,stroke:#FFA500,color:#000
    classDef external fill:#D3D3D3,stroke:#696969,color:#000
```
