# suzuki-no-suke/dullahan architecture

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

- Interactive diagram: https://gitdiagram.com/suzuki-no-suke/dullahan
- Repository: https://github.com/suzuki-no-suke/dullahan

## Overview

##### Project Type and Purpose
- The README explains that DuLLahan is a headless working assistant framework. It’s designed to provide backend services (exposed over Uvicorn on port 7878) for working assistant tasks, while also offering multiple frontend clients built with various Svelte methodologies.
- The framework integrates multiple bot implementations that appear to leverage various LLM (large language model) APIs (e.g., OpenAI, Claude, Gemini, Perplexity) and includes helper components for prompts parsing/rendering and web retrieval.

##### Analyzing the File Structure
- Back-End Core:
- Main entry points: main.py (launches the Uvicorn server) and README instructions that expose an API.
- The “botfirm” directory houses the core logic for interfacing with LLM APIs. It includes submodules for LLM calls (under botfirm/helper/llm_call) and for managing prompt workflows (botfirm/helper/prompts). There are versioned bot implementations in botfirm/v1 (e.g., CommandBook, Echobot, PreResearcher, etc.).
- The “src” folder contains modules for bot management (bots_manag) and for defining data models and ORM logic. This separation points to a layer for business logic and persistent data (chat histories, messages, chatbots, etc.).
- The “tools” directory shows utilities for database setup, bot registration, and system updates.
- Testing directories (tests, test_firm, test_once) suggest that the project is well-organized for both unit and integration tests.

- Front-End Clients:
- The “frontend” directory contains several sub-projects – all are built using Svelte (with variations like Svelte Flowbite, Mobilefirst, Onepage, Skeleton, Tailwind, Two-page, and SvelteKit). They are likely different styles or variations intended for different UI/UX approaches.
- These frontends are structured with their own package.json, configuration (e.g., tailwind.config, svelte.config.js, vite.config.ts), and routing (typically handling chat sessions, bot selection, and history).

- Documentation:

##### Final Suggestions for the Principal Software Engineer
- Drill down into the backend by breaking it into logical modules (as outlined above) using nested components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Clients
    subgraph "Frontend Clients"
        f1["Svelte Flowbite"]:::frontend
        f2["Svelte Mobilefirst"]:::frontend
        f3["Svelte Onepage"]:::frontend
        f4["Svelte Skeleton"]:::frontend
        f5["Svelte Tailwind"]:::frontend
        f6["Svelte Two-Page"]:::frontend
        f7["SvelteKit"]:::frontend
    end

    %% API Server
    api["API Server (Uvicorn on port 7878)"]:::api

    %% Bot Management Module
    subgraph "Bot Management Module"
        bm1["Botfirm Core"]:::backend
        bm2["Versioned Bots"]:::backend
        bm3["Helper Modules"]:::backend
    end

    %% Business Logic & Data Layer
    subgraph "Business Logic & Data Layer"
        bll1["Bot Management Logic"]:::backend
        bll2["Data Models"]:::backend
        bll3["ORM Definitions"]:::backend
    end

    %% Utility/Tooling Components
    subgraph "Utility/Tooling Components"
        ut1["Database Init"]:::tools
        ut2["Register Bots"]:::tools
        ut3["Setup"]:::tools
        ut4["V1 Update"]:::tools
    end

    %% External Services and Data Store
    ext["External LLM APIs"]:::external
    db["Persistent Data Store"]:::external

    %% Documentation
    doc["Documentation"]:::doc

    %% Connections from Frontend to API Server
    f1 -->|"requests"| api
    f2 -->|"requests"| api
    f3 -->|"requests"| api
    f4 -->|"requests"| api
    f5 -->|"requests"| api
    f6 -->|"requests"| api
    f7 -->|"requests"| api

    %% API Server routes to backend components
    api -->|"routes"| bm1
    api -->|"routes"| bll1
    api -->|"configures"| ut3
    api -->|"updates"| ut4

    %% Bot Management Module internal flow
    bm1 -->|"delegates"| bm2
    bm1 -->|"utilizes"| bm3
    bm3 -->|"calls"| ext

    %% Business Logic & Data Layer flow
    bll1 -->|"manages"| bll2
    bll1 -->|"uses"| bll3
    bll3 -->|"persists"| db

    %% Tools interactions
    ut1 -->|"initializes"| db
    ut2 -->|"registers"| bm1

    %% Documentation links (dashed connections)
    doc ---|"details"| api
    doc ---|"details"| bm1
    doc ---|"details"| bll2

    %% Click Events
    click api "https://github.com/suzuki-no-suke/dullahan/blob/main/main.py"
    click bm1 "https://github.com/suzuki-no-suke/dullahan/tree/main/botfirm"
    click bm2 "https://github.com/suzuki-no-suke/dullahan/tree/main/botfirm/v1"
    click bm3 "https://github.com/suzuki-no-suke/dullahan/tree/main/botfirm/helper"
    click bll1 "https://github.com/suzuki-no-suke/dullahan/tree/main/src/bots_manag"
    click bll2 "https://github.com/suzuki-no-suke/dullahan/tree/main/src/datadef"
    click bll3 "https://github.com/suzuki-no-suke/dullahan/tree/main/src/orm"
    click ut1 "https://github.com/suzuki-no-suke/dullahan/blob/main/tools/init_database.py"
    click ut2 "https://github.com/suzuki-no-suke/dullahan/blob/main/tools/regist_all_bots.py"
    click ut3 "https://github.com/suzuki-no-suke/dullahan/blob/main/tools/setup.py"
    click ut4 "https://github.com/suzuki-no-suke/dullahan/blob/main/tools/v1_update.py"
    click f1 "https://github.com/suzuki-no-suke/dullahan/tree/main/frontend/svelte-flowbite"
    click f2 "https://github.com/suzuki-no-suke/dullahan/tree/main/frontend/svelte-mobilefirst"
    click f3 "https://github.com/suzuki-no-suke/dullahan/tree/main/frontend/svelte-onepage"
    click f4 "https://github.com/suzuki-no-suke/dullahan/tree/main/frontend/svelte-skeleton"
    click f5 "https://github.com/suzuki-no-suke/dullahan/tree/main/frontend/svelte-tailwind"
    click f6 "https://github.com/suzuki-no-suke/dullahan/tree/main/frontend/svelte-two-page"
    click f7 "https://github.com/suzuki-no-suke/dullahan/tree/main/frontend/sveltekit"
    click doc "https://github.com/suzuki-no-suke/dullahan/tree/main/doc"

    %% Styles
    classDef api fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef tools fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef frontend fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef doc fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
