# datacontract/datacontract-specification architecture

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

- Interactive diagram: https://gitdiagram.com/datacontract/datacontract-specification
- Repository: https://github.com/datacontract/datacontract-specification

## Overview

##### Main Components

a) Core Components:
- Data Contract Specification Engine
- Schema Validation Layer
- Data Contract Parser
- Server Type Handlers
- Quality Validation Engine
- Service Level Agreement (SLA) Monitor

b) Integration Components:
- CLI Interface
- JSON Schema Validator
- External Tool Integrations (Soda, Great Expectations)
- Version Management System

##### Relationships and Data Flow

- Input flow of YAML data contracts
- Schema validation process
- Server type resolution
- Quality checks execution
- Service level monitoring
- Integration with external tools

##### Architectural Pattern
Use a layered architecture pattern with:
- Interface Layer (CLI, API)
- Core Specification Layer
- Validation Layer
- Integration Layer
- Storage Layer

- Interface Layer                                        |

- CLI Tool     |  |  Web Editor      |  |  GPT Interface |  |  Schema Store      |  |

- Core Specification Layer                                    |

- Contract Parser  |  | Schema Validator |  | Version Manager|  | Extension Handler|    |

- Validation Layer                                         |

- Quality Checker  |  | SLA Monitor      |  | Data Validator |  | Lineage Tracker |    |

- Integration Layer                                         |

- Soda Engine    |  | Great Expect.    |  | Custom Engines |  | Server Adapters |    |

- Storage Layer                                           |

- Version Store   |  | Contract Repo    |  | Example Store |  | Schema Registry  |    |

##### Additional Elements
- Version management indicators
- External tool integration points
- Validation checkpoints
- Extension points for custom implementations

##### Important Details to Capture
- Support for multiple server types (BigQuery, S3, etc.)
- Quality validation mechanisms
- Service level monitoring points
- Schema validation process
- Version management system
- Extension mechanisms

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Define styles
    classDef interface fill:#FFA500,stroke:#333,stroke-width:2px
    classDef core fill:#3498DB,stroke:#333,stroke-width:2px
    classDef validation fill:#F1C40F,stroke:#333,stroke-width:2px
    classDef integration fill:#2ECC71,stroke:#333,stroke-width:2px
    classDef storage fill:#95A5A6,stroke:#333,stroke-width:2px

    %% Interface Layer
    subgraph InterfaceLayer["Interface Layer"]
        CLI["CLI Tool"]
        WebEditor["Web Editor"]:::interface
        GPT["GPT Interface"]
        SchemaStore["Schema Store"]
    end

    %% Core Layer
    subgraph CoreLayer["Core Specification Layer"]
        ContractParser["Contract Parser"]:::core
        SchemaValidator["Schema Validator"]:::core
        VersionManager["Version Manager"]:::core
        ExtHandler["Extension Handler"]:::core
    end

    %% Validation Layer
    subgraph ValidationLayer["Validation Layer"]
        QualityChecker["Quality Checker"]:::validation
        SLAMonitor["SLA Monitor"]:::validation
        DataValidator["Data Validator"]:::validation
        LineageTracker["Lineage Tracker"]:::validation
    end

    %% Integration Layer
    subgraph IntegrationLayer["Integration Layer"]
        SodaEngine["Soda Engine"]:::integration
        GreatExp["Great Expectations"]:::integration
        CustomEngines["Custom Engines"]:::integration
        ServerAdapters["Server Adapters"]:::integration
    end

    %% Storage Layer
    subgraph StorageLayer["Storage Layer"]
        VersionStore["Version Store"]:::storage
        ContractRepo["Contract Repository"]:::storage
        ExampleStore["Example Store"]:::storage
        SchemaRegistry["Schema Registry"]:::storage
    end

    %% Relationships
    InterfaceLayer --> CoreLayer
    CoreLayer --> ValidationLayer
    ValidationLayer --> IntegrationLayer
    IntegrationLayer --> StorageLayer

    %% Click events
    click WebEditor "https://github.com/datacontract/datacontract-specification/blob/main/_layouts/default.html"
    click SchemaValidator "https://github.com/datacontract/datacontract-specification/blob/main/datacontract.schema.json"
    click VersionManager "https://github.com/datacontract/datacontract-specification/tree/main/versions/"
    click ContractRepo "https://github.com/datacontract/datacontract-specification/tree/main/examples/"
    click ExampleStore "https://github.com/datacontract/datacontract-specification/tree/main/examples/"
    click VersionStore "https://github.com/datacontract/datacontract-specification/blob/main/versions/0.9.3/datacontract.schema.json"
    click SchemaRegistry "https://github.com/datacontract/datacontract-specification/blob/main/definition.schema.json"

    %% Legend
    subgraph Legend
        L1["Interface Components"]:::interface
        L2["Core Components"]:::core
        L3["Validation Components"]:::validation
        L4["Integration Components"]:::integration
        L5["Storage Components"]:::storage
    end
```
