# jeetgoyal80/cropic-ai architecture

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

- Interactive diagram: https://gitdiagram.com/jeetgoyal80/cropic-ai
- Repository: https://github.com/jeetgoyal80/cropic-ai

## Overview

##### Project type and purpose
- This is a full-stack, mobile-centric agricultural aid system.
- Frontend: a Flutter mobile app (app/) for farmers to sign up, log in, submit claims, view crops, insights, profiles.
- Backend: a Python FastAPI service (Backend/app/) exposing REST endpoints for farmers and disease-prediction.
- ML component: a PyTorch model file (disease_model.pt) and Jupyter notebook (Ml_model/notebook/Training.ipynb) used for training and served by the backend.
- Database: managed in Backend/app/database/db.py (likely SQLite or PostgreSQL via SQLAlchemy/SQLModel).

##### File structure
- Top-level folders:
- app/ (Flutter mobile application)
- Backend/ (Python FastAPI backend)
- Ml_model/ (model training notebooks)
- app/: follows Flutter conventions
- android/ (native Android build)
- lib/ (Dart code: models, providers, screens, services, utils)
- Backend/app/: follows FastAPI conventions
- routers/ (API endpoints: farmers.py, predict.py)
- schemas/ (Pydantic DTOs)
- models/ (PyTorch model artifacts)
- utils/ (authentication and helper functions)
- database/ (connection and ORM setup)
- Configuration files: requirements.txt, pubspec.yaml, gradle files, etc.

##### README
- Minimal placeholder (“Let’s Started”).

##### Be detailed but avoid over-fragmentation
- Environment boundaries (Mobile, Backend, Database, Dev/Training).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Development / Training Environment
    subgraph "Dev/Training Environment"
        direction TB
        Notebook["Jupyter Notebook\n(Training.ipynb)"]:::dev
        Notebook -->|"generates model artifact"| ModelArtifact
    end

    %% ML Model Artifact
    ModelArtifact["PyTorch Model Artifact\n(disease_model.pt)"]:::ml

    %% Backend Service
    subgraph "FastAPI Backend Service"
        direction TB
        Main["Service Entry Point\n(main.py)"]:::backend
        FarmersRouter["Farmers CRUD Router\n(farmers.py)"]:::backend
        PredictRouter["Disease Prediction Router\n(predict.py)"]:::backend
        Schemas["Pydantic Schemas\n(schemas/)"]:::backend
        DB["Database Config & ORM\n(db.py)"]:::database
        UtilsAuth["Auth Utilities\n(auth.py)"]:::backend
        UtilsHelper["Helper Utilities\n(utils.py)"]:::backend

        Main -->|includes routers| FarmersRouter
        Main -->|includes routers| PredictRouter
        FarmersRouter -->|uses schemas| Schemas
        FarmersRouter -->|CRUD operations| DB
        PredictRouter -->|loads model| ModelArtifact
        PredictRouter -->|uses schemas| Schemas
        Main -->|uses auth| UtilsAuth
        Main -->|uses helpers| UtilsHelper
    end

    %% Mobile Application
    subgraph "Flutter Mobile App"
        direction TB
        MobileApp["Flutter App\n(app/)"]:::frontend
        Screens["UI Screens\n(app/lib/screens)"]:::frontend
        Providers["State Management Providers\n(app/lib/providers)"]:::frontend
        Services["Client Services\n(app/lib/services)"]:::frontend

        MobileApp --> Screens
        MobileApp --> Providers
        MobileApp --> Services
        Services -->|REST API calls| Main
    end

    %% Database Instance
    Database["Database Instance\n(SQLAlchemy/SQLModel)"]:::database
    DB -->|connects to| Database

    %% External Services (optional)
    subgraph "External Services"
        direction TB
        AuthProvider["OAuth/JWT Provider"]:::external
        PushNotifications["Push Notifications Service"]:::external
    end
    UtilsAuth -->|verifies tokens| AuthProvider
    MobileApp -->|receives notifications| PushNotifications

    %% Click Events
    click MobileApp "https://github.com/jeetgoyal80/cropic-ai/tree/main/app/"
    click Screens "https://github.com/jeetgoyal80/cropic-ai/tree/main/app/lib/screens"
    click Providers "https://github.com/jeetgoyal80/cropic-ai/tree/main/app/lib/providers"
    click Services "https://github.com/jeetgoyal80/cropic-ai/tree/main/app/lib/services"
    click Main "https://github.com/jeetgoyal80/cropic-ai/blob/main/Backend/app/main.py"
    click FarmersRouter "https://github.com/jeetgoyal80/cropic-ai/blob/main/Backend/app/routers/farmers.py"
    click PredictRouter "https://github.com/jeetgoyal80/cropic-ai/blob/main/Backend/app/routers/predict.py"
    click Schemas "https://github.com/jeetgoyal80/cropic-ai/tree/main/Backend/app/schemas"
    click DB "https://github.com/jeetgoyal80/cropic-ai/blob/main/Backend/app/database/db.py"
    click UtilsAuth "https://github.com/jeetgoyal80/cropic-ai/blob/main/Backend/app/utils/auth.py"
    click UtilsHelper "https://github.com/jeetgoyal80/cropic-ai/blob/main/Backend/app/utils/utils.py"
    click ModelArtifact "https://github.com/jeetgoyal80/cropic-ai/blob/main/Backend/app/models/disease_model.pt"
    click Notebook "https://github.com/jeetgoyal80/cropic-ai/blob/main/Ml_model/notebook/Training.ipynb"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef backend fill:#E0FFE0,stroke:#28a745,color:#28a745;
    classDef database fill:#FFE8D0,stroke:#d15704,color:#d15704;
    classDef ml fill:#F3E8FF,stroke:#6f42c1,color:#6f42c1;
    classDef dev fill:#F0F0F0,stroke:#6a737d,color:#6a737d;
    classDef external fill:#FFF5E5,stroke:#d73a49,color:#d73a49;
```
