# kslat3r/anpr-dashcam architecture

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

- Interactive diagram: https://gitdiagram.com/kslat3r/anpr-dashcam
- Repository: https://github.com/kslat3r/anpr-dashcam

## Overview

##### Main Components

A. Hardware Layer:
- Raspberry Pi v3
- Camera Module
- Touchscreen Module

B. Application Layer:
Frontend (React Application):
- User Interface Components
- Redux Store
- WebSocket Client

Backend (Node.js Server):
- WebSocket Server
- Service Layer
- Facades Layer

C. External Services:
- DVLA API Integration

##### Component Relationships and Data Flow

**[Hardware] → [Backend Services] → [Frontend Components] → [User Interface]**

##### Detailed Component Breakdown

Frontend Components (React):
- Layout Container
- Vehicle Details Components (Make, Model, MOT, Tax)
- Image Component
- Loading Component
- Numberplate Component

Backend Services:
- ANPR Service
- Camera Service
- DVLA Service
- Cache Service
- Number Plate Service
- Client Management Service

##### Key Elements to Highlight

A. Data Flow:
- Camera → ANPR Service → Number Plate Detection → DVLA Service → Frontend Display
- WebSocket Communication between Client and Server
- Redux State Management Flow

B. Service Integration:
- Camera Module Integration
- DVLA API Integration
- Caching Layer

##### Specific Implementation Details

- Real-time processing pipeline
- WebSocket-based communication (shown in socket.js)
- Redux state management (actions and reducers)
- Facade pattern implementation for vehicle and photo handling
- Service layer architecture

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Hardware
        RPi[Raspberry Pi v3]:::hardware
        Cam[Camera Module]:::hardware
        Touch[Touchscreen Module]:::hardware
        Cam --> RPi
        Touch --> RPi
    end

    subgraph Backend
        WS[WebSocket Server]:::backend
        
        subgraph Services
            ANPR[ANPR Service]:::service
            CamS[Camera Service]:::service
            DVLAS[DVLA Service]:::service
            Cache[Cache Service]:::service
            NPS[Number Plate Service]:::service
            CMS[Client Management Service]:::service
        end
        
        subgraph Facades
            VF[Vehicle Facade]:::facade
            PF[Photo Facade]:::facade
        end
        
        RPi --> CamS
        CamS --> ANPR
        ANPR --> NPS
        NPS --> VF
        CamS --> PF
        VF --> WS
        PF --> WS
    end

    subgraph Frontend
        WSC[WebSocket Client]:::frontend
        Redux[Redux Store]:::frontend
        
        subgraph "UI Components"
            Layout[Layout Container]:::ui
            VD[Vehicle Details]:::ui
            Img[Image Component]:::ui
            Load[Loading Component]:::ui
            NP[Numberplate Component]:::ui
        end
        
        WSC --> Redux
        Redux --> Layout
        Layout --> VD
        Layout --> Img
        Layout --> Load
        Layout --> NP
    end

    subgraph External
        DVLA[DVLA API]:::external
    end

    DVLAS <--> DVLA
    WS <--> WSC

    %% Click Events
    click Layout "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/client/src/containers/layout/Layout.js"
    click VD "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/client/src/components/details/Details.js"
    click Img "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/client/src/components/image/Image.js"
    click Load "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/client/src/components/loading/Loading.js"
    click NP "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/client/src/components/numberplate/Numberplate.js"
    click Redux "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/client/src/store.js"
    click WSC "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/client/src/services/socket.js"
    click ANPR "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/server/services/anpr.js"
    click CamS "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/server/services/camera.js"
    click DVLAS "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/server/services/dvla.js"
    click Cache "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/server/services/cache.js"
    click NPS "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/server/services/number-plate.js"
    click CMS "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/server/services/clients.js"
    click VF "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/server/facades/vehicle.js"
    click PF "https://github.com/kslat3r/anpr-dashcam/blob/master/app/packages/server/facades/photo.js"

    classDef hardware fill:#E0E0E0,stroke:#333,stroke-width:2px
    classDef backend fill:#D5E8D4,stroke:#82B366,stroke-width:2px
    classDef service fill:#97D077,stroke:#82B366,stroke-width:2px
    classDef facade fill:#B9E0A5,stroke:#82B366,stroke-width:2px
    classDef frontend fill:#DAE8FC,stroke:#6C8EBF,stroke-width:2px
    classDef ui fill:#B1DEFF,stroke:#6C8EBF,stroke-width:2px
    classDef external fill:#FFE6CC,stroke:#D79B00,stroke-width:2px

    subgraph Legend
        L1[Hardware Component]:::hardware
        L2[Backend Service]:::service
        L3[Frontend Component]:::frontend
        L4[External API]:::external
        L5[Facade]:::facade
        L6[UI Component]:::ui
    end
```
