# vanh1112/drawdb architecture

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

- Interactive diagram: https://gitdiagram.com/vanh1112/drawdb
- Repository: https://github.com/vanh1112/drawdb

## Overview

##### Main Components
- Frontend Application: The project’s heart lies in its frontend. Core areas include:
- A UI layer built with React (e.g., components such as EditorCanvas, EditorHeader, EditorSidePanel, LexicalEditor, Navbar, etc.) that render different parts of the DBER editor.
- Internationalization (i18n) integration with locale files under src/i18n, ensuring multi-language support.
- Utility modules (in src/utils) for tasks like exporting and importing SQL (including database-specific implementations) and method helpers for validations and calculations.
- Backend/Server Integration:
- While the project is mostly client-side, the README mentions configuring a separate server (drawdb-server) for survey and bug report forms. Illustrate this as an external service that the frontend communicates with (possibly via API calls).
- Build & Deployment:
- Build configurations, Dockerfile, and compose.yml. This indicates containerization and CI/CD integration (with GitHub workflows) to streamline development and production deployment.

##### Architectural Patterns and Design Principles
- Component-Based Architecture:
- The system is built using modular React components. Each UI feature is separated into self-contained units (e.g., different editor panels, modals, side sheets) for clear separation of concerns.
- State Management:
- Extensibility & Separation of Concerns:
- The clear separation of components (for the canvas, modals, side panels, etc.), utility functions (SQL import/export, schema validations), and configurations (i18n, tailwind, Vite config) demonstrate a well-decoupled system.
- Containerization and CI/CD:
- The presence of Dockerfiles and GitHub workflows indicates a modern development workflow and deployment practice.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Application Subgraph
    subgraph "Frontend Application"
        FEApp["Frontend Application"]:::app
        
        subgraph "UI Components"
            EditorCanvas["EditorCanvas"]:::ui
            EditorHeader["EditorHeader"]:::ui
            EditorSidePanel["EditorSidePanel"]:::ui
            LexicalEditor["LexicalEditor"]:::ui
        end
        
        subgraph "State & Utilities"
            StateManagement["React Context Providers"]:::state
            Internationalization["Internationalization (i18n)"]:::config
            SQLExport["SQL Export Utility"]:::util
            SQLImport["SQL Import Utility"]:::util
        end
    end

    %% External Backend Integration
    ExternalBackend["External Backend (drawdb-server)"]:::external

    %% Build & Deployment Subgraph
    subgraph "Build & Deployment"
        DockerfileNode["Dockerfile"]:::build
        ComposeNode["compose.yml"]:::build
        GitHubWorkflows["CI/CD (.github/workflows)"]:::build
        ViteConfig["vite.config.js"]:::build
    end

    %% Connections within Frontend Application
    EditorCanvas -->|"updates"| StateManagement
    EditorHeader -->|"interacts"| StateManagement
    EditorSidePanel -->|"modifies"| StateManagement
    LexicalEditor -->|"integrated_with"| EditorCanvas

    EditorHeader -->|"triggers_SQL_export"| SQLExport
    EditorHeader -->|"triggers_SQL_import"| SQLImport

    Internationalization ---|"supports"| EditorHeader
    Internationalization ---|"supports"| EditorSidePanel

    %% Connections to External Backend
    EditorHeader -->|"reports_issues"| ExternalBackend
    EditorSidePanel -->|"sends_surveys"| ExternalBackend

    %% Build & Deployment deploying the Frontend Application
    DockerfileNode -->|"containers"| FEApp
    ComposeNode -->|"orchestrates"| FEApp
    GitHubWorkflows -->|"CI_CD_builds"| FEApp
    ViteConfig -->|"builds_SPA"| FEApp

    %% Styling for different components
    classDef ui fill:#d0e6ff,stroke:#1f78b4,stroke-width:2px;
    classDef state fill:#ffe6e6,stroke:#d62728,stroke-width:2px;
    classDef config fill:#e6ffe6,stroke:#2ca02c,stroke-width:2px;
    classDef util fill:#fff7bc,stroke:#ff7f0e,stroke-width:2px;
    classDef external fill:#f0e6ff,stroke:#9467bd,stroke-width:2px;
    classDef build fill:#e6f7ff,stroke:#17becf,stroke-width:2px;
    classDef app fill:#fff0e6,stroke:#8c564b,stroke-width:2px;

    %% Click Events for Frontend Components
    click EditorCanvas "https://github.com/vanh1112/drawdb/tree/main/src/components/EditorCanvas"
    click EditorHeader "https://github.com/vanh1112/drawdb/tree/main/src/components/EditorHeader"
    click EditorSidePanel "https://github.com/vanh1112/drawdb/tree/main/src/components/EditorSidePanel"
    click LexicalEditor "https://github.com/vanh1112/drawdb/tree/main/src/components/LexicalEditor"
    click StateManagement "https://github.com/vanh1112/drawdb/tree/main/src/context"
    click Internationalization "https://github.com/vanh1112/drawdb/tree/main/src/i18n"
    click SQLExport "https://github.com/vanh1112/drawdb/tree/main/src/utils/exportSQL"
    click SQLImport "https://github.com/vanh1112/drawdb/tree/main/src/utils/importSQL"

    %% Click Events for Build & Deployment Configurations
    click DockerfileNode "https://github.com/vanh1112/drawdb/tree/main/Dockerfile"
    click ComposeNode "https://github.com/vanh1112/drawdb/blob/main/compose.yml"
    click GitHubWorkflows "https://github.com/vanh1112/drawdb/tree/main/.github/workflows"
    click ViteConfig "https://github.com/vanh1112/drawdb/blob/main/vite.config.js"
```
