# dhiwinsamrich/yolov8_blueprint_detector architecture

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

- Interactive diagram: https://gitdiagram.com/dhiwinsamrich/yolov8_blueprint_detector
- Repository: https://github.com/dhiwinsamrich/yolov8_blueprint_detector

## Overview

##### Project type and purpose
- This is a monolithic, full-stack machine-learning inference service:
- FastAPI-based backend exposing JSON and interactive UI endpoints
- YOLOv8 object-detection model for doors and windows
- Static web frontend (drag-and-drop) for user interaction
- Docker-ready deployment with Docker Compose

##### File structure
- Top-level files and directories
- `app.py` / `new_version.py`: FastAPI application entrypoint
- `static/`, `frontend.html`: Web UI assets (HTML/CSS/JS)
- `models/`, `yolov8n.pt`: Trained YOLO weight files
- `datasets/`, `train.py`: Training pipeline and labeled image sets
- `runs/`: Inference and training run artifacts
- `Dockerfile`, `docker-compose.yml`, `Start.sh`: Container orchestration
- `config.yaml`, `render.yaml`: Runtime configuration parameters
- `requirements.txt`: Python dependencies
- Patterns and design choices
- Layered architecture: presentation layer (static/UI), application layer (FastAPI endpoints), model layer (YOLOv8 inference), persistence (model files, logs)
- Model-loading strategy: custom weights → fallback weights
- Supports two clients: HTML drag-and-drop and direct API calls (curl/Postman)

##### README for additional insights
- Docker instructions: single service exposing port 8000
- Model loading fallback logic
- Training evidence and labeling format

##### Essential elements
- Component labels (e.g., “FastAPI Server”, “YOLOv8 Inference Engine”)
- Configuration and model files as data stores

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Actors
    Browser["User Browser"]:::external
    APIClient["API Client\n(curl/Postman)"]:::external

    %% Docker Container Boundary
    subgraph DockerContainer["Docker Container"]
        style DockerContainer stroke-dasharray:5 5

        %% Presentation Layer
        subgraph PresentationLayer["Presentation Layer"]
            InteractiveUI["Interactive UI\n(frontend.html)"]:::presentation
            StaticAssets["Static Assets\n(static/)"]:::presentation
        end

        %% Application Layer
        subgraph ApplicationLayer["Application Layer"]
            FastAPI["FastAPI Server\n(app.py)"]:::application
            Requirements["Python Dependencies\n(requirements.txt)"]:::infra
        end

        %% Model Inference Layer
        subgraph ModelLayer["Model Inference Layer"]
            WeightLoader["Model Manager\nWeight Loader"]:::model
            Inference["YOLOv8 Inference Engine"]:::model
        end

        %% Persistence Layer
        subgraph PersistenceLayer["Persistence"]
            ModelFiles["Model Artifacts\n(models/)"]:::persistence
            ConfigStore["Configuration Store\n(config.yaml, render.yaml)"]:::persistence
            Runs["Run Artifacts\n(runs/)"]:::persistence
        end

        %% Infrastructure
        subgraph Infrastructure["Infrastructure"]
            Dockerfile["Dockerfile"]:::infra
            Compose["docker-compose.yml"]:::infra
            Startsh["Start.sh"]:::infra
        end

    end

    %% Training Pipeline (side process)
    subgraph TrainingPipeline["Training Pipeline"]
        style TrainingPipeline stroke-dasharray:5 5
        Train["train.py"]:::application
        Datasets["Datasets\n(datasets/)"]:::persistence
    end

    %% Data Flows
    Browser -->|"GET /interactive"| InteractiveUI
    InteractiveUI --> StaticAssets
    InteractiveUI -->|"AJAX POST /detect"| FastAPI
    APIClient -->|"POST /detect"| FastAPI

    FastAPI -->|"Load weights"| WeightLoader
    WeightLoader -->|"reads"| ModelFiles
    WeightLoader --> Inference
    Inference -->|"writes"| Runs
    Inference -->|"inference result JSON + base64"| FastAPI

    FastAPI -->|"reads"| ConfigStore
    FastAPI -->|"response JSON"| InteractiveUI
    FastAPI -->|"response JSON"| APIClient

    Train -->|"reads"| Datasets
    Train -->|"writes"| ModelFiles

    %% Click Events
    click FastAPI "https://github.com/dhiwinsamrich/yolov8_blueprint_detector/blob/main/app.py"
    click InteractiveUI "https://github.com/dhiwinsamrich/yolov8_blueprint_detector/blob/main/frontend.html"
    click StaticAssets "https://github.com/dhiwinsamrich/yolov8_blueprint_detector/tree/main/static/"
    click ModelFiles "https://github.com/dhiwinsamrich/yolov8_blueprint_detector/tree/main/models/"
    click ConfigStore "https://github.com/dhiwinsamrich/yolov8_blueprint_detector/blob/main/config.yaml"
    click Runs "https://github.com/dhiwinsamrich/yolov8_blueprint_detector/tree/main/runs/"
    click Train "https://github.com/dhiwinsamrich/yolov8_blueprint_detector/blob/main/train.py"
    click Datasets "https://github.com/dhiwinsamrich/yolov8_blueprint_detector/tree/main/datasets/"
    click Dockerfile "https://github.com/dhiwinsamrich/yolov8_blueprint_detector/tree/main/Dockerfile"
    click Compose "https://github.com/dhiwinsamrich/yolov8_blueprint_detector/blob/main/docker-compose.yml"
    click Startsh "https://github.com/dhiwinsamrich/yolov8_blueprint_detector/blob/main/Start.sh"
    click Requirements "https://github.com/dhiwinsamrich/yolov8_blueprint_detector/blob/main/requirements.txt"

    %% Styles
    classDef presentation fill:#D6EAF8,stroke:#3498DB,stroke-width:1px
    classDef application fill:#D5F5E3,stroke:#27AE60,stroke-width:1px
    classDef model fill:#FDEBD0,stroke:#E67E22,stroke-width:1px
    classDef persistence fill:#E5E8E8,stroke:#95A5A6,stroke-width:1px
    classDef infra fill:#EBDEF0,stroke:#8E44AD,stroke-width:1px
    classDef external fill:#EBF5FB,stroke:#5D6D7E,stroke-width:1px
```
