Skip to content

Architecture Overview

Overview

A high-level view of CASYS RPG's architecture, designed for developers who want to understand the system without diving into technical details.

System Overview

graph TD
    subgraph Frontend
        UI[User Interface] --> WS[WebSocket]
        UI --> HTTP[HTTP API]
    end

    subgraph Backend
        WS --> AM[Agent Manager]
        HTTP --> AM

        subgraph Agents
            SA[Story Agent]
            RA[Rules Agent]
            DA[Decision Agent]
            NA[Narrator Agent]
            TA[Trace Agent]
        end

        AM --> Agents
    end

    subgraph Storage
        DB[Database]
        FS[File System]
    end

    Backend --> Storage

Key Components

Frontend Layer

  • User Interface

    • SvelteKit framework
    • Responsive design
    • Real-time updates
  • Communication

    • WebSocket for live updates
    • REST API for CRUD operations
    • State synchronization

Backend Layer

  • API Layer

    • FastAPI framework
    • WebSocket support
    • Request handling
  • Agent System

    • Multi-agent architecture
    • Specialized agents
    • Coordinated processing

Storage Layer

  • Data Storage
    • State persistence
    • Game assets
    • Player data

System Flow

sequenceDiagram
    participant U as User
    participant F as Frontend
    participant A as API
    participant M as Agent Manager
    participant S as Storage

    U->>F: Action
    F->>A: Request
    A->>M: Process
    M->>S: Save
    S-->>M: Confirm
    M-->>A: Response
    A-->>F: Update
    F-->>U: Display

Design Principles

Clean Architecture

  • Separation of Concerns

    • Clear boundaries
    • Independent layers
    • Clean interfaces
  • Dependency Management

    • Inversion of control
    • Dependency injection
    • Clear dependencies

Event-Driven Design

  • Event System

    • Message passing
    • State updates
    • Action processing
  • Async Processing

    • Non-blocking operations
    • Parallel execution
    • Resource efficiency

Integration Points

External Systems

  • API Integration

    • Clear interfaces
    • Version control
    • Documentation
  • Plugin System

    • Extension points
    • Custom agents
    • System hooks

Data Flow

graph LR
    subgraph Input
        UI[User Input]
        EX[External Data]
    end

    subgraph Processing
        AG[Agents]
        RU[Rules]
        ST[State]
    end

    subgraph Output
        RE[Response]
        UP[Updates]
    end

    Input --> Processing
    Processing --> Output

Best Practices

Development

  1. Code Organization

    • Clear structure
    • Consistent patterns
    • Documentation
  2. Testing

    • Unit tests
    • Integration tests
    • Performance tests

Deployment

  1. Environment Setup

    • Configuration
    • Dependencies
    • Security
  2. Monitoring

    • Logging
    • Metrics
    • Alerts

Next Steps