# alexhsamuel/apsis architecture

> Architecture diagram of the GitHub repository alexhsamuel/apsis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexhsamuel/apsis
- Repository: https://github.com/alexhsamuel/apsis

## Overview

##### Main System Components

a. Core Service Layer
- SQLite database (evident from sqlite.py)
- Async scheduling library components

b. Interface Layer
- REST API service (Sanic-based)
- Web UI (Vue.js frontend)
- CLI interface

c. Agent System
- Agent components for distributed task execution
- Procstar integration for process management

##### Component Relationships

**[Web UI (Vue.js)] ←→ [REST API] ←→ [Core Scheduler Service]**
**[CLI Interface] ←→ [REST API] ←→ [Core Scheduler Service]**
**[Core Scheduler Service] ←→ [SQLite Database]**
**[Core Scheduler Service] ←→ [Agent System] ←→ [Task Execution]**

##### Detailed Component Breakdown

For each major component, include these subcomponents:

a. Core Scheduler Service:
- Schedule Management (schedule/*)
- Job Management (jobs/*)
- Run Management (runs.py)
- Condition Handling (cond/*)
- Action Processing (actions/*)

b. Agent System:
- Agent API
- Process Management
- Remote Execution
- Security (SSL/Certificates)

c. Web UI:
- Vue.js Components
- WebSocket Communication
- State Management
- Time Zone Handling

##### Implementation Details

Key features:
- Async operation flow
- Job dependency resolution
- Schedule evaluation
- State transitions
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Interface
        WebUI["Web UI (Vue.js)"]
        CLI["CLI Interface"]
        REST["REST API Service"]
        WS["WebSocket Communication"]
    end

    subgraph Core
        Scheduler["Core Scheduler Service"]
        SQLite[(SQLite Database)]
        
        subgraph Management
            Schedule["Schedule Management"]
            Jobs["Job Management"]
            Runs["Run Management"]
            State["State Management"]
            Time["Time Handling"]
        end
        
        subgraph Processing
            Conditions["Condition Handling"]
            Actions["Action Processing"]
        end
    end

    subgraph Execution
        Agent["Agent System"]
        Procstar["Procstar Integration"]
    end

    %% Connections
    WebUI <--> REST
    CLI <--> REST
    REST <--> Scheduler
    WS <--> Scheduler
    
    Scheduler <--> SQLite
    Scheduler --> Management
    Scheduler --> Processing
    
    Schedule --> Jobs
    Jobs --> Runs
    Runs --> State
    Time --> Schedule
    
    Conditions --> Actions
    Actions --> Agent
    Agent --> Procstar

    %% Click events
    click WebUI "https://github.com/alexhsamuel/apsis/tree/master/vue/"
    click CLI "https://github.com/alexhsamuel/apsis/blob/master/python/apsis/cli.py"
    click REST "https://github.com/alexhsamuel/apsis/blob/master/python/apsis/service/api.py"
    click WS "https://github.com/alexhsamuel/apsis/blob/master/python/apsis/service/messages.py"
    click Scheduler "https://github.com/alexhsamuel/apsis/blob/master/python/apsis/scheduler.py"
    click SQLite "https://github.com/alexhsamuel/apsis/blob/master/python/apsis/sqlite.py"
    click Schedule "https://github.com/alexhsamuel/apsis/tree/master/python/apsis/schedule/"
    click Jobs "https://github.com/alexhsamuel/apsis/blob/master/python/apsis/jobs.py"
    click Runs "https://github.com/alexhsamuel/apsis/blob/master/python/apsis/runs.py"
    click State "https://github.com/alexhsamuel/apsis/blob/master/python/apsis/states.py"
    click Time "https://github.com/alexhsamuel/apsis/blob/master/python/apsis/lib/timing.py"
    click Conditions "https://github.com/alexhsamuel/apsis/tree/master/python/apsis/cond/"
    click Actions "https://github.com/alexhsamuel/apsis/tree/master/python/apsis/actions/"
    click Agent "https://github.com/alexhsamuel/apsis/tree/master/python/apsis/agent/"
    click Procstar "https://github.com/alexhsamuel/apsis/blob/master/python/apsis/procstar.py"

    %% Styling
    classDef interface fill:#90EE90
    classDef core fill:#87CEEB
    classDef execution fill:#FFA500
    classDef database fill:#DDA0DD
    
    class WebUI,CLI,REST,WS interface
    class Scheduler,Schedule,Jobs,Runs,State,Time,Conditions,Actions core
    class Agent,Procstar execution
    class SQLite database

    %% Legend
    subgraph Legend
        L1["Interface Components"]:::interface
        L2["Core Components"]:::core
        L3["Execution Components"]:::execution
        L4[(Database)]:::database
    end
```
