# adityajadli06/ambulancecall architecture

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

- Interactive diagram: https://gitdiagram.com/adityajadli06/ambulancecall
- Repository: https://github.com/adityajadli06/ambulancecall

## Overview

##### Project Type and Purpose
- Project Type: A full-stack web application with a clear separation between a frontend (HTML, CSS, JavaScript) and a backend cloud service (Firebase).
- Purpose: To allow users to authenticate (via Google, email/password, or phone OTP) and book ambulances based on location and budget. The system filters available ambulances and displays results on a dedicated page.

##### Break Down the File Structure
- User Interface Components: Multiple HTML pages are present:
- index.html – Landing page with navigation.
- booking.html – Booking form for capturing user location and budget.
- results.html – Page to display filtered ambulance results.
- Additional authentication pages: email-signin.html, email-signup.html, google-login.html.
- JavaScript Files:
- script.js – Manages booking logic, user inputs, and localStorage handling.
- auth.js – Manages authentication flow.
- firebaseConfig.js – Sets up Firebase connection (Authentication and possibly Database).
- Assets:
- The assets folder contains images or media used on the website–likely including backgrounds or ambulance images.
- Styles:
- styles.css holds the styling details for consistent UI presentation.

##### Architectural Components
a. Frontend:
- Web Pages: The various HTML files create the user interface and form the client-side rendering of the application.
- Client-side Scripts: script.js and auth.js implement the dynamic functionalities like input handling, UI transitions, and integration with Firebase.
- Styles: CSS that ties the visual element of the UI together.
b. Backend / Cloud Services:
- Firebase Authentication: Enables multiple sign-in methods (Google, email, phone OTP).
- Firebase Database (if applicable): Used to store or retrieve ambulance details matching the provided criteria.
c. Data Handling:
- Local Storage: Temporarily stores booking details until they are processed, then clears out.

##### Relationships and Interactions
- Users interact with the UI through the browser.
- Authentication pages (Google, email-signin, email-signup) communicate with Firebase Authentication via auth.js and firebaseConfig.js.
- Once logged in, users fill out booking forms (booking.html), which trigger logic in script.js to capture user inputs.
- The booking details are temporarily held in localStorage.
- The booking logic, possibly via Firebase Database, retrieves and filters ambulances based on budget as shown on results.html.
- The overall flow moves from authentication to booking information submission to results display.

##### Architectural Patterns or Design Principles
- Separation of Concerns: HTML for view, CSS for styling, and JavaScript for behavior.
- Client-Server Architecture: The client is a static web application that depends on Firebase (a backend-as-a-service) for authentication and data storage.
- Dynamic UI Management: Showing/hiding sections based on user interaction, with data flow controlled by events in the JavaScript files.

##### Final Advice for the Engineer
- Use annotations if necessary to detail the purpose of each interaction (e.g., “User logs in via auth.js which communicates with Firebase Authentication”).
- Aim for clarity so that the dynamic flow (from sign-in, booking input, and result filtering) is evident at a glance.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend (Browser)
    subgraph "Frontend (Browser)"
        index["Landing Page (index.html)"]
        booking["Booking Form (booking.html)"]
        results["Results Display (results.html)"]
        emailSignin["Email SignIn (email-signin.html)"]
        emailSignup["Email SignUp (email-signup.html)"]
        googleLogin["Google Login (google-login.html)"]
    end

    %% Client Scripts & Assets
    subgraph "Client Scripts & Assets"
        script["Booking Logic (script.js)"]
        auth["Authentication Module (auth.js)"]
        firebaseConfig["Firebase Config (firebaseConfig.js)"]
        css["CSS Styling (styles.css)"]
        assets["Media & Assets (assets/)"]
        localStorage["Local Storage"]
    end

    %% Backend / Cloud Services
    subgraph "Backend / Cloud Services"
        firebaseAuth["Firebase Authentication"]
        firebaseDB["Firebase Database"]
    end

    %% Project Documentation
    doc["Project Documentation (README.md)"]

    %% Connections between Frontend Pages
    index -->|"navigatesTo"| emailSignin
    index -->|"navigatesTo"| emailSignup
    index -->|"navigatesTo"| googleLogin
    index -->|"navigatesTo"| booking

    booking -->|"submitsForm"| script
    booking -->|"proceedsTo"| results

    %% Styling and Assets applied to UI
    index -->|"styledBy"| css
    booking -->|"styledBy"| css
    results -->|"styledBy"| css
    emailSignin -->|"styledBy"| css
    emailSignup -->|"styledBy"| css
    googleLogin -->|"styledBy"| css

    index -->|"uses"| assets
    booking -->|"uses"| assets
    results -->|"uses"| assets
    emailSignin -->|"uses"| assets
    emailSignup -->|"uses"| assets
    googleLogin -->|"uses"| assets

    %% Authentication Flow
    emailSignin -->|"triggersAuth"| auth
    emailSignup -->|"triggersAuth"| auth
    googleLogin -->|"triggersAuth"| auth
    auth -->|"utilizes"| firebaseConfig
    firebaseConfig -->|"configures"| firebaseAuth

    %% Booking Data Flow
    script -->|"storesDataIn"| localStorage
    script -->|"queries"| firebaseDB
    firebaseDB -->|"returnsResultsTo"| results

    %% Documentation connection (reference only)
    doc --- index

    %% Click Events for Component Mapping
    click index "https://github.com/adityajadli06/ambulancecall/blob/main/index.html"
    click booking "https://github.com/adityajadli06/ambulancecall/blob/main/booking.html"
    click results "https://github.com/adityajadli06/ambulancecall/blob/main/results.html"
    click emailSignin "https://github.com/adityajadli06/ambulancecall/blob/main/email-signin.html"
    click emailSignup "https://github.com/adityajadli06/ambulancecall/blob/main/email-signup.html"
    click googleLogin "https://github.com/adityajadli06/ambulancecall/blob/main/google-login.html"
    click script "https://github.com/adityajadli06/ambulancecall/blob/main/script.js"
    click auth "https://github.com/adityajadli06/ambulancecall/blob/main/auth.js"
    click firebaseConfig "https://github.com/adityajadli06/ambulancecall/blob/main/firebaseConfig.js"
    click css "https://github.com/adityajadli06/ambulancecall/blob/main/styles.css"
    click assets "https://github.com/adityajadli06/ambulancecall/tree/main/assets/"
    click doc "https://github.com/adityajadli06/ambulancecall/blob/main/README.md"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef script fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef backend fill:#ffe0b2,stroke:#e64a19,stroke-width:2px;
    classDef doc fill:#f8bbd0,stroke:#ad1457,stroke-width:2px;

    class index,booking,results,emailSignin,emailSignup,googleLogin frontend;
    class script,auth,firebaseConfig,css,assets,localStorage script;
    class firebaseAuth,firebaseDB backend;
    class doc doc;
```
