# ntgnguyen/check-phat-nguoi architecture

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

- Interactive diagram: https://gitdiagram.com/ntgnguyen/check-phat-nguoi
- Repository: https://github.com/ntgnguyen/check-phat-nguoi

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Core Components:
- Configuration Management System
- Data Retrieval System
- Notification System
- Context Management
- Type System

b) External Integrations:
- Telegram API
- Traffic Violation Data Source

##### Component Relationships

- Config Reader → All Components (configuration flow)
- Data Retrieval → Context Management (violation data flow)
- Context Management → Notification System (processed data flow)
- Notification System → External Services (output flow)

##### Specific Implementation Details

a) Configuration System:
- Config file loading
- Model validation flow
- Notification engine configuration

b) Data Retrieval System:
- Base engine interface
- Specific implementation for traffic violations
- Data transformation flow

c) Notification System:
- Base notification engine
- Telegram-specific implementation
- Markdown message formatting

##### Additional Elements

Include:
- Error handling flows
- Configuration validation paths
- Data transformation pipelines
- Singleton patterns where used

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External["External Services"]
        TG[Telegram API]:::external
        VS["Traffic Violation Source"]:::external
    end

    subgraph Core["Core Components"]
        subgraph Config["Configuration Management"]
            CR["Config Reader"]:::config
            CM["Config Models"]:::config
            SD["Schema Definition"]:::config
        end

        subgraph DataRetrieval["Data Retrieval System"]
            BE["Base Engine"]:::core
            IE["Implementation Engine"]:::core
            MI["Main Interface"]:::core
        end

        subgraph Notify["Notification System"]
            NB["Base Engine"]:::core
            TI["Telegram Implementation"]:::core
            MF["Message Formatting"]:::core
            NH["Notification Handler"]:::core
        end

        subgraph Context["Context Management"]
            PC["Plates Context"]:::core
            CTM["Context Models"]:::core
        end

        subgraph Types["Type System"]
            AT["API Types"]:::types
            VT["Vehicle Types"]:::types
            LT["Log Level Types"]:::types
        end

        subgraph Support["Supporting Systems"]
            CO["Constants"]:::utility
            UT["Utilities"]:::utility
            SP["Singleton Pattern"]:::utility
            LS["Logger Setup"]:::utility
        end
    end

    %% Relationships
    CR --> BE
    CR --> NB
    BE --> IE
    IE --> MI
    MI --> PC
    PC --> CTM
    CTM --> NH
    NB --> TI
    TI --> MF
    MF --> NH
    NH --> TG
    IE --> VS

    %% Click Events
    click CR "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/src/check_phat_nguoi/config/config_reader.py"
    click CM "https://github.com/NTGNguyen/check-phat-nguoi/tree/main/src/check_phat_nguoi/config/models/"
    click SD "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/schemas/config.json"
    click BE "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/src/check_phat_nguoi/get_data/engines/base.py"
    click IE "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/src/check_phat_nguoi/get_data/engines/check_phat_nguoi.py"
    click MI "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/src/check_phat_nguoi/get_data/get_data.py"
    click NB "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/src/check_phat_nguoi/notify/engines/base.py"
    click TI "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/src/check_phat_nguoi/notify/engines/telegram.py"
    click MF "https://github.com/NTGNguyen/check-phat-nguoi/tree/main/src/check_phat_nguoi/notify/markdown_message/"
    click NH "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/src/check_phat_nguoi/notify/send_notifications.py"
    click PC "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/src/check_phat_nguoi/context/plates/context.py"
    click CTM "https://github.com/NTGNguyen/check-phat-nguoi/tree/main/src/check_phat_nguoi/context/plates/models/"
    click AT "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/src/check_phat_nguoi/types/api.py"
    click VT "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/src/check_phat_nguoi/types/vehicle_type.py"
    click LT "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/src/check_phat_nguoi/types/log_level.py"
    click CO "https://github.com/NTGNguyen/check-phat-nguoi/tree/main/src/check_phat_nguoi/constants/"
    click UT "https://github.com/NTGNguyen/check-phat-nguoi/tree/main/src/check_phat_nguoi/utils/"
    click SP "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/src/check_phat_nguoi/utils/singleton.py"
    click LS "https://github.com/NTGNguyen/check-phat-nguoi/blob/main/src/check_phat_nguoi/utils/setup_logger.py"

    %% Styles
    classDef external fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef config fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef types fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef utility fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["External Service"]:::external
        L2["Core Component"]:::core
        L3["Configuration"]:::config
        L4["Types"]:::types
        L5["Utility"]:::utility
    end
```
