# vinay-daripelly/eco-craft architecture

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

- Interactive diagram: https://gitdiagram.com/vinay-daripelly/eco-craft
- Repository: https://github.com/vinay-daripelly/eco-craft

## Overview

##### Project type and purpose
- This is a mobile, Android-native, full-stack application (“Ecocraft”) written in Kotlin.
- Its purpose is to let users (individuals or organizations) upload images of plastic waste, identify the resin type using an on-device TensorFlow Lite model, generate upcycling suggestions via an external LLM API, and track/manage submissions via Firebase.

##### File structure
- Top-level build files (build.gradle, settings.gradle, gradle/…) configure an Android Gradle project.
- Single module “app/” contains:
- AndroidManifest.xml, resource folders (res/layout, drawables, values)
- src/main/java/com/example/ecocraftplastic: Activity classes (HomeActivity, LoginActivity, PlasticDetectionActivity, etc.), Constants.kt and SuggestionService.kt
- src/main/assets/model_unquant.tflite: on-device ML model
- src/main/res/xml/data_extraction_rules.xml, backup_rules.xml: Android backup/data extraction
- src/androidTest and src/test: instrumented and unit tests
- No separate “backend” code—backend responsibilities are offloaded to Firebase (Auth, Firestore, Storage).

##### README for additional insights
- ML model for plastic classification runs locally (TensorFlow Lite).
- LLM integration (e.g., Gemini Pro) is called via SuggestionService.kt.
- Firebase Auth handles user identity; Firestore stores submissions and dashboard data; Cloud Storage may store image files.
- MPAndroidChart (or equivalent) for charts in Organization mode.

##### Detailed component breakdown (
- Android Client container
- UI: HomeActivity, PlasticDetectionActivity, etc.
- ML Inference Engine (model_unquant.tflite)
- Networking: SuggestionService → LLM API
- Local Data Handler (if any caching, e.g., SharedPreferences via Constants.kt)
- Cloud container
- Firebase Auth
- Firestore (Collections: detections, suggestions, recycle_requests)
- Cloud Storage (bucket for images)
- LLM API endpoint
- Flows:
1. Auth token → Firestore
2. ML inference → local → SuggestionService call
3. Firestore read/write → UI updates
4. Admin actions → Firestore updates → UI notifications

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Android Client"
        subgraph "UI Layer"
            Login["LoginActivity"]:::androidClient
            Signup["SignupActivity"]:::androidClient
            Home["HomeActivity"]:::androidClient
            IndMode["IndividualModeActivity"]:::androidClient
            OrgMode["OrganizationModeActivity"]:::androidClient
            Detect["PlasticDetectionActivity"]:::androidClient
            Requests["RecycleRequestsActivity"]:::androidClient
            SuggestUI["SuggestionActivity"]:::androidClient
        end
        subgraph "ML Inference Engine"
            Model["model_unquant.tflite"]:::ml
        end
        SuggestService["SuggestionService"]:::androidClient
        Constants["Constants.kt"]:::androidClient
        Manifest["AndroidManifest.xml"]:::androidClient
        BackupRules["backup_rules.xml"]:::androidClient
        DataExtraction["data_extraction_rules.xml"]:::androidClient
    end

    subgraph "External Services"
        Auth["Firebase Auth"]:::cloud
        Firestore["Firebase Firestore"]:::cloud
        Storage["Firebase Cloud Storage"]:::cloud
        LLM["LLM API"]:::cloud
    end

    subgraph "Tests"
        InstrTest["ExampleInstrumentedTest.kt"]:::test
        UnitTest["ExampleUnitTest.kt"]:::test
    end

    %% Data Flows
    Login -->|"authenticate"| Auth -->|"token"| Home
    Home -->|"navigate to"| Detect
    Detect -->|"input image"| Model -->|"resin type & volume"| Detect
    Detect -->|"invoke inference"| SuggestService -->|"request suggestions"| LLM -->|"return suggestions"| SuggestService --> SuggestUI
    Detect -->|"write record"| Firestore
    Detect -->|"upload image"| Storage
    SuggestService -->|"save suggestion"| Firestore
    IndMode -->|"read summaries"| Firestore
    OrgMode -->|"read aggregated data"| Firestore -->|"chart data"| OrgMode
    Requests -->|"update requests"| Firestore

    %% Click Events
    click Login "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/java/com/example/ecocraftplastic/LoginActivity.kt"
    click Signup "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/java/com/example/ecocraftplastic/SignupActivity.kt"
    click Home "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/java/com/example/ecocraftplastic/HomeActivity.kt"
    click IndMode "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/java/com/example/ecocraftplastic/IndividualModeActivity.kt"
    click OrgMode "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/java/com/example/ecocraftplastic/OrganizationModeActivity.kt"
    click Detect "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/java/com/example/ecocraftplastic/PlasticDetectionActivity.kt"
    click Requests "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/java/com/example/ecocraftplastic/RecycleRequestsActivity.kt"
    click SuggestUI "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/java/com/example/ecocraftplastic/SuggestionActivity.kt"
    click Model "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/assets/model_unquant.tflite"
    click SuggestService "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/java/com/example/ecocraftplastic/SuggestionService.kt"
    click Constants "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/java/com/example/ecocraftplastic/Constants.kt"
    click Manifest "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/AndroidManifest.xml"
    click BackupRules "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/res/xml/backup_rules.xml"
    click DataExtraction "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/main/res/xml/data_extraction_rules.xml"
    click InstrTest "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/androidTest/java/com/example/ecocraftplastic/ExampleInstrumentedTest.kt"
    click UnitTest "https://github.com/vinay-daripelly/eco-craft/blob/master/app/src/test/java/com/example/ecocraftplastic/ExampleUnitTest.kt"

    %% Styles
    classDef androidClient fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef ml fill:#90EE90,stroke:#333,stroke-width:1px
    classDef cloud fill:#FFA500,stroke:#333,stroke-width:1px
    classDef test fill:#D3D3D3,stroke:#333,stroke-width:1px
```
