# usmahapatra/speedalert-assignment architecture

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

- Interactive diagram: https://gitdiagram.com/usmahapatra/speedalert-assignment
- Repository: https://github.com/usmahapatra/speedalert-assignment

## Overview

##### Project type and purpose
- This is an Android “headless” Kotlin application (no UI) that simulates over-speed detection and alerting for a rental car system.
- It runs as a simple console-style Android app: invoke `main()` in Main.kt, feed speed into the system, detect violations, and issue mocked Firebase notifications.

##### File structure
- Top-level module `app/` is a standard Android Studio Gradle module (with `build.gradle.kts`, `AndroidManifest.xml`, `src/main/java`, `src/main/res`, plus test folders).
- No `frontend`/`backend` split—this is a single APK with all logic in Kotlin classes under `com.example.speedalertassign`.
- Key classes under `app/src/main/java/com/example/speedalertassign`:
- Customer, Vehicle, RentalSession (entities)
- SpeedMonitor (service that observes speed changes)
- SpeedViolationListener (observer interface/implementation)
- FirebaseNotifier (infrastructure adapter, mocked notification)
- Main (entry-point orchestrator)
- Config files under `res/xml` (backup/data-extraction rules) are present but not used in logic—they represent Android resource inputs.

##### README for additional insights
- Confirms Kotlin + Android Studio, no UI, Firebase integration is mocked via `println()`.
- Usage: run `main()` and feed values into `onSpeedChanged()`.

##### Elements
- Blue for Domain entities
- Green for Service/logic
- Orange for Infra adapters
- Data flows (speed data in; alert out).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Environment
    subgraph "Android Runtime (ART/Dalvik)" 
        direction TB
        subgraph "AAOS Speed Monitor App"
            direction TB

            %% Domain Layer
            subgraph "Domain Layer" 
                direction TB
                Customer["Customer\n(Entity)"]:::domain
                Vehicle["Vehicle\n(Entity)"]:::domain
                RentalSession["RentalSession\n(Entity)"]:::domain
            end

            %% Service Layer
            subgraph "Service Layer" 
                direction TB
                Main["Main\n(Entry Point)"]:::service
                SpeedMonitor["SpeedMonitor\n(Subject)\nchecks speed vs. threshold"]:::service
                SpeedViolationListener["SpeedViolationListener\n(Observer)\nhandles violations"]:::service
            end

            %% Infrastructure Layer
            subgraph "Infrastructure Layer" 
                direction TB
                FirebaseNotifier["FirebaseNotifier\n(mock adapter)"]:::infra
                ResourceSubsystem["Resource Subsystem\n(config XMLs)"]:::infra
            end

            %% Interactions
            Main -->|"init Session & Monitor"| RentalSession
            Main -->|"init Session & Monitor"| SpeedMonitor
            SpeedMonitor -->|"registerListener()"| SpeedViolationListener
            SpeedMonitor -->|"onSpeedChanged(speed)"| SpeedViolationListener
            SpeedViolationListener -->|"sendAlert()"| FirebaseNotifier
        end
    end

    %% Simulator feeding speeds
    SpeedSimulator["Speed Data Simulator"]:::external
    SpeedSimulator -->|"feedSpeed()"| Main

    %% Click Events
    click ApplicationModule "https://github.com/usmahapatra/speedalert-assignment/tree/main/app/"
    click AndroidManifest "https://github.com/usmahapatra/speedalert-assignment/blob/main/app/src/main/AndroidManifest.xml"
    click Main "https://github.com/usmahapatra/speedalert-assignment/blob/main/app/src/main/java/com/example/speedalertassign/Main.kt"
    click Customer "https://github.com/usmahapatra/speedalert-assignment/blob/main/app/src/main/java/com/example/speedalertassign/Customer.kt"
    click Vehicle "https://github.com/usmahapatra/speedalert-assignment/blob/main/app/src/main/java/com/example/speedalertassign/Vehicle.kt"
    click RentalSession "https://github.com/usmahapatra/speedalert-assignment/blob/main/app/src/main/java/com/example/speedalertassign/RentalSession.kt"
    click SpeedMonitor "https://github.com/usmahapatra/speedalert-assignment/blob/main/app/src/main/java/com/example/speedalertassign/SpeedMonitor.kt"
    click SpeedViolationListener "https://github.com/usmahapatra/speedalert-assignment/blob/main/app/src/main/java/com/example/speedalertassign/SpeedViolationListener.kt"
    click FirebaseNotifier "https://github.com/usmahapatra/speedalert-assignment/blob/main/app/src/main/java/com/example/speedalertassign/FirebaseNotifier.kt"
    click ResourceSubsystem "https://github.com/usmahapatra/speedalert-assignment/tree/main/app/src/main/res/xml/"

    %% Styles
    classDef domain fill:#cce5ff,stroke:#1f497d,color:#1f497d;
    classDef service fill:#d4edda,stroke:#155724,color:#155724;
    classDef infra fill:#fff3cd,stroke:#856404,color:#856404;
    classDef external fill:#f8d7da,stroke:#721c24,color:#721c24;
```
