# hac1es/nt106-doan architecture

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

- Interactive diagram: https://gitdiagram.com/hac1es/nt106-doan
- Repository: https://github.com/hac1es/nt106-doan

## Overview

##### Project Type and Purpose
- “Dreaw” is a distributed, full-stack, real-time collaborative drawing application with OCR.
- Key capabilities: real-time multi-user drawing via SignalR, user authentication, multiple rooms, and image-to-text (OCR) via a Python microservice.

##### Top-Level Components
- CoreApp (Windows Forms client)
- DoAnPaint (shared drawing UI library / standalone paint app)
- FlaskAPI (Python OCR service)
- Load Balancer (gateway/proxy)
- SignalRServer (clustered .NET Core servers)
- Database (SQL Server)
- Redis (SignalR backplane / caching)

##### Important Details to Capture
- The client must point to the Load Balancer’s URL (https://localhost:7002).
- Redis is critical for multi-instance SignalR messaging.
- The FlaskAPI OCR service is a separate process invoked over HTTP from the server.
- SQL Server holds user and room data.
- DoAnPaint is a shared library inside the client for drawing primitives and notifications.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Tier
    subgraph "Client Tier"
        direction TB
        CoreApp["CoreApp\n(.NET WinForms)"]:::frontend
        DoAnPaint["DoAnPaint\n(Shared Drawing Lib)"]:::frontend
    end

    %% API/Gateway Tier
    subgraph "API Gateway Tier"
        direction TB
        LoadBalancer["Load Balancer\n(.NET Core)"]:::gateway
    end

    %% Application Tier
    subgraph "Application Tier"
        direction TB
        SignalR1["SignalRServer Instance 1"]:::backend
        SignalR2["SignalRServer Instance 2"]:::backend
    end

    %% Microservice Tier
    subgraph "Microservice Tier"
        direction TB
        FlaskAPI["FlaskAPI OCR Service"]:::micro
    end

    %% Data Tier
    subgraph "Data Tier"
        direction TB
        SQLServer["SQL Server\n(User & Room Data)"]:::data
        Redis["Redis\n(SignalR Backplane)"]:::data
    end

    %% Connections
    CoreApp -->|HTTPS REST| LoadBalancer
    CoreApp -->|WebSocket/SignalR| LoadBalancer
    DoAnPaint -->|Embedded UI| CoreApp

    LoadBalancer -->|HTTP Proxy| SignalR1
    LoadBalancer -->|HTTP Proxy| SignalR2
    LoadBalancer -->|WS Proxy| SignalR1
    LoadBalancer -->|WS Proxy| SignalR2

    SignalR1 -->|Redis pub/sub| Redis
    SignalR2 -->|Redis pub/sub| Redis
    SignalR1 -->|SQL CRUD| SQLServer
    SignalR2 -->|SQL CRUD| SQLServer

    SignalR1 -->|HTTP OCR Request| FlaskAPI
    SignalR2 -->|HTTP OCR Request| FlaskAPI

    %% Click Events
    click CoreApp "https://github.com/hac1es/nt106-doan/blob/master/CoreApp/CoreApp.csproj"
    click DoAnPaint "https://github.com/hac1es/nt106-doan/blob/master/DoAnPaint/DrawingForm.csproj"
    click LoadBalancer "https://github.com/hac1es/nt106-doan/blob/master/Load Balancer/Load Balancer.csproj"
    click SignalR1 "https://github.com/hac1es/nt106-doan/blob/master/SignalRServer/Server1.csproj"
    click SignalR2 "https://github.com/hac1es/nt106-doan/blob/master/LoadBalancing/SignalRServer/Server2.csproj"
    click FlaskAPI "https://github.com/hac1es/nt106-doan/blob/master/FlaskAPI/app.py"
    click SQLServer "https://github.com/hac1es/nt106-doan/blob/master/Database.txt"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:1px;
    classDef gateway fill:#d4edda,stroke:#333,stroke-width:1px;
    classDef backend fill:#f8d7da,stroke:#333,stroke-width:1px;
    classDef micro fill:#e2e3e5,stroke:#333,stroke-width:1px;
    classDef data fill:#fff3cd,stroke:#333,stroke-width:1px;
```
