# decoded-cipher/weblyft architecture

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

## Overview

##### Main Components
- API Server – Found under src/api-server. This microservice includes middleware, controllers, and routes for handling authentication, project deployments, and logs. Note that it contains integrations for Kafka (for streaming/log analytics), Prisma (for database interactions), and RabbitMQ (for queueing deployments).
- Build Server – Located under src/build-server. This service is responsible for handling containerized builds, likely managing multi-stage builds and interacting with Docker.
- Docker Manager – In src/docker-mgr. This component appears responsible for managing Docker containers, handling queues, and ensuring that container orchestration tasks are performed.
- Reverse Proxy – In src/reverse-proxy. It includes SSL handling, routing logic, error-page management, and likely acts as the entry point for external requests. It also connects to the database (referencing configuration files like db.ts) and may also integrate with caching (Redis) and other services.
- External Integrations – Include systems like GitHub (for OAuth and webhook-triggered deployments), Kafka & ClickHouse (for real-time logging and analytics), RabbitMQ (for deployment queues), and Neon Postgres/Cloudflare R2 for database and storage, as indicated in the README and config files.

##### Relationships and Interactions
- The API Server routes deployment commands and authentication requests, and it communicates with:
- The Build Server, which is responsible for actual Dockerized builds.
- The Docker Manager, which likely handles container orchestration and management during deployment.
- The API Server also integrates with messaging systems:
- It uses RabbitMQ to queue and process build updates.
- It uses Kafka (with ClickHouse for analytics) for centralized logging and real-time streaming insights.
- The Data Store and External Services:
- A connection to the database (likely Neon Postgres as hinted by the “neon.ts” reference) and caching (Redis).
- Cloud storage integration through Cloudflare R2.
- GitHub integration for source code deployments and OAuth-based authentication.

##### Important Architectural Patterns and Design Principles
- Microservices Architecture: Each service (API Server, Build Server, Docker Manager, Reverse Proxy) is independent and containerized (using Docker) to allow scalability, isolation, and easier maintenance.
- Containerization & CI/CD: The use of Dockerfiles across components and integration with GitHub Actions/Container Registry emphasizes continuous integration and deployment.
- Messaging & Event-Driven Design: RabbitMQ and Kafka illustrate that asynchronous messaging and real-time data processing are core parts of the system.
- Separation of Concerns: Each service specializes in a distinct function (e.g., routing, builds, container management), ensuring modularity and ease of testing.

##### Relevant Technologies, Frameworks, and Libraries
- Usage of Docker and CI/CD pipelines (GitHub Actions and Container Registry) since they are central to deployment and build processes.

##### Final Advice
- Be as detailed as possible: Break down the system into all identifiable components, including configurations (e.g., Kafka, RabbitMQ, Prisma schema) that influence operations.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["User Request"]:::external

    subgraph "Core Microservices"
        RP["Reverse Proxy\n(SSL, Routing)"]:::microservice
        APS["API Server\n(Authentication, Deployments, Logs)"]:::microservice
        BS["Build Server\n(Dockerized Builds)"]:::microservice
        DM["Docker Manager\n(Container Orchestration)"]:::microservice
    end

    subgraph "Messaging & Analytics"
        RAB["RabbitMQ\n(Deployment Queue)"]:::messaging
        KA["Kafka/ClickHouse\n(Logging & Real-time Analytics)"]:::messaging
    end

    subgraph "Data & External Integrations"
        DB["Neon Postgres\n(Database)"]:::database
        CACHE["Redis\n(Caching)"]:::cache
        CF["Cloudflare R2\n(Cloud Storage)"]:::external
        GH["GitHub\n(OAuth & Webhooks)"]:::external
    end

    A -->|"hits" | RP
    RP -->|"forwards"| APS
    APS -->|"triggers builds"| BS
    APS -->|"manages containers"| DM
    APS -->|"queues deployments"| RAB
    APS -->|"streams logs"| KA
    APS -->|"queries"| DB
    APS -->|"caches data"| CACHE
    APS -->|"stores artifacts"| CF
    APS -->|"integrates with"| GH

    click RP "https://github.com/decoded-cipher/weblyft/tree/master/src/reverse-proxy"
    click APS "https://github.com/decoded-cipher/weblyft/tree/master/src/api-server"
    click BS "https://github.com/decoded-cipher/weblyft/tree/master/src/build-server"
    click DM "https://github.com/decoded-cipher/weblyft/tree/master/src/docker-mgr"

    classDef microservice fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef external fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef messaging fill:#DDA0DD,stroke:#000,stroke-width:1px;
    classDef database fill:#FFA07A,stroke:#000,stroke-width:1px;
    classDef cache fill:#AFEEEE,stroke:#000,stroke-width:1px;
```
