# ssyquia/claw-patrol architecture

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

- Interactive diagram: https://gitdiagram.com/ssyquia/claw-patrol
- Repository: https://github.com/ssyquia/claw-patrol

## Overview

##### Project Type and Purpose
- This is a single-service, full-stack ML application built with Streamlit (front-end + lightweight back-end) for image classification.
- Purpose: Users upload a dinosaur image; the app uses a ResNet152V2 model to predict one of 15 species.

##### File Structure
- Top-level:
- app.py – Streamlit entry point
- model/ – holds the trained ResNet152V2 model file(s)
- data/ – labeled images (used offline for training/experimentation)
- dino-cnn.ipynb – Jupyter notebook for model development/training
- requirements.txt – Python dependencies (Streamlit, TensorFlow/Keras, etc.)
- .devcontainer/ – Docker devcontainer setup for reproducible local development
- venv/ – local Python virtual environment
- No persistent database; inference is served directly from the file system.

##### README for Insights
- Confirms front-end is served by Streamlit Cloud.
- Highlights the core ML component: ResNet152V2.
- No external APIs or microservices.

##### Main Components & Their Relationships
a. User & Web Client
- A user accesses the Streamlit web UI via browser (or mobile).
b. Deployment Environment
- Streamlit Cloud (or containerized server) hosting app.py
- Python runtime environment with dependencies from requirements.txt
c. Inference Engine
- app.py routes image inputs into the model loader/inference module
- The ResNet152V2 model is loaded from model/ directory at startup
d. Data Layer (Offline)
- data/ directory used during local training (shown for completeness)
e. Development Environment
- .devcontainer for Dockerized VS Code development
- dino-cnn.ipynb for experimentation and retraining

Interactions (Data Flow):
1. User → uploads image via Streamlit UI
2. Streamlit front-end (in app.py) → passes image to inference function
3. Inference function → loads and runs ResNet152V2 on the image
4. Prediction result → sent back to front-end
5. Streamlit UI → displays predicted species to the user

##### Architectural Patterns & Principles
- Single-page application with clear separation:
- Presentation layer (Streamlit widgets & layout)
- Inference logic (model loading & prediction)
- Containerized development ensures environment parity (.devcontainer)
- Reusable modules: model loader, preprocessing, prediction

##### Detailed Components
- Streamlit Server (app.py)
- Dependency Loader (requirements.txt, venv)
- Inference Function (preprocessing + model.predict)
- Model Repository (model/.h5 or saved_weights)
- Offline Training Notebook (dino-cnn.ipynb)
- Devcontainer (Docker config)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    User["User Browser"]:::frontend

    %% Frontend & Inference Service
    Streamlit["Streamlit Server (app.py)"]:::frontend
    Dependency["Dependencies (requirements.txt, venv)"]:::backend
    LocalEnv["Virtual Environment (venv/)"]:::dev
    Inference["Inference Module<br/>(preprocessing + model.predict)"]:::backend

    %% Data/Model Storage
    Model["ResNet152V2 Model Files"]:::data
    DataOffline["Offline Labeled Training Images"]:::data

    %% Offline Training Pipeline
    OfflineNotebook["Offline Training Notebook (dino-cnn.ipynb)"]:::dev

    %% Development Environment
    Devcontainer["Devcontainer (Docker)<br/>(.devcontainer/devcontainer.json)"]:::dev
    Readme["Project Readme (README.md)"]:::dev

    %% Main Request Flow
    User -->|"Upload Image"| Streamlit
    Streamlit -->|"Invoke Inference"| Inference
    Inference -->|"Load Model"| Model
    Inference -->|"Return Prediction"| Streamlit
    Streamlit -->|"Display Result"| User

    %% Dependency Flow
    Dependency -->|"Installed In"| Streamlit
    Dependency -->|"Installed In"| Inference
    LocalEnv -->|"Provides Runtime"| Streamlit
    LocalEnv -->|"Provides Runtime"| Inference

    %% Offline Training Flow
    OfflineNotebook -->|"Reads Images"| DataOffline
    OfflineNotebook -->|"Generates/Updates"| Model

    %% Dev Environment Relations
    Devcontainer -->|"Configures Env"| Streamlit
    Devcontainer -->|"Configures Env"| OfflineNotebook
    Readme -->|"Documents Setup"| Streamlit
    Readme -->|"Documents Setup"| Devcontainer

    %% Click Events
    click Streamlit "https://github.com/ssyquia/claw-patrol/blob/master/app.py"
    click Dependency "https://github.com/ssyquia/claw-patrol/blob/master/requirements.txt"
    click LocalEnv "https://github.com/ssyquia/claw-patrol/tree/master/venv/"
    click Inference "https://github.com/ssyquia/claw-patrol/blob/master/app.py"
    click Model "https://github.com/ssyquia/claw-patrol/tree/master/model/"
    click DataOffline "https://github.com/ssyquia/claw-patrol/tree/master/data/"
    click OfflineNotebook "https://github.com/ssyquia/claw-patrol/blob/master/dino-cnn.ipynb"
    click Devcontainer "https://github.com/ssyquia/claw-patrol/blob/master/.devcontainer/devcontainer.json"
    click Readme "https://github.com/ssyquia/claw-patrol/blob/master/README.md"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px,color:#000
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px,color:#000
    classDef data fill:#FFA500,stroke:#333,stroke-width:1px,color:#000
    classDef dev fill:#D3D3D3,stroke:#333,stroke-width:1px,color:#000
```
