# undb-io/undb architecture

> Architecture diagram of the GitHub repository undb-io/undb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/undb-io/undb
- Repository: https://github.com/undb-io/undb

## Overview

##### High-Level Architecture Components

a) Frontend Layer:
- SvelteKit-based web application (apps/frontend)
- Desktop application (apps/desktop) using Tauri
- UI components for different views (grid, calendar, kanban, gallery)

b) Backend Layer:
- Core backend service (apps/backend)
- GraphQL API
- RESTful OpenAPI endpoints
- Authentication/Authorization system

c) Database Layer:
- SQLite database
- Storage system for attachments
- Migration system (drizzle)

##### Core Service Components

a) Core Modules (packages/):
- Table management system
- Record management
- Form builder
- View system (grid, calendar, kanban, etc.)
- Formula engine
- Webhook system
- Audit system
- Authorization system

b) Supporting Services:
- Real-time updates system
- Template system
- Storage service
- Mail service
- Webhook service

##### Key Interactions

- Data flow between frontend and backend
- Authentication flow
- Real-time update patterns
- Storage operations
- External integrations (webhooks, email)

##### Detailed Component Breakdown

Create subsections for:
a) Table System:
- Schema management
- Field types
- Relations
- Views configuration

b) Record System:
- CRUD operations
- Filtering
- Sorting
- Aggregation

c) Authorization:
- User management
- Space management
- Role-based access control
- API tokens

##### Technical Implementation Details

Specific technologies:
- Bun runtime
- SvelteKit
- GraphQL
- SQLite
- Drizzle ORM
- Tauri (desktop)

##### Deployment Options

Different deployment scenarios:
- Single binary deployment
- Docker container deployment
- Cloud deployment
- Local development setup

Use the following visual elements:

##### Data flow patterns

This system design should reflect undb's capability to scale from a simple local deployment to a full cloud service while maintaining its core functionality and security features.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        WA["Web App (SvelteKit)"]
        DA["Desktop App (Tauri)"]
        UI["UI Components"]
        WA --> UI
        DA --> UI
    end

    subgraph Backend
        BS["Backend Service"]
        GQL["GraphQL API"]
        AUTH["Auth System"]
        BS --> GQL
        BS --> AUTH
    end

    subgraph CoreModules
        TM["Table Management"]
        RM["Record Management"]
        FB["Form Builder"]
        VS["View System"]
        FE["Formula Engine"]
        WS["Webhook System"]
        AS["Audit System"]
        AZ["Authorization System"]
    end

    subgraph SupportingServices
        RT["Real-time Updates"]
        TS["Template System"]
        SS["Storage Service"]
        MS["Mail Service"]
    end

    subgraph Database
        DB[(SQLite)]
        ST[(Storage)]
    end

    subgraph AdditionalCore
        SM["Space Management"]
        DS["Dashboard System"]
        CS["Command System"]
        QS["Query System"]
    end

    Frontend --> Backend
    Backend --> CoreModules
    Backend --> SupportingServices
    CoreModules --> Database
    SupportingServices --> Database

    %% Component Mappings
    click WA "https://github.com/undb-io/undb/tree/develop/apps/frontend/"
    click DA "https://github.com/undb-io/undb/tree/develop/apps/desktop/"
    click UI "https://github.com/undb-io/undb/tree/develop/apps/frontend/src/lib/components/"
    click BS "https://github.com/undb-io/undb/tree/develop/apps/backend/"
    click GQL "https://github.com/undb-io/undb/tree/develop/apps/backend/src/modules/openapi/"
    click AUTH "https://github.com/undb-io/undb/tree/develop/apps/backend/src/modules/auth/"
    click TM "https://github.com/undb-io/undb/tree/develop/packages/table/"
    click RM "https://github.com/undb-io/undb/tree/develop/packages/table/src/modules/records/"
    click FB "https://github.com/undb-io/undb/tree/develop/packages/table/src/modules/forms/"
    click VS "https://github.com/undb-io/undb/tree/develop/packages/table/src/modules/views/"
    click FE "https://github.com/undb-io/undb/tree/develop/packages/formula/"
    click WS "https://github.com/undb-io/undb/tree/develop/packages/webhook/"
    click AS "https://github.com/undb-io/undb/tree/develop/packages/audit/"
    click AZ "https://github.com/undb-io/undb/tree/develop/packages/authz/"
    click RT "https://github.com/undb-io/undb/tree/develop/packages/realtime/"
    click TS "https://github.com/undb-io/undb/tree/develop/packages/template/"
    click SS "https://github.com/undb-io/undb/tree/develop/packages/table/src/modules/storage/"
    click MS "https://github.com/undb-io/undb/tree/develop/packages/mail/"
    click SM "https://github.com/undb-io/undb/tree/develop/packages/space/"
    click DS "https://github.com/undb-io/undb/tree/develop/packages/dashboard/"
    click CS "https://github.com/undb-io/undb/tree/develop/packages/commands/"
    click QS "https://github.com/undb-io/undb/tree/develop/packages/queries/"

    classDef frontend fill:#42b883,stroke:#333,stroke-width:2px
    classDef backend fill:#1e88e5,stroke:#333,stroke-width:2px
    classDef core fill:#ff7043,stroke:#333,stroke-width:2px
    classDef support fill:#7e57c2,stroke:#333,stroke-width:2px
    classDef database fill:#fdd835,stroke:#333,stroke-width:2px
    classDef additional fill:#26a69a,stroke:#333,stroke-width:2px

    class WA,DA,UI frontend
    class BS,GQL,AUTH backend
    class TM,RM,FB,VS,FE,WS,AS,AZ core
    class RT,TS,SS,MS support
    class DB,ST database
    class SM,DS,CS,QS additional

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        B[Backend]:::backend
        C[Core Modules]:::core
        S[Support Services]:::support
        D[(Database)]:::database
        A[Additional Core]:::additional
    end
```
