# aues6uen11z/dacapo architecture

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

- Interactive diagram: https://gitdiagram.com/aues6uen11z/dacapo
- Repository: https://github.com/aues6uen11z/dacapo

## Overview

##### Project Type & Purpose
- DaCapo is a **full-stack, desktop GUI application** built with **Wails** (Go backend + Quasar/Vue frontend).
- Purpose: Provide a **config-driven** graphical script/task manager that pulls remote repos, manages Python venvs, schedules tasks, and presents logs in real time.

##### File Structure
- Top-level directories:
- `frontend/` → Quasar/Vue SPA
- `backend/` → Go server with MVC-style controllers
- `build/` → Packaging for Windows/macOS (via Wails)
- `repos/` → User-managed script repositories
- Backend layers:
- `router/` → API routes
- `controller/` → Instance, Scheduler, Template, Updater controllers
- `model/` → DB definitions, Request/Response structs
- `utils/` → Git operations, Logger, WebSocket manager
- Frontend:
- `src/pages/` → Views (Home, Instance, Settings, etc.)
- `src/components/` → Reusable Vue components
- `src/services/` → API wrappers (`axios`), request/response typings
- `wailsjs/` → Auto-generated RPC bindings

##### Key README Insights
- Configs are JSON/YAML → drives UI generation.
- Features: multi-language, auto-update, scheduler, Python venv management.
- Uses Wails to bundle frontend+backend into a desktop client.

##### Main Components & Relationships
a. **UI Layer (Frontend SPA)**
- Quasar/Vue pages & components
- Communicates via **Wails RPC** or HTTP API over an embedded WebView2/WebKit
b. **API/Router (Go)**
- `router/router.go` defines endpoints → mapped to controllers
c. **Controllers**
- `instance_ctrl` → CRUD on task instances
- `scheduler_ctrl` → schedule/trigger tasks
- `template_ctrl` → load/generate UI from config templates
- `updater_ctrl` → self-update mechanism
d. **Model Layer & Storage**
- `model/db.go` → local database (e.g., SQLite)
- Structs for instance info, template info, scheduler, requests, responses
e. **Utilities & Services**
- Git utils → clone/pull repos
- Python venv & dependency manager (invoked by controller)
- WS manager → pushes real-time log events back to UI
f. **External Dependencies**
- Remote Git repositories
- Python interpreter & packages
- File system (for config files, logs, repos)

##### Architectural Patterns & Design Principles
- **MVC-like** separation in backend (Router → Controller → Model)
- **Event-driven** real-time updates via WebSocket
- **Plugin/config-driven** UI generation (templates in `repos/`)
- **Single-Page Application** on frontend with service layer for type safety

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        direction TB
        Pages["Pages"]:::frontend
        Components["Reusable Vue Components"]:::frontend
        API_Service["API Service"]:::frontend
        Req_Types["Request Typings"]:::frontend
        Res_Types["Response Typings"]:::frontend
        RPC["Wails RPC Bindings"]:::frontend
    end

    subgraph "Backend Layer"
        direction TB
        Router["API Router"]:::backend
        subgraph "Controllers"
            direction TB
            InstanceCtrl["Instance Controller"]:::backend
            SchedulerCtrl["Scheduler Controller"]:::backend
            TemplateCtrl["Template Controller"]:::backend
            UpdaterCtrl["Updater Controller"]:::backend
        end
        subgraph "Models"
            direction TB
            DB["DB Setup & Definitions"]:::backend
            InstanceModel["Instance Configuration & Info"]:::backend
            SchedulerTemplateModel["Scheduler & Template Models"]:::backend
            ReqRes["Request/Response Structs"]:::backend
        end
        subgraph "Utils"
            direction TB
            GitUtil["Git Utility"]:::backend
            Logger["Logger"]:::backend
            WSManager["WebSocket Manager"]:::backend
        end
        main["Application Bootstrap"]:::backend
    end

    subgraph "External Systems"
        direction TB
        LocalDB["Local Database (SQLite)"]:::external
        FileSystem["File System (repos/configs/logs)"]:::external
        RemoteGit["Remote Git Repos"]:::external
        PythonRuntime["Python Runtime"]:::external
    end

    subgraph "Build & Packaging"
        direction TB
        WindowsBuild["Windows Installer"]:::external
        MacBuild["macOS Bundle"]:::external
    end

    Pages -->|uses| API_Service
    Components -->|uses| API_Service
    API_Service -->|"HTTP/Wails RPC"| Router
    RPC -->|"RPC Calls"| Router

    Router -->|routes to| InstanceCtrl
    Router -->|routes to| SchedulerCtrl
    Router -->|routes to| TemplateCtrl
    Router -->|routes to| UpdaterCtrl

    InstanceCtrl -->|CRUD| DB
    SchedulerCtrl -->|read/write| DB
    TemplateCtrl -->|load templates| FileSystem
    UpdaterCtrl -->|self-update| GitUtil

    SchedulerCtrl -->|invoke venv| PythonRuntime
    SchedulerCtrl -->|log stream| WSManager
    WSManager -->|push logs| Pages

    GitUtil -->|clone/pull| RemoteGit
    DB -->|store| LocalDB
    FileSystem -->|store logs/templates| LocalDB

    main -->|initializes| Router
    main -->|build triggers| WindowsBuild
    main -->|build triggers| MacBuild

    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px;

    click Pages "https://github.com/aues6uen11z/dacapo/tree/master/frontend/src/pages"
    click Components "https://github.com/aues6uen11z/dacapo/tree/master/frontend/src/components"
    click API_Service "https://github.com/aues6uen11z/dacapo/blob/master/frontend/src/services/api.ts"
    click Req_Types "https://github.com/aues6uen11z/dacapo/blob/master/frontend/src/services/request.ts"
    click Res_Types "https://github.com/aues6uen11z/dacapo/blob/master/frontend/src/services/response.ts"
    click RPC "https://github.com/aues6uen11z/dacapo/blob/master/frontend/wailsjs/go/app/App.d.ts"
    click Router "https://github.com/aues6uen11z/dacapo/blob/master/backend/router/router.go"
    click InstanceCtrl "https://github.com/aues6uen11z/dacapo/blob/master/backend/controller/instance_ctrl.go"
    click SchedulerCtrl "https://github.com/aues6uen11z/dacapo/blob/master/backend/controller/scheduler_ctrl.go"
    click TemplateCtrl "https://github.com/aues6uen11z/dacapo/blob/master/backend/controller/template_ctrl.go"
    click UpdaterCtrl "https://github.com/aues6uen11z/dacapo/blob/master/backend/controller/updater_ctrl.go"
    click DB "https://github.com/aues6uen11z/dacapo/blob/master/backend/model/db.go"
    click InstanceModel "https://github.com/aues6uen11z/dacapo/blob/master/backend/model/instance_conf.go"
    click SchedulerTemplateModel "https://github.com/aues6uen11z/dacapo/blob/master/backend/model/scheduler.go"
    click ReqRes "https://github.com/aues6uen11z/dacapo/blob/master/backend/model/request.go"
    click GitUtil "https://github.com/aues6uen11z/dacapo/blob/master/backend/utils/git.go"
    click Logger "https://github.com/aues6uen11z/dacapo/blob/master/backend/utils/logger.go"
    click WSManager "https://github.com/aues6uen11z/dacapo/blob/master/backend/utils/ws_manager.go"
    click FileSystem "https://github.com/aues6uen11z/dacapo/tree/master/repos/"
    click main "https://github.com/aues6uen11z/dacapo/blob/master/main.go"
    click WindowsBuild "https://github.com/aues6uen11z/dacapo/tree/master/build/windows/installer"
    click MacBuild "https://github.com/aues6uen11z/dacapo/tree/master/build/darwin"
```
