# deepraj21/buildlab architecture

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

- Interactive diagram: https://gitdiagram.com/deepraj21/buildlab
- Repository: https://github.com/deepraj21/buildlab

## Overview

##### Project type and purpose
- BuildLab is a full-stack hybrid web/mobile application.
- Purpose: Let users query an AI to scaffold, run, and edit React projects in a browser-embedded IDE and terminal; support AI-powered search, group chat, and private “spaces.”

##### File structure
- Top-level separation:
- app/client → the frontend (web + mobile via Capacitor/Android)
- app/server → the backend (Node.js/Express controllers, services, models)
- client/src → React+TypeScript (Vite) with pages, components, routes, UI library, config (axios, socket).
- client/android → Capacitor Android wrapper (native Android project + Java MainActivity).
- server/
- controllers → HTTP handlers by domain (ai, chat, project, blog, user)
- services → business logic (ai.service calls LLMs & Google, project.service scaffolds code, redis.service for caching, user.service, etc.)
- models → data schemas (blog, project, user)
- middleware → auth checks
- routes → Express routers wired to controllers
- server.js/app.js → Express app entrypoints

##### Readme insights
- Tech stack: React+TSX (Vite), Tailwind CSS, ShadCN UI, Capacitor for Android, Node.js backend.
- Features: AI-powered search, React project generation agent, chat (@ai and group), private workspaces (“spaces”), in-app browser/terminal.
- External integrations: OpenAI or other LLMs, Google search scraping, Postman-documented REST API.

##### Detail
- Sub-module (ai.controller vs. chat.controller vs. project.controller).
- Middleware (auth) as a separate stage in the request flow.
- In-app browser/terminal module hosting generated React projects.
- Real-time channels (Socket.IO) vs. standard REST.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Zone
    subgraph "Client" 
        direction TB
        subgraph "Web Platform"
            direction TB
            WebClient["React Web Client"]:::client
            Routes["Frontend Routes Config"]:::client
            AxiosConfig["Frontend HTTP Client (Axios)"]:::client
            SocketConfig["Frontend Real-Time (Socket.IO)"]:::client
            Pages["Frontend Pages"]:::client
            UIComponents["UI Components Library"]:::client
            DomainComponents["Domain Components"]:::client
        end
        subgraph "Mobile Platform"
            direction TB
            MobileClient["Capacitor Mobile Client (Android wrapper)"]:::client
        end
    end

    %% Server Zone
    subgraph "Backend Services"
        direction TB
        ExpressApp["Express App Entrypoints"]:::server
        AuthMiddleware["Authentication Middleware"]:::server

        subgraph "API Layer"
            direction TB
            RoutesAPI["API Routes"]:::server
            Controllers["Controllers"]
            subgraph ControllersGroup
                direction TB
                AIController["AI Controller"]:::server
                ChatController["Chat Controller"]:::server
                ProjectController["Project Controller"]:::server
                BlogController["Blog Controller"]:::server
                UserController["User Controller"]:::server
            end
        end

        subgraph "Service Layer"
            direction TB
            AIService["AI Integration Service"]:::server
            ProjectService["Project Scaffolding Service"]:::server
            RedisService["Redis Cache Service"]:::server
            UserService["User Management Service"]:::server
        end

        subgraph "Data Layer"
            direction TB
            Models["Data Models"]
            subgraph ModelsGroup
                direction TB
                BlogModel["Blog Model"]:::server
                ProjectModel["Project Model"]:::server
                UserModel["User Model"]:::server
            end
        end
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        MongoDB["MongoDB"]:::db
        RedisDB["Redis"]:::db
    end

    %% External Services
    subgraph "External Services"
        direction TB
        LLM["OpenAI / LLM Provider"]:::external
        GoogleSearch["Google Search Service"]:::external
    end

    %% Client to Backend
    WebClient -->|REST / WebSocket| ExpressApp
    MobileClient -->|REST / WebSocket| ExpressApp

    %% Backend flow
    ExpressApp -->|uses| AuthMiddleware
    AuthMiddleware -->|routes to| RoutesAPI
    RoutesAPI -->|calls| AIController
    RoutesAPI -->|calls| ChatController
    RoutesAPI -->|calls| ProjectController
    RoutesAPI -->|calls| BlogController
    RoutesAPI -->|calls| UserController

    AIController -->|invokes| AIService
    ProjectController -->|invokes| ProjectService
    ChatController -->|invokes| RedisService
    UserController -->|invokes| UserService
    BlogController -->|invokes| UserService

    AIService -->|queries| LLM
    AIService -->|queries| GoogleSearch
    ProjectService -->|reads/writes| MongoDB
    UserService -->|reads/writes| MongoDB
    RedisService -->|caches| RedisDB

    BlogServiceDB["Blog Controller"] -.->|reads/writes| MongoDB

    %% Models to DB
    BlogModel -->|schema| MongoDB
    ProjectModel -->|schema| MongoDB
    UserModel -->|schema| MongoDB

    %% Click Events
    click WebClient "https://github.com/deepraj21/buildlab/tree/master/app/client/src"
    click MobileClient "https://github.com/deepraj21/buildlab/tree/master/app/client/android"
    click Routes "https://github.com/deepraj21/buildlab/blob/master/app/client/src/routes/AppRoutes.tsx"
    click AxiosConfig "https://github.com/deepraj21/buildlab/blob/master/app/client/src/config/axios.ts"
    click SocketConfig "https://github.com/deepraj21/buildlab/blob/master/app/client/src/config/socket.ts"
    click Pages "https://github.com/deepraj21/buildlab/tree/master/app/client/src/pages"
    click UIComponents "https://github.com/deepraj21/buildlab/tree/master/app/client/src/components/ui"
    click DomainComponents "https://github.com/deepraj21/buildlab/tree/master/app/client/src/components"
    click ExpressApp "https://github.com/deepraj21/buildlab/blob/master/app/server/app.js"
    click ExpressApp "https://github.com/deepraj21/buildlab/blob/master/app/server/server.js"
    click RoutesAPI "https://github.com/deepraj21/buildlab/tree/master/app/server/routes"
    click AIController "https://github.com/deepraj21/buildlab/blob/master/app/server/controllers/ai.controller.js"
    click ChatController "https://github.com/deepraj21/buildlab/blob/master/app/server/controllers/chat.controller.js"
    click ProjectController "https://github.com/deepraj21/buildlab/blob/master/app/server/controllers/project.controller.js"
    click BlogController "https://github.com/deepraj21/buildlab/blob/master/app/server/controllers/blog.controller.js"
    click UserController "https://github.com/deepraj21/buildlab/blob/master/app/server/controllers/user.controller.js"
    click AIService "https://github.com/deepraj21/buildlab/blob/master/app/server/services/ai.service.js"
    click RedisService "https://github.com/deepraj21/buildlab/blob/master/app/server/services/redis.service.js"
    click ProjectService "https://github.com/deepraj21/buildlab/blob/master/app/server/services/project.service.js"
    click UserService "https://github.com/deepraj21/buildlab/blob/master/app/server/services/user.service.js"
    click BlogController "https://github.com/deepraj21/buildlab/blob/master/app/server/routes/blog.routes.js"
    click ProjectController "https://github.com/deepraj21/buildlab/blob/master/app/server/routes/project.routes.js"
    click AIController "https://github.com/deepraj21/buildlab/blob/master/app/server/routes/ai.routes.js"
    click UserController "https://github.com/deepraj21/buildlab/blob/master/app/server/routes/user.routes.js"
    click AuthMiddleware "https://github.com/deepraj21/buildlab/blob/master/app/server/middleware/auth.middleware.js"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#02457A,color:#02457A
    classDef server fill:#DFF7D8,stroke:#1A6F24,color:#1A6F24
    classDef db fill:#FFE8B8,stroke:#A66C00,color:#A66C00
    classDef external fill:#E8DAFF,stroke:#6B1AAB,color:#6B1AAB
```
