# sutt/doorman architecture

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

- Interactive diagram: https://gitdiagram.com/sutt/doorman
- Repository: https://github.com/sutt/doorman

## Overview

##### Main Components

a) Frontend Layer:
- Web UI components (found in /front-ui)
- Admin interface (views in /src/views)
- User interaction components

b) Core Services:
- DoorMan Service (/src/doorman)
- API Routes
- Hub Management
- Queue Service
- Funding Service
- BossMan Service (/src/bossman)
- Command Management
- Invoice Processing
- Validation Service

c) External Integrations:
- Lightning Network (LNbits)
- AI Service Providers (e.g., Stable Diffusion)
- Worker Nodes

**[Client Layer]**
- ↕️
**[DoorMan/BossMan Services]**
- ↕️
**[External Services & Workers]**

##### Key Interactions to Highlight

a) Payment Flow:
- Client → DoorMan → LNbits → BossMan
- Invoice validation and processing

b) Service Flow:
- Client request → Queue → Worker assignment
- Worker execution → Result delivery

##### Detailed Component Breakdown

**[Frontend Components]**
- Admin Interface
- User Interface
- Payment Interface

**[DoorMan Service]**
- API Routes
- Hub Management
- Queue Service
- Funding Service

**[BossMan Service]**
- Command Management
- Invoice Processing
- Validation Service

**[External Services]**
- Lightning Network (LNbits)
- AI Service Providers
- Worker Nodes

##### Important Technical Details

- Port numbers (3001 for DoorMan, 8090 for BossMan)
- Database connections (SQLite)
- WebSocket connections for real-time updates
- API endpoints

##### Implementation Notes

- Maintain consistent styling and spacing
- Version information
- Document all external dependencies

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef storage fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Frontend Layer
    subgraph Frontend
        WebUI["Web UI"]
        AdminUI["Admin Interface"]
        UserInterface["User Interface"]
    end

    %% Core Services Layer
    subgraph DoorMan
        DoormanApp["DoorMan Service"]
        APIRoutes["API Routes"]
        HubMgmt["Hub Management"]
        QueueSvc["Queue Service"]
        FundingSvc["Funding Service"]
    end

    subgraph BossMan
        BossmanApp["BossMan Service"]
        CmdMgmt["Command Management"]
        InvoiceProc["Invoice Processing"]
        ValidSvc["Validation Service"]
    end

    %% External Services Layer
    subgraph External
        LNbits["Lightning Network (LNbits)"]
        AIProviders["AI Service Providers"]
        Workers["Worker Nodes"]
    end

    %% Storage Layer
    subgraph Storage
        DB[("Database")]
        WorkerConfig["Worker Configurations"]
    end

    %% Relationships
    WebUI --> DoormanApp
    AdminUI --> DoormanApp
    UserInterface --> DoormanApp

    DoormanApp --> APIRoutes
    DoormanApp --> HubMgmt
    DoormanApp --> QueueSvc
    DoormanApp --> FundingSvc

    DoormanApp -.-> BossmanApp
    BossmanApp --> CmdMgmt
    BossmanApp --> InvoiceProc
    BossmanApp --> ValidSvc

    InvoiceProc --> LNbits
    CmdMgmt --> AIProviders
    QueueSvc --> Workers

    DoormanApp --> DB
    BossmanApp --> DB
    CmdMgmt --> WorkerConfig

    %% Click Events
    click WebUI "https://github.com/sutt/DoorMan/tree/master//front-ui/v1/"
    click AdminUI "https://github.com/sutt/DoorMan/tree/master//src/views/"
    click UserInterface "https://github.com/sutt/DoorMan/tree/master//src/views/assets/"
    click DoormanApp "https://github.com/sutt/DoorMan/blob/master//src/doorman/app.ts"
    click APIRoutes "https://github.com/sutt/DoorMan/blob/master//src/doorman/routes/api.ts"
    click HubMgmt "https://github.com/sutt/DoorMan/blob/master//src/doorman/routes/hub.ts"
    click QueueSvc "https://github.com/sutt/DoorMan/blob/master//src/doorman/services/queue.ts"
    click FundingSvc "https://github.com/sutt/DoorMan/blob/master//src/doorman/services/funding.ts"
    click BossmanApp "https://github.com/sutt/DoorMan/blob/master//src/bossman/app.ts"
    click CmdMgmt "https://github.com/sutt/DoorMan/blob/master//src/bossman/services/commands.ts"
    click InvoiceProc "https://github.com/sutt/DoorMan/blob/master//src/bossman/routes/invoice-rest.ts"
    click ValidSvc "https://github.com/sutt/DoorMan/blob/master//src/bossman/services/validate.ts"
    click LNbits "https://github.com/sutt/DoorMan/blob/master//src/bossman/services/lnbits/invoice.ts"
    click DB "https://github.com/sutt/DoorMan/tree/master//src/data/dbs/"
    click WorkerConfig "https://github.com/sutt/DoorMan/blob/master//src/data/workers.json"

    %% Style Applications
    class WebUI,AdminUI,UserInterface frontend
    class DoormanApp,APIRoutes,HubMgmt,QueueSvc,FundingSvc core
    class BossmanApp,CmdMgmt,InvoiceProc,ValidSvc core
    class LNbits,AIProviders,Workers external
    class DB,WorkerConfig storage
```
