# mdhruvil/deplit architecture

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

- Interactive diagram: https://gitdiagram.com/mdhruvil/deplit
- Repository: https://github.com/mdhruvil/deplit

## Overview

##### Project Type and Purpose
- It’s a multi-app system that appears to provide both backend and frontend services along with supporting utilities for deployment and management.
- The apps folder contains several key services – an API server, a builder service, a control plane (likely a user interface), a sidecar, and a spawner – which together suggest that the system orchestrates deployments or project management.
- The existence of “bruno” scripts (with .bru extensions) for creating, updating, and deleting deployments and projects, plus the “api/src/routers” for deployments and projects, reinforces that the project is aimed at managing or deploying projects/environments, possibly through a command-line or web dashboard interface.
- Shared “packages” for eslint, TypeScript, and UI indicate shared internal libraries that provide consistency and reusable components across apps.

##### Main Components and Their Roles
- API Service (apps/api):
- Serves as the primary backend.
- Contains routers for "deployments" and "projects", middleware (auth-middleware.ts), and a database layer (db/queries, db/schema).
- Manages schema migrations (drizzle) with SQL scripts.

- Builder Service (apps/builder):
- Likely responsible for orchestrating builds, handling git operations, post-processing, and upload tasks.
- Acts as a background or command-line service to trigger build processes.

- Control Plane (apps/controlplane):
- A frontend application (React/TypeScript, using Vite) that provides a web UI.
- Communicates with the API, includes UI components (from packages/ui) and custom libraries for authentication and utilities.

- Sidecar Service (apps/sidecar):
- A lightweight service (with its own Dockerfile and configurations) that might perform auxiliary tasks or add extra functionality alongside other services.

- Spawner Service (apps/spawner):
- Uses Azure Functions-style conventions (host.json, .funcignore) to run serverless functions.
- Contains a “Spawner.ts” function which implies a role in dynamic task execution or service instantiation.

- Bruno Scripts (bruno directory):
- Contains scripts with a custom “.bru” extension that handle deployment and project operations.
- Likely serve as CLI tools or configuration scripts for interacting with the API or deployment system.

- Shared Packages (packages folder):
- ESLint, TypeScript, and UI packages providing consistent configurations and reusable components across apps.

##### Relationships and Interactions
- The Control Plane (frontend UI) interacts with the API to fetch and update data regarding deployments and projects.
- The API service connects to a database (as indicated by SQL migrations and schema definitions) and exposes REST endpoints (via routers) which the Control Plane consumes.
- The Builder service might be triggered (perhaps via CI/CD pipelines – see .github/workflows) to build, process, and deploy changes to the system.
- The Sidecar could be used for monitoring or extending functionality alongside the main API or Builder.
- The Spawner, as a function-based component, might dynamically create or manage additional instances or underlying infrastructure.
- Bruno CLI scripts appear to provide a user-facing, script-based layer to manage deployments and projects on top of the API’s functionality.
- The shared packages (ui, eslint-config, typescript-config) integrate with various apps to enforce consistency in code style and UI design.

##### Architectural Patterns and Design Principles
- Modular/microservices architecture: Each application (api, builder, controlplane, sidecar, spawner) functions as a distinct service with its own responsibilities.
- Separation of concerns: Frontend (Control Plane) is clearly separated from backend (API) while supporting services (Builder, Sidecar, Spawner) offer specialized functionality.
- Shared library usage: Common configurations (eslint, TypeScript) and UI components minimize duplication and reinforce design consistency.
- CI/CD integration: GitHub workflows for building/deploying images suggest an automated build and release process.
- Infrastructure as code elements: Dockerfiles and function host definition hint at containerization and potential serverless deployment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD & Infrastructure
    subgraph "CI/CD & Infrastructure"
        CI("CI/CD Workflows"):::cicd
        DB("Database"):::database
    end

    %% Backend Services
    subgraph "Backend Services"
        API("API Service (Node.js/TypeScript, Drizzle ORM)"):::backend
        Builder("Builder Service (Docker, Build Orchestration)"):::backend
        Sidecar("Sidecar Service (Docker)"):::backend
        Spawner("Spawner Service (Azure Functions)"):::backend
    end

    %% Frontend
    subgraph "Frontend"
        CP("Control Plane (React/Vite)"):::frontend
    end

    %% Utility Tools
    subgraph "Utility Tools"
        Bruno("Bruno CLI Scripts (.bru)"):::utility
    end

    %% Shared Packages
    subgraph "Shared Packages"
        ESL("ESLint Configuration"):::shared
        TS("TypeScript Configuration"):::shared
        UIComp("UI Components"):::shared
    end

    %% Relationships and Data Flow
    CP -->|"RESTcalls"| API
    Builder -->|"Buildtriggers"| API
    Sidecar -->|"Auxiliarytasks"| API
    Spawner -->|"Serviceinstantiation"| API
    API -->|"DBoperations"| DB

    CI -->|"Deploys"| API
    CI -->|"Deploys"| Builder
    CI -->|"Deploys"| Sidecar

    Bruno -->|"CLImanagement"| API
    Bruno -->|"CLImanagement"| Builder

    %% Shared packages integration (dashed lines)
    CP --- UIComp
    CP --- TS
    CP --- ESL
    API --- ESL
    API --- TS
    TS --- UIComp

    %% Click Events
    click API "https://github.com/mdhruvil/deplit/tree/main/apps/api"
    click Builder "https://github.com/mdhruvil/deplit/tree/main/apps/builder"
    click CP "https://github.com/mdhruvil/deplit/tree/main/apps/controlplane"
    click Sidecar "https://github.com/mdhruvil/deplit/tree/main/apps/sidecar"
    click Spawner "https://github.com/mdhruvil/deplit/tree/main/apps/spawner"
    click Bruno "https://github.com/mdhruvil/deplit/tree/main/bruno"
    click ESL "https://github.com/mdhruvil/deplit/tree/main/packages/eslint-config"
    click TS "https://github.com/mdhruvil/deplit/tree/main/packages/typescript-config"
    click UIComp "https://github.com/mdhruvil/deplit/tree/main/packages/ui"
    click CI "https://github.com/mdhruvil/deplit/tree/main/.github/workflows"

    %% Styles
    classDef backend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef frontend fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef utility fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef shared fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef cicd fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
    classDef database fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
