# lerocha/chinook-database architecture

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

- Interactive diagram: https://gitdiagram.com/lerocha/chinook-database
- Repository: https://github.com/lerocha/chinook-database

## Overview

##### Project type and purpose
- This is an open-source code-generation library (ChinookDatabase) plus a test harness (ChinookDatabase.Test).
- Its purpose is to generate a sample “Chinook” database schema and data scripts for multiple SQL vendors (SQL Server, Oracle, MySQL, etc.) via T4 templates, and to validate those scripts against live database instances.

##### File structure
- Top-level solutions:
- ChinookDatabase (class library, .NET 8)
- ChinookDatabase.Test (test project with fixtures for each vendor)
- docker-compose.yml (brings up containerized DB servers for integration tests)
- Key directories in ChinookDatabase:
- DataModel: C# POCOs representing tables (Album, Artist, Customer, etc.)
- DataSources:
– ChinookDataSet.xsd / .json: dataset definition + sample data
– T4 templates (.tt / .ttinclude)
– Pre-generated SQL scripts (.sql, .sqlite) and batch files to seed databases
- DdlStrategies: IDdlStrategy + concrete classes per vendor (SqlServerStrategy, OracleStrategy, etc.) implementing the Strategy pattern for DDL generation
- Utilities: helpers for DataSet manipulation
- _T4Templates: central .tt files orchestrating codegen
- ChinookDatabase.Test:
- Fixtures for each database type that use the generated scripts to create a live DB and run validation queries
- appsettings.test.json: connection strings

##### README for additional insights
- Emphasizes T4-based autogeneration of SQL scripts from a single model/data source.
- Requires Visual Studio T4 engine + .NET 8.
- Scripts are intended for demos and ORM testing.
- Docker Compose file can bring up all supported DB servers for CI integration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build-Time"
        VS["Visual Studio / dotnet build"]:::external
        subgraph "Code Generation Module"
            T4E["T4 Engine"]:::codeModule
            T4T["T4 Templates"]:::codeModule
            DM["DataModel"]:::codeModule
            DSrc["DataSources"]:::dataInput
            Ddl["DdlStrategies"]:::codeModule
            Util["Utilities"]:::codeModule
        end
        VS -->|triggers| T4E
        DSrc -->|provides schema/data| T4E
        DM -->|provides model| T4E
        Ddl -->|provides strategies| T4E
        Util -->|assists| T4E
        T4T -->|orchestrates| T4E
        T4E -->|generates| Out["Generated SQL scripts & .bat"]:::output
    end

    subgraph "Test-Time"
        Out -->|input scripts| TH["Test Harness"]:::test
        TC["appsettings.test.json"]:::test --> TH
        subgraph "Dockerized DBs"
            DB["DB Containers"]:::external
        end
        TH -->|runs against| DB
        DC["docker-compose.yml"]:::external --> DB
    end

    classDef codeModule fill:#cce5ff,stroke:#004085
    classDef dataInput fill:#d4edda,stroke:#155724
    classDef output fill:#ffeeba,stroke:#856404
    classDef external fill:#e2e3e5,stroke:#6c757d
    classDef test fill:#f5c6cb,stroke:#721c24

    click DM "https://github.com/lerocha/chinook-database/tree/master/ChinookDatabase/DataModel/"
    click DSrc "https://github.com/lerocha/chinook-database/tree/master/ChinookDatabase/DataSources/"
    click Ddl "https://github.com/lerocha/chinook-database/tree/master/ChinookDatabase/DdlStrategies/"
    click Util "https://github.com/lerocha/chinook-database/blob/master/ChinookDatabase/Utilities/DataSetHelper.cs"
    click T4T "https://github.com/lerocha/chinook-database/blob/master/ChinookDatabase/_T4Templates/Chinook.tt"
    click T4T "https://github.com/lerocha/chinook-database/blob/master/ChinookDatabase/_T4Templates/Chinook.ttinclude"
    click T4T "https://github.com/lerocha/chinook-database/blob/master/ChinookDatabase/_T4Templates/Manager.ttinclude"
    click Out "https://github.com/lerocha/chinook-database/tree/master/ChinookDatabase/DataSources/"
    click TH "https://github.com/lerocha/chinook-database/tree/master/ChinookDatabase.Test/DatabaseTests/"
    click TC "https://github.com/lerocha/chinook-database/blob/master/ChinookDatabase.Test/appsettings.test.json"
    click DC "https://github.com/lerocha/chinook-database/blob/master/docker-compose.yml"
    click VS "https://github.com/lerocha/chinook-database/blob/master/ChinookDatabase.sln"
    click VS "https://github.com/lerocha/chinook-database/blob/master/ChinookDatabase/ChinookDatabase.csproj"
    click VS "https://github.com/lerocha/chinook-database/blob/master/ChinookDatabase.Test/ChinookDatabase.Test.csproj"
```
