# dataf3l/dbdiff architecture

> Architecture diagram of the GitHub repository dataf3l/dbdiff, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dataf3l/dbdiff
- Repository: https://github.com/dataf3l/dbdiff

## Overview

##### Project Type Analysis
This appears to be a web-based tool with both frontend and backend components, written in Go with a JavaScript frontend. The project seems to be focused on database comparison functionality.

##### Main Components

A. Frontend Layer:
- HTML/CSS Static Assets (from /public directory)
- JavaScript Client (db_diff.js)
- Configuration Interface (config.js)

B. Backend Layer:
- Go Server (db_diff.go)
- Configuration Handler
- Database Connection Management

C. External Components:
- Source Database Connection
- Target Database Connection

- [Frontend Tier]
- [Backend Tier]
- [Database Tier]

##### Detailed Component Breakdown

Frontend Tier (Blue):
**┌─────────────────────────┐**
- Static Assets           │
- index.html          │
- style.css           │

- JavaScript Client      │
- db_diff.js          │
- ┘

Backend Tier (Green):
**┌─────────────────────────┐**
- Go Server              │
- Database Comparator │
- API Endpoints       │
- Config Manager      │
- ┘

Configuration (Gray):
**┌─────────────────────────┐**
- Configuration          │
- config.js           │
- ┘

Database Tier (Orange):
**┌─────────────────────────┐**
- Source DB    Target DB │
- ┘

##### Important Elements to Highlight

- Configuration Flow: Show how config.js influences both frontend and backend
- API Communication: Illustrate the HTTP/WebSocket communication between frontend and backend
- Database Connections: Show how the backend connects to both source and target databases
- Error Handling Flow: Include error propagation paths

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#e67e22,stroke:#d35400,color:white
    classDef config fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef build fill:#9b59b6,stroke:#8e44ad,color:white

    %% Frontend Layer
    subgraph Frontend
        StaticHTML["Static HTML"]:::frontend
        StaticCSS["Static CSS"]:::frontend
        JSClient["JavaScript Client"]:::frontend
    end

    %% Backend Layer
    subgraph Backend
        GoServer["Go Server"]:::backend
        DBComparator["Database Comparator"]:::backend
        APIEndpoints["API Endpoints"]:::backend
        ConfigManager["Configuration Manager"]:::backend
    end

    %% Configuration Layer
    subgraph Configuration
        ConfigJS["Configuration Interface"]:::config
        EnvConfig["Environment Config"]:::config
    end

    %% Database Layer
    subgraph Databases
        SourceDB[(Source Database)]:::database
        TargetDB[(Target Database)]:::database
    end

    %% Build System
    subgraph BuildSystem
        UnixBuild["Unix Build Script"]:::build
        WinBuild["Windows Build Script"]:::build
        DevEnv["Development Environment"]:::build
    end

    %% Relationships
    JSClient --> APIEndpoints
    StaticHTML --> JSClient
    StaticCSS --> StaticHTML
    APIEndpoints --> DBComparator
    DBComparator --> SourceDB
    DBComparator --> TargetDB
    ConfigJS --> ConfigManager
    ConfigManager --> DBComparator
    EnvConfig --> ConfigManager
    DevEnv --> GoServer
    UnixBuild --> GoServer
    WinBuild --> GoServer

    %% Click events for component mapping
    click StaticHTML "https://github.com/dataf3l/dbdiff/blob/master/public/index.html"
    click StaticCSS "https://github.com/dataf3l/dbdiff/blob/master/public/css/style.css"
    click JSClient "https://github.com/dataf3l/dbdiff/blob/master/public/js/db_diff.js"
    click GoServer "https://github.com/dataf3l/dbdiff/blob/master/db_diff.go"
    click ConfigJS "https://github.com/dataf3l/dbdiff/blob/master/private_sample/config.js"
    click DevEnv "https://github.com/dataf3l/dbdiff/blob/master/run_in_development.sh"
    click UnixBuild "https://github.com/dataf3l/dbdiff/blob/master/make.sh"
    click WinBuild "https://github.com/dataf3l/dbdiff/blob/master/mkwin.sh"
    click EnvConfig "https://github.com/dataf3l/dbdiff/blob/master/env.sh.sample"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        Backend_L["Backend Component"]:::backend
        Database_L["Database"]:::database
        Config_L["Configuration"]:::config
        Build_L["Build System"]:::build
    end
```
