# odense-rpa/automation-server architecture

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

- Interactive diagram: https://gitdiagram.com/odense-rpa/automation-server
- Repository: https://github.com/odense-rpa/automation-server

## Overview

##### Main Components

a) Frontend Layer:
- Vue.js based web application (evident from .vue files)
- Components for managing processes, workqueues, credentials, and sessions
- Store management system
- Router for navigation
- Services for API communication

b) Backend Layer:
- FastAPI application
- Database layer with SQLAlchemy (indicated by alembic migrations)
- API routes organized by resource types
- Authentication/Security services
- Repository pattern implementation
- Scheduler component

c) Worker Layer:
- Python-based automation runner
- Client library for communication
- Resource handlers
- Session management

**[Frontend Layer]**
- ↕
**[Backend Layer]**
- ↕
**[Worker Layer]**

##### Detailed Component Breakdown

Frontend Section:
**[Vue.js Frontend]**
- Views (Process, Workqueue, Credentials)
- Components
- Store Management
- API Services

Backend Section:
**[FastAPI Backend]**
- API Routes (v1)
- Authentication
- Database Layer
- Repositories
- Services
- Scheduler

Worker Section:
**[Worker Nodes]**
- Automation Client
- Runners
- Resource Handlers

##### Important Elements to Highlight

- Blue: Frontend components
- Green: Backend services
- Orange: Worker nodes
- Gray: External services/databases

- Rectangles: Main components
- Hexagons: API endpoints
- Circles: Services

##### Connection Types

- REST API calls between frontend and backend
- Database connections
- Worker communication channels
- Authentication flows
- Event triggers and scheduling paths

##### Additional Details

Annotations for:
- Authentication flow
- Session management
- Work queue processing
- Resource allocation
- Trigger handling

##### Technical Stack Indicators

- Vue.js (Frontend)
- FastAPI (Backend)
- SQLAlchemy (Database ORM)
- Python Runners (Workers)
- OAuth2 (Security)

##### Specific Implementation Notes

- Relationship between workqueues, sessions, and workers
- How triggers interact with the scheduling system
- Demonstrate the flow of work items through the system
- Credential management security boundary

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef worker fill:#e67e22,stroke:#d35400,color:white
    classDef database fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef api fill:#9b59b6,stroke:#8e44ad,color:white
    classDef config fill:#34495e,stroke:#2c3e50,color:white

    %% Frontend Layer
    subgraph Frontend
        App["Vue.js App"]:::frontend
        Views["Views"]:::frontend
        Components["Components"]:::frontend
        Store["Store Management"]:::frontend
        Router["Router"]:::frontend
        APIService["API Services"]:::frontend
    end

    %% Backend Layer
    subgraph Backend
        FastAPI["FastAPI Application"]:::backend
        Auth["Authentication"]:::backend
        Scheduler["Scheduler"]:::backend
        Services["Services"]:::backend
        
        subgraph API
            ProcessAPI["Process API"]:::api
            WorkqueueAPI["Workqueue API"]:::api
            SessionAPI["Session API"]:::api
            CredentialsAPI["Credentials API"]:::api
            TriggerAPI["Trigger API"]:::api
        end
        
        subgraph Database
            DB[(Database)]:::database
            Models["DB Models"]:::backend
            Repository["Repository Layer"]:::backend
            DBSession["DB Session"]:::backend
        end
    end

    %% Worker Layer
    subgraph Workers
        Worker["Worker Node"]:::worker
        AutoClient["Automation Client"]:::worker
        ResourceHandler["Resource Handlers"]:::worker
        SessionMgr["Session Management"]:::worker
        PythonRunner["Python Runner"]:::worker
    end

    %% Configuration Nodes
    BackendConfig["Backend Config"]:::config
    FrontendConfig["Frontend Config"]:::config
    WorkerConfig["Worker Config"]:::config

    %% Relationships
    App --> Views
    App --> Components
    App --> Store
    App --> Router
    App --> APIService
    APIService --> API
    
    FastAPI --> Auth
    FastAPI --> Scheduler
    FastAPI --> Services
    FastAPI --> API
    
    ProcessAPI --> Repository
    WorkqueueAPI --> Repository
    SessionAPI --> Repository
    CredentialsAPI --> Repository
    TriggerAPI --> Repository
    
    Repository --> Models
    Models --> DBSession
    DBSession --> DB
    
    Worker --> AutoClient
    Worker --> ResourceHandler
    Worker --> SessionMgr
    Worker --> PythonRunner
    
    BackendConfig --> FastAPI
    FrontendConfig --> App
    WorkerConfig --> Worker

    %% Click events for component mapping
    click App "https://github.com/odense-rpa/automation-server/blob/master/frontend/src/App.vue"
    click Views "https://github.com/odense-rpa/automation-server/tree/master/frontend/src/views"
    click Components "https://github.com/odense-rpa/automation-server/tree/master/frontend/src/components"
    click Store "https://github.com/odense-rpa/automation-server/tree/master/frontend/src/stores"
    click Router "https://github.com/odense-rpa/automation-server/blob/master/frontend/src/router/index.js"
    click APIService "https://github.com/odense-rpa/automation-server/blob/master/frontend/src/services/automationserver.js"
    click FastAPI "https://github.com/odense-rpa/automation-server/blob/master/backend/app/main.py"
    click ProcessAPI "https://github.com/odense-rpa/automation-server/blob/master/backend/app/api/v1/process.py"
    click WorkqueueAPI "https://github.com/odense-rpa/automation-server/blob/master/backend/app/api/v1/workqueue.py"
    click SessionAPI "https://github.com/odense-rpa/automation-server/blob/master/backend/app/api/v1/session.py"
    click CredentialsAPI "https://github.com/odense-rpa/automation-server/blob/master/backend/app/api/v1/credentials.py"
    click TriggerAPI "https://github.com/odense-rpa/automation-server/blob/master/backend/app/api/v1/trigger.py"
    click Models "https://github.com/odense-rpa/automation-server/blob/master/backend/app/database/models.py"
    click Repository "https://github.com/odense-rpa/automation-server/tree/master/backend/app/database/repository"
    click Auth "https://github.com/odense-rpa/automation-server/blob/master/backend/app/security/oauth2.py"
    click Scheduler "https://github.com/odense-rpa/automation-server/blob/master/backend/app/scheduler.py"
    click Services "https://github.com/odense-rpa/automation-server/tree/master/backend/app/services"
    click Worker "https://github.com/odense-rpa/automation-server/blob/master/worker/main.py"
    click AutoClient "https://github.com/odense-rpa/automation-server/tree/master/worker/automationclient"
    click ResourceHandler "https://github.com/odense-rpa/automation-server/blob/master/worker/automationclient/resources.py"
    click SessionMgr "https://github.com/odense-rpa/automation-server/blob/master/worker/automationclient/sessions.py"
    click PythonRunner "https://github.com/odense-rpa/automation-server/blob/master/worker/runners/python.py"
    click DBSession "https://github.com/odense-rpa/automation-server/blob/master/backend/app/database/session.py"
    click BackendConfig "https://github.com/odense-rpa/automation-server/blob/master/backend/app/config.py"
    click FrontendConfig "https://github.com/odense-rpa/automation-server/blob/master/frontend/.env"
    click WorkerConfig "https://github.com/odense-rpa/automation-server/blob/master/worker/requirements.txt"
```
