# yash-kumarsharma/elira architecture

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

- Interactive diagram: https://gitdiagram.com/yash-kumarsharma/elira
- Repository: https://github.com/yash-kumarsharma/elira

## Overview

##### Main Components
a. **User’s Browser**
- Loads static HTML/CSS/JS from a hosting server (e.g., GitHub Pages or any static-file host).
- Runs client-side logic: Tailwind CSS, Vanilla JS, Alpine.js.
- Manages demo-only auth in `localStorage`.
b. **Static-File Hosting**
- Serves all `.html` pages (index.html, budget.html, consult.html, etc.), CSS assets, images, audio.
c. **Flask Backend Service** (`app.py`)
- Provides the “Safe Routes Map” endpoint and any Python-powered features.
- Implements CORS for client calls.
d. **External Services**
- **OSRM API** for crime-aware route calculations.
- **Leaflet.js** library on the client for map rendering.
- **EmailJS** and **WhatsApp** link-based APIs for emergency alerts.

##### Relationships & Data Flows
- User’s Browser → (HTTP GET) → Static-File Hosting → `.html` + assets
- On `/safe_routes_map.html`: Browser JS → (XHR/Fetch) → Flask Backend → (OSRM API) → Flask returns JSON → Browser renders via Leaflet
- On `/emergency_location.html`: Browser geolocation → triggers EmailJS/WhatsApp links → external messaging services
- For all other pages: purely static client-side interactions; no backend calls (demo auth in localStorage)

##### Architectural Patterns & Design Principles
- **Separation of Concerns**: Static multi-page frontend vs. a single micro-service for dynamic mapping.
- **Micro-service Pattern**: Flask app isolated from static hosting, can be deployed separately.
- **Client-heavy UI**: Plain JS/Alpine.js for interactive components, reducing backend load.
- **Serverless-style**: Most pages need no server beyond static hosting.

##### Technologies & Frameworks to Call Out
- Frontend: HTML5, Tailwind CSS, Vanilla JS, Alpine.js
- Mapping: Leaflet.js + OSRM API
- Backend: Python, Flask, Flask-CORS
- Alerts: EmailJS, WhatsApp
- Auth (demo): Browser localStorage

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer" 
        direction TB
        Browser["User's Browser"]:::client
        LocalStorage[(Demo Auth: localStorage)]:::storage
    end

    %% Hosting Layer
    subgraph "Static File Hosting" 
        direction TB
        StaticServer["Static File Server"]:::hosting
        subgraph "Pages & Assets"
            direction TB
            Index["index.html"]  
            Budget["budget.html"]  
            Consult["consult.html"]  
            Courses["courses.html"]  
            EmergencyLoc["emergenc_location.html"]  
            Feedback["feedback_form.html"]  
            FinancialHome["financial_home.html"]  
            Insurance["insurance.html"]  
            Investment["investment.html"]  
            LearnMore["learn_more_financial.html"]  
            Legal["legal.html"]  
            Login["login.html"]  
            Shop["shop.html"]  
            SafeRoutes["safe_routes_map.html"]  
            Siren["police-siren-sound-effect-240674.mp3"]  
        end
        DevServer["Dev Static Server (Node.js)"]:::hosting
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        FlaskAPI["Flask API Service (app.py)"]:::backend
    end

    %% External Services Layer
    subgraph "External Services"
        direction TB
        OSRM["OSRM API"]:::external
        EmailJS["EmailJS"]:::external
        WhatsApp["WhatsApp API"]:::external
    end

    %% Connections
    Browser -->|GET HTML/CSS/JS| StaticServer
    StaticServer -->|serves pages & assets| Index
    StaticServer --> Budget
    StaticServer --> Consult
    StaticServer --> Courses
    StaticServer --> EmergencyLoc
    StaticServer --> Feedback
    StaticServer --> FinancialHome
    StaticServer --> Insurance
    StaticServer --> Investment
    StaticServer --> LearnMore
    StaticServer --> Legal
    StaticServer --> Login
    StaticServer --> Shop
    StaticServer --> SafeRoutes
    StaticServer --> Siren

    Browser -->|localStorage auth| LocalStorage

    Browser -->|Fetch /safe_routes_map| FlaskAPI
    FlaskAPI -->|calls OSRM| OSRM
    OSRM -->|returns JSON| FlaskAPI
    FlaskAPI -->|returns JSON| Browser

    Browser -->|trigger alert| EmailJS
    Browser -->|trigger alert| WhatsApp

    DevServer -->|serves static files| StaticServer

    %% Click Events
    click Index "https://github.com/yash-kumarsharma/elira/blob/main//index.html"
    click Budget "https://github.com/yash-kumarsharma/elira/blob/main//budget.html"
    click Consult "https://github.com/yash-kumarsharma/elira/blob/main//consult.html"
    click Courses "https://github.com/yash-kumarsharma/elira/blob/main//courses.html"
    click EmergencyLoc "https://github.com/yash-kumarsharma/elira/blob/main//emergenc_location.html"
    click Feedback "https://github.com/yash-kumarsharma/elira/blob/main//feedback_form.html"
    click FinancialHome "https://github.com/yash-kumarsharma/elira/blob/main//financial_home.html"
    click Insurance "https://github.com/yash-kumarsharma/elira/blob/main//insurance.html"
    click Investment "https://github.com/yash-kumarsharma/elira/blob/main//investment.html"
    click LearnMore "https://github.com/yash-kumarsharma/elira/blob/main//learn_more_financial.html"
    click Legal "https://github.com/yash-kumarsharma/elira/blob/main//legal.html"
    click Login "https://github.com/yash-kumarsharma/elira/blob/main//login.html"
    click Shop "https://github.com/yash-kumarsharma/elira/blob/main//shop.html"
    click SafeRoutes "https://github.com/yash-kumarsharma/elira/blob/main//safe_routes_map.html"
    click Siren "https://github.com/yash-kumarsharma/elira/blob/main//police-siren-sound-effect-240674.mp3"
    click FlaskAPI "https://github.com/yash-kumarsharma/elira/blob/main/app.py"
    click DevServer "https://github.com/yash-kumarsharma/elira/blob/main//New folder/server.js"

    %% Styles
    classDef client fill:#E0F7FA,stroke:#0288D1,stroke-width:2px
    classDef hosting fill:#E8F5E9,stroke:#388E3C,stroke-width:2px
    classDef backend fill:#FFF3E0,stroke:#F57C00,stroke-width:2px
    classDef external fill:#FFEBEE,stroke:#D32F2F,stroke-width:2px
    classDef storage fill:#BBDEFB,stroke:#1976D2,stroke-width:2px
```
