# renatomassaro/feebdb architecture

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

## Overview

##### Main Components (Top Level)

a) Core System Components:
- Database Manager (Central Coordinator)
- Repository Manager
- Migration System
- Query System
- Type System

b) External Interface:
- Mix Tasks (CLI Interface)
- File System Adapter

##### Database Manager Layer
- To Repository Manager
- Local State Management
- Connection to SQLite instances

##### Repository Management
- Registry
- Supervisor
- Repo Entry Handler
- Dynamic creation of database instances

##### Data Flow Layer
- Schema Management
- Query Processing
- Type System
- Migration System

Use these specific visualization guidelines:

##### Actor Model Integration
- Supervisor hierarchy
- Demonstrate message passing between components

##### Plugin System
- Custom types
- Query builders
- Migration handlers

##### State Management
- Local state handling
- Repository registry

Specific Implementation Details:

**Feeb.DB**
- Application
- Boot
- LocalState
- Migrator
- Query
- Dynamic
- Binding
- Repo
- Manager
- Schema

##### Multi-tenant nature
- How each client gets its own SQLite database
- Isolation between instances

##### Lifecycle
- Database creation
- Migration application
- Query execution
- Type conversion

##### Test infrastructure
- How each test gets its own database instance
- Demonstrate the clean slate approach

##### Modular nature
- Type system extensibility
- Query building flexibility
- Migration management

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Components
    DB[Database Manager]:::core
    RM[Repository Manager]:::repo
    MS[Migration System]:::migration
    QS[Query System]:::query
    TS[Type System]:::type
    EI[External Interfaces]:::external

    %% Database Manager Subcomponents
    subgraph DBManager
        DB --> |Manages| LSM[Local State Manager]:::core
        DB --> |Coordinates| Boot[Boot System]:::core
        DB --> |Initializes| App[Application]:::core
    end

    %% Repository Manager Subcomponents
    subgraph RepoManager
        RM --> Reg[Registry]:::repo
        RM --> Sup[Supervisor]:::repo
        RM --> REH[Repo Entry Handler]:::repo
        Sup --> |Supervises| SQLite[(SQLite Instances)]:::database
    end

    %% Migration System Subcomponents
    subgraph MigrationSystem
        MS --> MP[Migration Parser]:::migration
        MS --> MM[Migration Metadata]:::migration
    end

    %% Query System Subcomponents
    subgraph QuerySystem
        QS --> QB[Query Builder]:::query
        QS --> QD[Dynamic Queries]:::query
        QS --> QBind[Query Binding]:::query
    end

    %% Type System Subcomponents
    subgraph TypeSystem
        TS --> TB[Type Behaviour]:::type
        TS --> Types[Built-in Types]:::type
        Types --> |Includes| BasicTypes[String/Integer/Boolean]:::type
        Types --> |Includes| ComplexTypes[Map/List/Enum]:::type
    end

    %% External Interface Components
    subgraph ExternalInterfaces
        EI --> MT[Mix Tasks]:::external
        EI --> FSA[File System Adapter]:::external
    end

    %% Main Component Relationships
    DB --> RM
    DB --> MS
    DB --> QS
    DB --> TS
    DB --> EI

    %% Style Definitions
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef repo fill:#2ecc71,stroke:#27ae60,color:white
    classDef migration fill:#f1c40f,stroke:#f39c12,color:black
    classDef query fill:#e67e22,stroke:#d35400,color:white
    classDef type fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef database fill:#34495e,stroke:#2c3e50,color:white

    %% Click Events
    click DB "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db.ex"
    click App "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/application.ex"
    click Boot "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/boot.ex"
    click LSM "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/local_state.ex"
    click RM "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/repo/manager.ex"
    click Reg "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/repo/manager/registry.ex"
    click REH "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/repo/manager/repo_entry.ex"
    click Sup "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/repo/manager/supervisor.ex"
    click MS "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/migrator.ex"
    click MP "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/migrator/parser.ex"
    click MM "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/migrator/metadata.ex"
    click QS "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/query.ex"
    click QB "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/query/dynamic/builder.ex"
    click QBind "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/query/binding.ex"
    click QD "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/query/dynamic.ex"
    click TS "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/type.ex"
    click TB "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/db/type/behaviour.ex"
    click FSA "https://github.com/renatomassaro/feebdb/blob/main/lib/feeb/adapters/file.ex"
    click MT "https://github.com/renatomassaro/feebdb/tree/main/lib/mix/task"
```
