# sahilkhan-7/accident-damage-detection architecture

> Architecture diagram of the GitHub repository sahilkhan-7/accident-damage-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sahilkhan-7/accident-damage-detection
- Repository: https://github.com/sahilkhan-7/accident-damage-detection

## Overview

##### Main Components

A. Client Layer:
- Web Interface (HTML/CSS/JavaScript)
- Different views (login, signup, dashboard, estimate)
- Image upload interface

B. Application Layer:
- Flask Web Server
- Authentication System
- Image Processing Pipeline
- Cost Estimation Engine

C. AI/ML Layer:
- YOLOv8 Model
- Object Detection System
- Damage Assessment

D. Data Layer:
- MySQL Database
- File Storage (for images)
- JSON Configuration (car_parts_prices.json)

##### Component Relationships and Data Flow

**User Interface → Flask Server → AI Model → Database**
- ↑             ↓
- Cost Estimation ────┘

##### Specific Implementation Details

- Frontend Templates (templates/*.html)
- Core Application (app.py)
- Model Storage (models/best.pt)
- Configuration (config.py)
- Database Schema (db_schema.sql)

##### Key Interactions to Highlight

A. User Flow:
- Authentication flow (login/signup)
- Image upload process
- Result visualization

B. Processing Flow:
- Image preprocessing
- Model inference
- Cost calculation
- Result storage

C. Data Flow:
- Database operations
- File storage operations
- Configuration management

##### Technical Details

A. Technologies:
- Flask (Web Framework)
- YOLOv8 (AI Model)
- MySQL (Database)
- OpenCV (Image Processing)
- Ultralytics (YOLOv8 Integration)

B. API Endpoints:
- Authentication endpoints
- Image upload endpoint
- Estimation endpoint
- Profile management endpoints

##### Data Storage Layer (Bottom)

Left to right approach:
- Input processing → Core processing → Output generation

Remember to:
- Use consistent symbols and notation
- Brief descriptions for complex components
- Both data and control flow
- Error handling paths
- System boundaries

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef ai fill:#e74c3c,stroke:#c0392b,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef config fill:#9b59b6,stroke:#8e44ad,color:white

    %% Client Layer
    subgraph ClientLayer
        WebUI["Web Interface"]:::frontend
        AuthUI["Authentication Interface"]:::frontend
        DashUI["Dashboard Interface"]:::frontend
        EstUI["Estimation Interface"]:::frontend
        ProfUI["Profile Management"]:::frontend
    end

    %% Application Layer
    subgraph AppLayer
        Flask["Flask Web Server"]:::backend
        Auth["Authentication System"]:::backend
        ImgProc["Image Processing Pipeline"]:::backend
        CostEng["Cost Estimation Engine"]:::backend
        Config["Configuration"]:::config
    end

    %% AI/ML Layer
    subgraph AILayer
        YOLO["YOLOv8 Model"]:::ai
        ObjDet["Object Detection System"]:::ai
        DmgAssess["Damage Assessment"]:::ai
    end

    %% Data Layer
    subgraph DataLayer
        DB[(MySQL Database)]:::data
        FileStore[(File Storage)]:::data
        CostConfig["Cost Configuration"]:::data
    end

    %% Relationships
    WebUI --> Flask
    AuthUI --> Auth
    DashUI --> Flask
    EstUI --> ImgProc
    ProfUI --> Auth

    Flask --> Auth
    Flask --> ImgProc
    ImgProc --> YOLO
    YOLO --> ObjDet
    ObjDet --> DmgAssess
    DmgAssess --> CostEng
    CostEng --> CostConfig
    
    Auth --> DB
    ImgProc --> FileStore
    CostEng --> DB

    %% Click events
    click WebUI "https://github.com/sahilkhan-7/accident-damage-detection/blob/main/templates/index.html"
    click AuthUI "https://github.com/sahilkhan-7/accident-damage-detection/tree/main/templates"
    click DashUI "https://github.com/sahilkhan-7/accident-damage-detection/blob/main/templates/dashboard.html"
    click EstUI "https://github.com/sahilkhan-7/accident-damage-detection/blob/main/templates/estimate.html"
    click ProfUI "https://github.com/sahilkhan-7/accident-damage-detection/tree/main/templates"
    click Flask "https://github.com/sahilkhan-7/accident-damage-detection/blob/main/app.py"
    click Config "https://github.com/sahilkhan-7/accident-damage-detection/blob/main/config.py"
    click YOLO "https://github.com/sahilkhan-7/accident-damage-detection/blob/main/models/best.pt"
    click DB "https://github.com/sahilkhan-7/accident-damage-detection/blob/main/db_schema.sql"
    click CostConfig "https://github.com/sahilkhan-7/accident-damage-detection/blob/main/car_parts_prices.json"

    %% Legend
    subgraph Legend
        Frontend["Frontend Components"]:::frontend
        Backend["Backend Components"]:::backend
        AIComp["AI Components"]:::ai
        DataComp["Data Storage"]:::data
        ConfigComp["Configuration"]:::config
    end
```
