# krishnaik06/chicken-disease-classification-projects architecture

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

- Interactive diagram: https://gitdiagram.com/krishnaik06/chicken-disease-classification-projects
- Repository: https://github.com/krishnaik06/chicken-disease-classification-projects

## Overview

##### Project Type and Purpose
- This project is a full-stack machine-learning application with:
- An ML pipeline (data ingestion → preprocessing → model training → evaluation → prediction)
- A REST/HTML interface (app.py + templates) for inference
- Reproducibility via DVC (dvc.yaml, dvc.lock)
- Containerization (Dockerfile) and CI/CD (GitHub Actions, AWS/Azure)

A. Data & Configuration
– Raw data store (local folder, remote S3 if used)
– config/config.yaml, params.yaml, secrets.yaml (optional)
– src/cnnClassifier/config & entity modules (centralized config manager)
B. ML Pipeline (Python modules under src/cnnClassifier/components & pipeline)
1. Data Ingestion (components/data_ingestion.py → pipeline/stage_01_data_ingestion.py)
2. Base Model Preparation (components/prepare_base_model.py → pipeline/stage_02_prepare_base_model.py)
3. Callbacks Preparation (components/prepare_callbacks.py → pipeline/stage_03_prepare_callbacks)
4. Model Training (components/training.py → pipeline/stage_03_training.py)
5. Model Evaluation (components/evaluation.py → pipeline/stage_04_evaluation.py)
6. Prediction Service (pipeline/predict.py)
C. DVC Reproducibility
– dvc.yaml defines pipeline stages, artifacts, commands
– dvc repro & dvc dag for orchestration
D. Web Application
– app.py (Flask/FastAPI entry point)
– template.py & templates/index.html (UI layer)
E. Container & Deployment
– Dockerfile builds the app + dependencies
– GitHub Actions workflows (.github/workflows/*.yml) for CI/CD
– AWS components: ECR (artifact registry), EC2 (host), IAM roles
– Azure components (optional): Azure Container Registry, Web App
F. External Services
– (Optionally) S3 or other data storage
– (Optionally) Model registry if extended

##### Interactions & Data Flow
1. Config → ML Pipeline stages
2. Pipeline stages producing model artifacts (saved .pkl or .h5)
3. DVC tracking of inputs/outputs between stages
4. Prediction Service reading the trained model
5. Web App receiving HTTP requests → invokes prediction pipeline
6. CI/CD pipelines triggered by code pushes → build Docker image → push to ECR/Azure CR → deploy to EC2/Web App

##### Architectural Patterns & Principles
- Modular ML pipeline (each stage is its own component + script)
- Configuration-driven design (params.yaml + config manager)
- Infrastructure as code / reproducibility (DVC + Docker + GitHub Actions)
- Separation of concerns (data processing vs. model vs. serving layer)

##### Serving Layer (Flask app) loading the model + UI template
5. CI/CD Layer (GitHub Actions) building the Docker image → pushing to registry → deploying to host (EC2 or Azure Web App)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data & Configuration
    subgraph "Data & Configuration"
        CONFIG_YAML["config/config.yaml"]:::data
        PARAMS["params.yaml"]:::data
        CONF_MODULE["Configuration Module"]:::data
        ENTITY_MODULE["Config Entity"]:::data
        RAW["Raw Data Store"]:::data
    end

    %% DVC Reproducibility
    subgraph "DVC Reproducibility"
        DVC_YAML["dvc.yaml"]:::infra
        DVC_LOCK["dvc.lock"]:::infra
        DVC_CONF[".dvc/config"]:::infra
    end

    %% ML Pipeline Stages
    subgraph "ML Pipeline" 
        direction TB
        ING["Data Ingestion Component"]:::ml
        PREP_BASE["Base Model Preparation"]:::ml
        PREP_CB["Callbacks Preparation"]:::ml
        TRAIN["Model Training Component"]:::ml
        EVAL["Model Evaluation Component"]:::ml
        PRED["Prediction Service"]:::ml
    end

    %% Model Artifact
    MODEL_ARTIFACT["Trained Model Artifact"]:::data

    %% Serving Layer
    subgraph "Serving Layer"
        FLASK["Flask App (app.py)"]:::serving
        TEMPLATE["Template (templates/index.html)"]:::serving
    end

    %% Container & CI/CD
    subgraph "Container & CI/CD"
        direction TB
        GH1[".github/workflows/main.yaml"]:::infra
        GH2[".github/workflows/main_chickenapp.yml"]:::infra
        DOCKERFILE["Dockerfile"]:::infra
        DOCKER_IMAGE["Docker Image"]:::infra
        ECR["ECR (AWS)"]:::external
        AZCR["Azure Container Registry"]:::external
        EC2["EC2 Instance"]:::infra
        AZWEB["Azure Web App"]:::infra
    end

    %% External Services
    S3["S3 Bucket"]:::external

    %% Connections
    CONFIG_YAML --> ING
    PARAMS --> ING
    CONF_MODULE --> ING
    ENTITY_MODULE --> ING

    ING --> PREP_BASE --> PREP_CB --> TRAIN --> EVAL --> PRED
    DVC_YAML --> ING
    DVC_YAML --> PREP_BASE
    DVC_YAML --> PREP_CB
    DVC_YAML --> TRAIN
    DVC_YAML --> EVAL
    DVC_YAML --> PRED
    DVC_LOCK --> DVC_YAML
    DVC_CONF --> DVC_YAML

    PRED --> MODEL_ARTIFACT
    MODEL_ARTIFACT --> FLASK
    FLASK -->|"renders"| TEMPLATE
    FLASK -->|"HTTP POST /predict"| PRED

    GH1 --> DOCKERFILE
    GH2 --> DOCKERFILE
    DOCKERFILE --> DOCKER_IMAGE
    DOCKER_IMAGE --> ECR
    DOCKER_IMAGE --> AZCR
    ECR --> EC2
    AZCR --> AZWEB
    EC2 --> FLASK
    AZWEB --> FLASK

    S3 --> RAW
    RAW --> ING

    %% Click Events
    click CONFIG_YAML "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/config/config.yaml"
    click PARAMS "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/params.yaml"
    click CONF_MODULE "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/src/cnnClassifier/config/configuration.py"
    click ENTITY_MODULE "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/src/cnnClassifier/entity/config_entity.py"
    click ING "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/src/cnnClassifier/components/data_ingestion.py"
    click PREP_BASE "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/src/cnnClassifier/components/prepare_base_model.py"
    click PREP_CB "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/src/cnnClassifier/components/prepare_callbacks.py"
    click TRAIN "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/src/cnnClassifier/components/training.py"
    click EVAL "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/src/cnnClassifier/components/evaluation.py"
    click PRED "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/src/cnnClassifier/pipeline/predict.py"
    click DVC_YAML "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/dvc.yaml"
    click DVC_LOCK "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/dvc.lock"
    click DVC_CONF "https://github.com/krishnaik06/chicken-disease-classification-projects/tree/main/.dvc/config"
    click FLASK "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/app.py"
    click TEMPLATE "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/templates/index.html"
    click DOCKERFILE "https://github.com/krishnaik06/chicken-disease-classification-projects/tree/main/Dockerfile"
    click GH1 "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/.github/workflows/main.yaml"
    click GH2 "https://github.com/krishnaik06/chicken-disease-classification-projects/blob/main/.github/workflows/main_chickenapp.yml"

    %% Styles
    classDef data fill:#cccccc,stroke:#333,stroke-width:1px
    classDef ml fill:#add8e6,stroke:#333,stroke-width:1px
    classDef serving fill:#90ee90,stroke:#333,stroke-width:1px
    classDef infra fill:#ffa500,stroke:#333,stroke-width:1px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px
```
