# ananyajackson11/clearsteer architecture

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

- Interactive diagram: https://gitdiagram.com/ananyajackson11/clearsteer
- Repository: https://github.com/ananyajackson11/clearsteer

## Overview

##### Project type and purpose
- ClearSteer is a cross-platform (mobile & web) Flutter application.
- Its core purpose is to capture camera input, perform on-device ML inference, provide text-to-speech feedback, and persist user data via Firebase.

##### File structure
- Top-level “android”, “ios”, “linux”, “macos”, “windows”, “web” folders: each hosts platform-specific Flutter embedding code.
- “lib/” contains Dart source files: UI pages (login, signup, drive, emergency, statistics, profile), plus detect.dart (ML wrapper).
- “assets/50epoch_float32.tflite” – the TFLite model.
- “pubspec.yaml” – Flutter dependencies (Firebase, tflite_flutter, flutter_tts, camera, image_picker).
- “test/” – widget tests.
- Platform folders include plugin registrants and runner code for desktop/embedded targets.

##### README
- Tech stack: Flutter UI, Firebase Auth & Firestore, TFLite, camera/TTS utilities, HTTP for external calls.
- Features: camera integration, real-time TTS, on-device ML, Firestore persistence, cross-platform.

##### Main components and interactions
a. Components
1. Flutter UI Layer (lib/*.dart pages)
2. Device Services
– Camera plugin
– Image Picker plugin
– flutter_tts plugin
3. ML Inference Engine
– TFLite runtime (tflite_flutter)
– Local model file (assets/50epoch_float32.tflite)
4. Backend Services (Firebase)
– Authentication (Firebase Auth)
– Data Storage (Cloud Firestore, optionally Storage)
5. Network Layer
– HTTP client (for optional REST calls)
b. Relationships & Data Flow
– UI captures camera frames → passes to ML Inference → outputs detection results.
– Detection results → fed to flutter_tts → audio feedback to user.
– User actions (login/signup) → Firebase Auth → returns user token.
– Authenticated UI → reads/writes user data to Firestore.
– Image uploads/read from Firestore Storage (if used).
– HTTP requests (if any) go out via Network Layer.
c. Architectural patterns & principles
– Layered architecture: Presentation (UI) → Services (Camera, TTS, HTTP, ML) → Backend (Firebase).
– Plugin-based modularity: each platform service is a Flutter plugin.
– Cross-platform runner host code isolates embedder details (Android/iOS/Linux/macOS/Windows).
d. Key technologies
– Flutter framework (Dart)
– TFLite Flutter plugin
– flutter_tts
– firebase_auth, cloud_firestore

##### Detailed capture of essential elements
- Platform boundaries: a container for Flutter host on Android/iOS/Desktop/Web.
- Model artifact as a runtime dependency.
- Real-time loop: camera frame → ML → TTS.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Platform Host Boundary
    subgraph "Platform Host"
        direction TB
        AndroidHost["Android: MainActivity.kt"]:::services
        iOSHost["iOS: AppDelegate.swift"]:::services
        LinuxHost["Linux: generated_plugin_registrant.cc"]:::services
        macOSHost["macOS: GeneratedPluginRegistrant.swift"]:::services
        WindowsHost["Windows: generated_plugin_registrant.cc"]:::services
    end

    %% Flutter UI Layer
    subgraph "Flutter UI Layer" 
        direction TB
        MainApp["main.dart (App Init)"]:::ui
        LoginPage["login_page.dart"]:::ui
        SignupPage["signup_page.dart"]:::ui
        OTPPage["otp_page.dart"]:::ui
        HomePage["home_page.dart"]:::ui
        DrivePage["drive_page.dart"]:::ui
        EmergencyPage["emergency_services_page.dart"]:::ui
        StatisticsPage["statistics_page.dart"]:::ui
        ProfilePage["profile_page.dart"]:::ui
        StatusPage["status_page.dart"]:::ui
    end

    %% Device Services
    subgraph "Device Services (Plugins)"
        direction TB
        Camera["camera plugin"]:::services
        ImagePicker["image_picker plugin"]:::services
        TTS["flutter_tts plugin"]:::services
    end

    %% ML Inference Engine
    subgraph "ML Inference Engine"
        direction TB
        TFLiteRuntime["TFLite Runtime"]:::ml
        ModelFile["50epoch_float32.tflite"]:::ml
        DetectWrapper["detect.dart (ML Wrapper)"]:::ml
    end

    %% Backend Services
    subgraph "Firebase Backend"
        direction TB
        Auth["Firebase Auth"]:::backend
        Firestore["Cloud Firestore"]:::backend
    end

    %% Network Layer
    subgraph "Network Layer"
        direction TB
        HTTPClient["HTTP Client"]:::network
    end

    %% Data Flows
    Camera -->|frames| DetectWrapper
    ImagePicker -->|images| DetectWrapper
    DetectWrapper -->|results| HomePage
    DetectWrapper -->|results| DrivePage
    HomePage -->|text| TTS
    DrivePage -->|alerts| TTS
    MainApp -->|init| Auth
    LoginPage -->|login/signup| Auth
    OTPPage -->|verify| Auth
    Auth -->|token| MainApp
    MainApp -->|reads/writes| Firestore
    ProfilePage -->|profile data| Firestore
    StatisticsPage -->|stats data| Firestore
    DrivePage -->|trip logs| Firestore
    StatusPage -->|status| Firestore
    MainApp -->|"optional calls"| HTTPClient
    HTTPClient -.->|"external APIs"| HomePage

    %% Platform to Flutter
    AndroidHost -->|hosts| MainApp
    iOSHost -->|hosts| MainApp
    LinuxHost -->|hosts| MainApp
    macOSHost -->|hosts| MainApp
    WindowsHost -->|hosts| MainApp

    %% Click Events
    click MainApp "https://github.com/ananyajackson11/clearsteer/blob/main/lib/main.dart"
    click LoginPage "https://github.com/ananyajackson11/clearsteer/blob/main/lib/login_page.dart"
    click SignupPage "https://github.com/ananyajackson11/clearsteer/blob/main/lib/signup_page.dart"
    click OTPPage "https://github.com/ananyajackson11/clearsteer/blob/main/lib/otp_page.dart"
    click HomePage "https://github.com/ananyajackson11/clearsteer/blob/main/lib/home_page.dart"
    click DrivePage "https://github.com/ananyajackson11/clearsteer/blob/main/lib/drive_page.dart"
    click EmergencyPage "https://github.com/ananyajackson11/clearsteer/blob/main/lib/emergency_services_page.dart"
    click StatisticsPage "https://github.com/ananyajackson11/clearsteer/blob/main/lib/statistics_page.dart"
    click ProfilePage "https://github.com/ananyajackson11/clearsteer/blob/main/lib/profile_page.dart"
    click StatusPage "https://github.com/ananyajackson11/clearsteer/blob/main/lib/status_page.dart"
    click DetectWrapper "https://github.com/ananyajackson11/clearsteer/blob/main/lib/detect.dart"
    click ModelFile "https://github.com/ananyajackson11/clearsteer/blob/main/assets/50epoch_float32.tflite"
    click AndroidHost "https://github.com/ananyajackson11/clearsteer/blob/main/android/app/src/main/kotlin/com/example/clearsteer/MainActivity.kt"
    click iOSHost "https://github.com/ananyajackson11/clearsteer/blob/main/ios/Runner/AppDelegate.swift"
    click LinuxHost "https://github.com/ananyajackson11/clearsteer/blob/main/linux/flutter/generated_plugin_registrant.cc"
    click macOSHost "https://github.com/ananyajackson11/clearsteer/blob/main/macos/Flutter/GeneratedPluginRegistrant.swift"
    click WindowsHost "https://github.com/ananyajackson11/clearsteer/blob/main/windows/flutter/generated_plugin_registrant.cc"
    click HTTPClient "https://github.com/ananyajackson11/clearsteer/blob/main/pubspec.yaml"
    click Camera "https://github.com/ananyajackson11/clearsteer/blob/main/pubspec.yaml"
    click ImagePicker "https://github.com/ananyajackson11/clearsteer/blob/main/pubspec.yaml"
    click TTS "https://github.com/ananyajackson11/clearsteer/blob/main/pubspec.yaml"

    %% Styles
    classDef ui fill:#D6EAF8,stroke:#1B4F72,color:#1B2631
    classDef services fill:#D5F5E3,stroke:#196F3D,color:#1B2631
    classDef ml fill:#FAD7A0,stroke:#B9770E,color:#1B2631
    classDef backend fill:#FCF3CF,stroke:#B7950B,color:#1B2631
    classDef network fill:#ECDCCC,stroke:#873600,color:#1B2631
```
