# danielxmoore/civet architecture

> Architecture diagram of the GitHub repository danielxmoore/civet, 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/danielxmoore/civet
- Repository: https://github.com/danielxmoore/civet

## Overview

##### Main Components Identification

The system should be divided into these primary components:

a. Core Compiler Components:
- Parser (source/parser/)
- Code Generator (source/generate.civet)
- Source Map Generator (source/sourcemap.civet)
- Configuration System (source/config.civet)

b. Integration Layer:
- Build Tool Plugins (source/unplugin/)
- Language Server (lsp/)
- CLI Interface (source/cli.civet)

c. Development Tools:
- Documentation Site (civet.dev/)
- Testing Framework (test/)
- Build Scripts (build/)

##### Component Relationships

**[Source Code] -> [Parser] -> [AST] -> [Code Generator] -> [TypeScript Output]**
- ^                        |
- v
- [Configuration]          [Source Maps]
- ^

- [Config Files (.civet)]

**[Integration Layer]**
- > [Build Plugins]
- > [Language Server]
- > [CLI Tools]

##### Specific Implementation Details

- Rectangles: Core processing components
- Hexagons: Integration points
- Blue: Core compiler components
- Green: Integration tools
- Orange: Development tools
- Gray: External systems

##### Key Architectural Patterns to Highlight

a. Plugin Architecture:
- How different build tools (Vite, esbuild, Webpack, etc.) connect through the unplugin system
- Demonstrate the plugin interface standardization

b. Language Server Protocol:
- LSP implementation connecting to various IDEs
- TypeScript service integration

c. Pipeline Processing:
- Compilation pipeline from source to output
- How source maps are generated in parallel

##### Integration Points

Critical integration points:
- Build tool plugins
- IDE integration via LSP
- Node.js loader system
- Test framework integration
- Documentation system

##### Development Workflow

A separate section showing:
- Build process
- Testing pipeline
- Documentation generation
- CI/CD integration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core["Core Compiler Pipeline"]
        direction TB
        SRC["Source Code"]
        PARSER["Parser"]:::core
        AST["Abstract Syntax Tree"]:::core
        CODEGEN["Code Generator"]:::core
        TSOUT["TypeScript Output"]
        SRCMAP["Source Map Generator"]:::core
        CONFIG["Configuration System"]:::core
        CIVETCFG["Config Files (.civet)"]
        
        SRC --> PARSER
        PARSER --> AST
        AST --> CODEGEN
        CODEGEN --> TSOUT
        CODEGEN --> SRCMAP
        CONFIG --> PARSER
        CIVETCFG --> CONFIG
    end

    subgraph Features["Language Features"]
        direction TB
        PATTERN["Pattern Matching"]:::feature
        PIPE["Pipe Operator"]:::feature
        JSX["JSX Enhancements"]:::feature
        TS["TypeScript Integration"]:::feature
    end

    subgraph Integration["Integration Layer"]
        direction TB
        PLUGINS["Build Tool Plugins"]:::integration
        LSP["Language Server"]:::integration
        CLI["CLI Interface"]:::integration
        
        subgraph BuildTools["Build Tools"]
            VITE["Vite"]:::external
            ESBUILD["esbuild"]:::external
            WEBPACK["Webpack"]:::external
        end
        
        PLUGINS --> BuildTools
    end

    subgraph DevTools["Development Tools"]
        direction TB
        DOCS["Documentation Site"]:::devtool
        TEST["Testing Framework"]:::devtool
        BUILD["Build Scripts"]:::devtool
    end

    Features --> PARSER
    Integration --> Core
    LSP --> TS
    
    %% Click Events
    click PARSER "https://github.com/DanielXMoore/Civet/tree/main/source/parser/"
    click CODEGEN "https://github.com/DanielXMoore/Civet/blob/main/source/generate.civet"
    click SRCMAP "https://github.com/DanielXMoore/Civet/blob/main/source/sourcemap.civet"
    click CONFIG "https://github.com/DanielXMoore/Civet/blob/main/source/config.civet"
    click PLUGINS "https://github.com/DanielXMoore/Civet/tree/main/source/unplugin/"
    click LSP "https://github.com/DanielXMoore/Civet/tree/main/lsp/"
    click CLI "https://github.com/DanielXMoore/Civet/blob/main/source/cli.civet"
    click DOCS "https://github.com/DanielXMoore/Civet/tree/main/civet.dev/"
    click TEST "https://github.com/DanielXMoore/Civet/tree/main/test/"
    click BUILD "https://github.com/DanielXMoore/Civet/tree/main/build/"
    click TS "https://github.com/DanielXMoore/Civet/blob/main/source/ts-diagnostic.civet"
    click PATTERN "https://github.com/DanielXMoore/Civet/blob/main/source/parser/pattern-matching.civet"
    click PIPE "https://github.com/DanielXMoore/Civet/blob/main/source/parser/pipe.civet"
    click LSP "https://github.com/DanielXMoore/Civet/blob/main/lsp/source/server.mts"

    %% Styling
    classDef core fill:#2374ab
    classDef feature fill:#457b9d
    classDef integration fill:#2a9d8f
    classDef external fill:#gray
    classDef devtool fill:#e9c46a
    
    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Language Features"]:::feature
        L3["Integration Tools"]:::integration
        L4["External Tools"]:::external
        L5["Development Tools"]:::devtool
    end
```
