# nappa85/symbols architecture

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

## Overview

##### Main Components

a) Core Components:
- Proc Macro Engine (Central Component)
- Database Connection Layer
- Code Generation Module
- Cache System
- Model Definition Layer

b) Data Flow Components:
- Input Processing (Attribute Macros)
- Database Query System
- Enum Generation
- Method Generation
- Cache Management

**┌─ Development Time ─────────────────────────────────────┐**

- ┌─ Proc Macro Engine ──────────────────────────────┐  │

- ┌─ Input Processing ─┐    ┌─ Code Generation ┐ │  │
- Attribute Parser │ -> │ - Enum Builder   │ │  │
- Type Resolution  │    │ - Method Builder │ │  │
- ┬─┘    └────────┬────────┘ │  │

- ┌─ Cache System ─┐ │    ┌─ Database Layer ┐  │  │
- Temp Storage │<┼--->│ - Query Engine │  │  │
- Cache Files  │      │ - Connection   │  │  │
- ┘       └───────────────┘  │  │

- ┘  │

- ┘

**┌─ Runtime ──────────────────────────────────────────┐**

- ┌─ Generated Code ────────────────────────────┐   │

- ┌─ Enum Types ─┐    ┌─ Generated Methods ┐│   │
- Variants   │    │ - Field Accessors  ││   │
- Converters │    │ - Constructors     ││   │
- ┘    └──────────────────┘  │   │

- ┘   │

- ┘

##### Key Relationships

- Attribute Processing → Database Queries
- Database Queries ↔ Cache System
- Code Generation → Output Enum/Methods
- Type Resolution → Method Generation

##### Important Details

a) Input Flow:
- Attribute macro parameters (#[example::example(...)])
- Table definitions
- Type mappings

b) Processing Flow:
- Cache checking/updating
- Database query execution
- Code generation steps

c) Output Flow:
- Generated enum variants
- Generated methods (const fn)
- Type conversions

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Development["Development Time"]
        subgraph ProcMacro["Proc Macro Engine"]
            InputProc["Input Processing"]
            CodeGen["Code Generation"]
            TypeRes["Type Resolution"]
            AttrParser["Attribute Parser"]
            
            InputProc --> CodeGen
            TypeRes --> CodeGen
            AttrParser --> InputProc
        end

        subgraph DataLayer["Data & Cache Layer"]
            DB[("Database Layer")]
            Cache["Cache System"]
            TempStorage["Temporary Storage"]
            
            DB <--> Cache
            Cache --> TempStorage
        end

        InputProc <--> DB
        CodeGen --> GenCode
    end

    subgraph Runtime["Runtime Environment"]
        subgraph GenCode["Generated Code"]
            EnumTypes["Enum Types"]
            Methods["Generated Methods"]
            
            EnumTypes --> Methods
        end
    end

    %% Component Styles
    classDef core fill:#2374ab,stroke:#2374ab,color:#fff
    classDef db fill:#48a9a6,stroke:#48a9a6,color:#fff
    classDef cache fill:#e4cc37,stroke:#e4cc37,color:#000
    classDef generated fill:#d4734f,stroke:#d4734f,color:#fff
    classDef container fill:none,stroke:#666,stroke-dasharray: 5 5

    %% Apply styles
    class ProcMacro,InputProc,CodeGen,TypeRes,AttrParser core
    class DB,DataLayer db
    class Cache,TempStorage cache
    class GenCode,EnumTypes,Methods generated
    class Development,Runtime container

    %% Click events
    click ProcMacro "https://github.com/nappa85/symbols/blob/master/symbols/src/lib.rs"
    click DB "https://github.com/nappa85/symbols/blob/master/example/fixtures/mariadb/schema.sql"
    click GenCode "https://github.com/nappa85/symbols/blob/master/example/src/model.rs"
    click DataLayer "https://github.com/nappa85/symbols/blob/master/example/docker-compose.yaml"
    click Runtime "https://github.com/nappa85/symbols/blob/master/example/src/lib.rs"
    click Methods "https://github.com/nappa85/symbols/blob/master/example/tests/it_works.rs"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2[("Database Components")]:::db
        L3["Cache Components"]:::cache
        L4["Generated Code"]:::generated
    end
```
