# miking-lang/miking architecture

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

## Overview

##### Main Components

a) Core Components:
- Boot System (/src/boot/)
- Standard Library (/stdlib/)
- Main Compiler Infrastructure (/src/main/)
- Target Language Backends

b) Language Processing Pipeline:
- Parser & Lexer
- Type Checker
- Symbolizer
- Evaluator
- Code Generator

**┌─────────────────────────────────────────────┐**
- Frontend Layer               │
- ┤
- Core Language Layer            │
- ┤
- Backend Targets Layer           │
- ┘

##### Key Components to Highlight

Frontend Layer:
- MLang (Language Definition System)
- Parser Combinators
- Boot Parser

Core Layer:
- MExpr (Core IR)
- Type System
- Evaluation Engine
- Symbol Table
- Pattern Matching

Backend Layer:
- OCaml Backend
- JavaScript Backend
- Python Backend
- CUDA Backend
- JVM Backend
- C Backend

##### Important Relationships

- How the boot system bootstraps the compiler
- How different backends interact with the core IR
- Demonstrate the relationship between the standard library and core components

##### Additional Elements

- A section for external dependencies
- Build system integration
- Test framework integration
- Extension points for language features

##### Implementation Details

- Annotations for critical architectural decisions
- Version information and documentation references

Remember to highlight the transformation pipeline from source languages through the core IR to various target platforms, as this is central to Miking's architecture.

This architectural representation will help developers understand how the different components interact and how to extend the system with new languages or backends.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer"
        MLang["MLang Language System"]
        ParserComb["Parser Combinators"]
        BootParser["Boot Parser"]:::parser
    end

    subgraph "Core Language Layer"
        MExpr["MExpr Core IR"]:::core
        TypeSystem["Type System"]:::core
        EvalEngine["Evaluation Engine"]:::core
        SymbolTable["Symbol Table"]:::core
        PatternMatch["Pattern Matching"]:::core
        Boot["Boot System"]:::core
        StdLib["Standard Library"]:::stdlib
    end

    subgraph "Backend Targets Layer"
        OCaml["OCaml Backend"]:::backend
        JavaScript["JavaScript Backend"]:::backend
        Python["Python Backend"]:::backend
        CUDA["CUDA Backend"]:::backend
        JVM["JVM Backend"]:::backend
        C["C Backend"]:::backend
    end

    %% Relationships
    MLang --> BootParser
    ParserComb --> BootParser
    BootParser --> MExpr
    MExpr --> TypeSystem
    MExpr --> EvalEngine
    MExpr --> SymbolTable
    MExpr --> PatternMatch
    Boot --> MExpr
    StdLib --> MExpr

    %% Backend relationships
    MExpr --> OCaml
    MExpr --> JavaScript
    MExpr --> Python
    MExpr --> CUDA
    MExpr --> JVM
    MExpr --> C

    %% Click events
    click Boot "https://github.com/miking-lang/miking/tree/develop/src/boot/"
    click StdLib "https://github.com/miking-lang/miking/tree/develop/stdlib/"
    click BootParser "https://github.com/miking-lang/miking/blob/develop/src/boot/lib/parser.mly"
    click EvalEngine "https://github.com/miking-lang/miking/blob/develop/src/boot/lib/eval.ml"
    click SymbolTable "https://github.com/miking-lang/miking/blob/develop/src/boot/lib/symbolize.ml"
    click OCaml "https://github.com/miking-lang/miking/tree/develop/stdlib/ocaml/"
    click JavaScript "https://github.com/miking-lang/miking/tree/develop/stdlib/javascript/"
    click Python "https://github.com/miking-lang/miking/tree/develop/stdlib/python/"
    click CUDA "https://github.com/miking-lang/miking/tree/develop/stdlib/cuda/"
    click JVM "https://github.com/miking-lang/miking/tree/develop/stdlib/jvm/"
    click C "https://github.com/miking-lang/miking/tree/develop/stdlib/c/"
    click MExpr "https://github.com/miking-lang/miking/blob/develop/src/boot/lib/mexpr.ml"
    click TypeSystem "https://github.com/miking-lang/miking/blob/develop/stdlib/mexpr/type.mc"
    click PatternMatch "https://github.com/miking-lang/miking/blob/develop/src/boot/lib/patterns.ml"

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef stdlib fill:#4CAF50,stroke:#2E7D32,color:white
    classDef backend fill:#FF9800,stroke:#EF6C00,color:white
    classDef parser fill:#9C27B0,stroke:#6A1B9A,color:white

    %% Legend
    subgraph Legend
        CoreComp["Core Components"]:::core
        StdLibComp["Standard Library"]:::stdlib
        BackendComp["Backend Targets"]:::backend
        ParserComp["Parser Components"]:::parser
    end
```
