# ruhanimittal29/clearbite architecture

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

- Interactive diagram: https://gitdiagram.com/ruhanimittal29/clearbite
- Repository: https://github.com/ruhanimittal29/clearbite

## Overview

##### Project Type and Purpose
- ClearBite is a full-stack AI-powered application aimed at helping users identify dietary triggers for acne and obtain personalized recommendations.
- The system integrates a React-based frontend, a Flask-based backend API, and an AI model (a fine-tuned Mistral model) that processes user inputs to generate advice.

##### Analyzing the File Structure
- The “app” directory contains the frontend code—React components, CSS, HTML, and configuration files (including Dockerfile, nginx configuration, and Vite config). This clearly indicates the client-side interface.
- The “model” directory hosts a Jupyter Notebook (ClearBite_Model.ipynb), which represents the work done to fine-tune the AI model.
- The “data” directory holds training and testing datasets, which were essential for the training phase.
- Deployment and container orchestration files (Docker-related files inside “app” and top-level docker-compose YAML files) provide hints about how the system is containerized and deployed.
- Although the file tree does not explicitly show a backend directory with Flask code, the README clarifies that a Flask-based backend API is part of the system. It’s likely this code may reside in a different location or be integrated into one of these directories (or possibly inside the “nwhack” folder), assuming a structure where the backend acts as the intermediary between the front-end and the AI model.

##### Key Architectural Components
- Frontend: The React application (from the “app” folder) is the user interface, facilitating user interactions and visualization of advice.
- Backend API: Powered by Flask and responsible for handling API requests, connecting the frontend with the AI model, and processing user-submitted dietary details.
- AI Model: The fine-tuned Mistral model (indicated in the README and represented by the notebook in the “model” folder) processes input data to identify dietary triggers.
- Data Storage/Processing: The “data” directory (with training and test datasets) is used during the model’s training phase.
- Containerization & Deployment: With Dockerfiles and compose files present, container-based deployment is applied to manage environment consistency and scalability.

##### Relationships and Interactions
- User -> Frontend: Users interact with the React UI, which sends HTTP requests.
- Frontend -> Backend: These requests are forwarded by the frontend to the Flask API.
- Backend -> AI Model: The Flask backend processes incoming requests, interacts with the AI model to fetch predictions, and returns results.
- Deployment: Docker containers (defined by Dockerfile, compose.yaml, etc.) help encapsulate the frontend, backend, and possibly model serving components for deployment.

##### Architectural Patterns and Technologies
- Separation of concerns separating the frontend, backend, and model logic states.
- With the tech-stack details: React JS and CSS for the client, Flask and Python3 for the backend & API, and Mistral for the AI model, with Docker and docker-compose handling container orchestration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global entities
    U("User"):::userClass

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE("React Frontend"):::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE("Flask API"):::backend
    end

    %% AI Processing Layer
    subgraph "AI Processing"
        M("Mistral AI Model"):::model
        D("Data Repository"):::data
    end

    %% Deployment & Containerization
    subgraph "Deployment & Containerization"
        DEP("Docker & docker-compose"):::deployment
    end

    %% Relationships
    U -->|"interacts"| FE
    FE -->|"calls_API"| BE
    BE -->|"processes"| M
    D -->|"feeds_training_data"| M
    DEP -.-> FE
    DEP -.-> BE
    DEP -.-> M
    DEP -.-> D

    %% Click Events
    click FE "https://github.com/ruhanimittal29/clearbite/tree/main/app"
    click BE "https://github.com/ruhanimittal29/clearbite/tree/main/nwhack"
    click M "https://github.com/ruhanimittal29/clearbite/blob/main/model/ClearBite_Model.ipynb"
    click D "https://github.com/ruhanimittal29/clearbite/tree/main/data"
    click DEP "https://github.com/ruhanimittal29/clearbite/tree/main/app/Dockerfile"

    %% Styles
    classDef userClass fill:#f9c,stroke:#333,stroke-width:2px;
    classDef frontend fill:#bbf,stroke:#333,stroke-width:2px;
    classDef backend fill:#bfb,stroke:#333,stroke-width:2px;
    classDef model fill:#ffb,stroke:#333,stroke-width:2px;
    classDef data fill:#fbb,stroke:#333,stroke-width:2px;
    classDef deployment fill:#bff,stroke:#333,stroke-width:2px;
```
