# gausampada/ai-model architecture

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

- Interactive diagram: https://gitdiagram.com/gausampada/ai-model
- Repository: https://github.com/gausampada/ai-model

## Overview

##### Project type and purpose
- This is a backend-only RESTful API service written in Python using Flask.
- Its purpose is to expose endpoints that accept text or images of Indian indigenous cow breeds, forward them to Google’s Gemini AI models, and return breed information or health-related observations.

##### File structure
- Top-level files:
- app.py   – Defines Flask routes (/ , /image_to_text, /text_to_text, /text_to_text_chat)
- breed_info.py – Encapsulates static or curated text-based data and logic for returning breed details
- cow_breed_api.py – Wraps calls to Google Gemini AI (construct prompts, call the external API, handle responses)
- requirements.txt – Flask, google-cloud libs, other dependencies
- README.md, .gitignore
- No database or persistent storage is present—this is a stateless, serverless-style API layer.

##### README for additional insights
- Uses environment variable GOOGLE_API_KEY to authenticate with Google Gemini.
- Emphasizes three main functional flows:
a. Image Analysis
b. Text Query
c. Chat-based Interaction

## Diagram (Mermaid)

```mermaid
flowchart TB
    client["Client\n(farmers apps, Postman, cURL)"]:::external

    subgraph "Flask API Layer"
        api["/ (Health Check)"]:::internal
        img["/image_to_text"]:::internal
        text["/text_to_text"]:::internal
        chat["/text_to_text_chat"]:::internal
    end

    subgraph "Business Logic Layer"
        imgHandler["ImageProcessor"]:::internal
        textHandler["TextQueryHandler"]:::internal
        chatHandler["ChatHandler"]:::internal
        breedInfo["Breed Info Module"]:::internal
    end

    integration["Gemini API Wrapper"]:::internal
    gaService["Google Gemini AI"]:::external
    config["Configuration\n(.env: GOOGLE_API_KEY)"]:::config
    docs["Project Docs\nREADME.md"]:::docs
    deps["Dependencies\nrequirements.txt"]:::docs

    client -->|HTTP/JSON| api
    client -->|HTTP/JSON| img
    client -->|HTTP/JSON| text
    client -->|HTTP/JSON| chat

    img -->|delegate| imgHandler
    text -->|delegate| textHandler
    chat -->|delegate| chatHandler

    imgHandler -->|calls| integration
    chatHandler -->|calls| integration
    textHandler -->|calls| breedInfo
    textHandler -->|optional gemini| integration

    integration -->|REST/gRPC| gaService
    gaService -->|response| integration

    integration -->|returns text| imgHandler
    integration -->|returns text| chatHandler
    breedInfo -->|returns data| textHandler

    config --- integration
    config --- api

    client --- docs
    docs --- deps

    click api "https://github.com/gausampada/ai-model/blob/master/app.py"
    click img "https://github.com/gausampada/ai-model/blob/master/app.py"
    click text "https://github.com/gausampada/ai-model/blob/master/app.py"
    click chat "https://github.com/gausampada/ai-model/blob/master/app.py"
    click imgHandler "https://github.com/gausampada/ai-model/blob/master/cow_breed_api.py"
    click chatHandler "https://github.com/gausampada/ai-model/blob/master/cow_breed_api.py"
    click textHandler "https://github.com/gausampada/ai-model/blob/master/breed_info.py"
    click breedInfo "https://github.com/gausampada/ai-model/blob/master/breed_info.py"
    click integration "https://github.com/gausampada/ai-model/blob/master/cow_breed_api.py"
    click config "https://github.com/gausampada/ai-model/blob/master/README.md"
    click docs "https://github.com/gausampada/ai-model/blob/master/README.md"
    click deps "https://github.com/gausampada/ai-model/blob/master/requirements.txt"

    classDef internal fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef external fill:#d4edda,stroke:#333,stroke-width:1px
    classDef config fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef docs fill:#f8d7da,stroke:#333,stroke-width:1px
```
