# nikhil-kadaparthi/lumpy-skin-disease-prediction-in-cattle architecture

> Architecture diagram of the GitHub repository nikhil-kadaparthi/lumpy-skin-disease-prediction-in-cattle, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nikhil-kadaparthi/lumpy-skin-disease-prediction-in-cattle
- Repository: https://github.com/nikhil-kadaparthi/lumpy-skin-disease-prediction-in-cattle

## Overview

##### Project Type and Purpose
- FarmFriend is a full-stack application that offers cattle health assessments through AI-powered image analysis (using YOLOv8 and PyTorch) and weather data analysis (using a RandomForest model and OpenWeatherMap & GoMaps APIs).
- It integrates user authentication and profile management via Firebase, alongside a FastAPI backend for machine learning inference and API endpoint management, and a React + TypeScript frontend built with Vite.

##### Main Components
a. Front-End:
- React Application (located in the src folder) that includes pages (Dashboard, Login, Register, etc.) and components (Navbar, Footer, Animated components).
- Vite build tooling and Tailwind CSS for responsive styling, along with libraries such as Framer Motion for animations.
- AuthContext for managing user authentication state (with Firebase).
- API services to communicate with the backend (see src/api.ts).

b. Back-End:
- A FastAPI application (api.py) serving as the REST API server.
- The backend is built with Python using Uvicorn as the ASGI server.
- Integration of machine learning models: YOLOv8 model for image processing (stored as best.pt) and a RandomForest model for weather-based risk analysis (stored in random_forest_model_weather_data.pkl).
- Endpoints to process image uploads, fetch and integrate weather data, and update assessments with RT-PCR results.

c. Machine Learning & Data Processing:
- The image processing component (YOLOv8) and weather risk analysis, tied into the backend, represent key specialized services.
- How the models are loaded and used to process input data.

d. External Services & Data Storage:
- Firebase for handling user authentication and real-time database functions.
- Integration with external APIs: OpenWeatherMap for weather data and GoMaps API for geocoding.

##### Relationships and Interactions
- Back-End ⇄ Machine Learning Models: The backend loads and utilizes the ML models for cattle image analysis and weather-based forecasting.
- Back-End ⇄ Firebase: Authentication and data persistence are managed via Firebase connections.
- Back-End ⇄ External APIs: The backend makes API calls to OpenWeatherMap and GoMaps to retrieve live weather data and geolocation details.

##### Architectural Patterns & Design Principles
- Clear separation of concerns:
- Frontend: Focused on user experience, authentication, and presentation.
- Backend: REST API design that integrates machine learning and external service communication.
- Modularization: The project structure (with separate directories for components, pages, and context in the frontend) reflects a modular design pattern.
- Integration layers: Highlight the API client layer in the frontend (src/api.ts) and the service layer in the FastAPI backend that connects to ML models and external APIs.

##### Detail and Simplicity
- Do not hesitate to break down the system into as many components or layers as necessary to show all critical interactions.
- Additional details where possible (such as environment configurations, deployment options, or development vs. production flows if relevant).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    subgraph "External Services"
        FWAPI["OpenWeatherMap API"]:::external
        GMAPI["GoMaps API"]:::external
        ExtFB["Firebase"]:::external
    end

    %% Frontend Layer
    subgraph "Frontend (React/Vite)"
        FE["React Frontend"]:::frontend
        APIS["API Service Layer"]:::frontend
        ACTX["AuthContext"]:::frontend
        FBConfig["Firebase Config"]:::frontend
        UI["UI Components"]:::frontend
        PGS["Frontend Pages"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (FastAPI)"
        BE["FastAPI Backend Endpoints"]:::backend
        YOLO["YOLOv8 Model for Image Processing"]:::backend
        RF["RandomForest Classifier for Weather Analysis"]:::backend
    end

    %% User Interaction
    User["Browser/User"]:::user

    %% Connections
    User -->|"access"| FE
    FE -->|"calls"| APIS
    FE -->|"manages"| ACTX
    FE -->|"renders"| UI
    FE -->|"navigates"| PGS

    APIS -->|"requests"| BE

    BE -->|"processes image"| YOLO
    BE -->|"analyzes weather"| RF
    BE -->|"authenticates"| ExtFB
    BE -->|"fetches weather"| FWAPI
    BE -->|"gets geolocation"| GMAPI

    ACTX -->|"integrates"| FBConfig

    %% Click Events for Component Mapping
    click FE "https://github.com/nikhil-kadaparthi/lumpy-skin-disease-prediction-in-cattle/tree/main/src/"
    click APIS "https://github.com/nikhil-kadaparthi/lumpy-skin-disease-prediction-in-cattle/blob/main/src/api.ts"
    click ACTX "https://github.com/nikhil-kadaparthi/lumpy-skin-disease-prediction-in-cattle/blob/main/src/context/AuthContext.tsx"
    click FBConfig "https://github.com/nikhil-kadaparthi/lumpy-skin-disease-prediction-in-cattle/blob/main/src/firebase.ts"
    click UI "https://github.com/nikhil-kadaparthi/lumpy-skin-disease-prediction-in-cattle/tree/main/src/components"
    click PGS "https://github.com/nikhil-kadaparthi/lumpy-skin-disease-prediction-in-cattle/tree/main/src/pages"
    click BE "https://github.com/nikhil-kadaparthi/lumpy-skin-disease-prediction-in-cattle/blob/main/api.py"
    click YOLO "https://github.com/nikhil-kadaparthi/lumpy-skin-disease-prediction-in-cattle/blob/main/best.pt"
    click RF "https://github.com/nikhil-kadaparthi/lumpy-skin-disease-prediction-in-cattle/blob/main/random_forest_model_weather_data.pkl"

    %% Styles
    classDef user fill:#e0f7fa,stroke:#006064,stroke-width:2px,color:#006064;
    classDef frontend fill:#cce5ff,stroke:#0056b3,stroke-width:2px,color:#0056b3;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px,color:#155724;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px,color:#856404;
```
