# absurdcoder/app_recovery_tool architecture

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

- Interactive diagram: https://gitdiagram.com/absurdcoder/app_recovery_tool
- Repository: https://github.com/absurdcoder/app_recovery_tool

## Overview

##### Project type and purpose
- This is a full-stack Django web application (“Dynamic Recovery Tool”) that provides a visual workflow builder and execution engine to automate data recovery and migration across multiple infrastructure systems.
- Key purpose: allow users to define recovery workflows via a UI, store them (as YAML and in the DB), and execute them against targets such as Kafka, MQ, databases, service buses, and file systems.

##### File structure
- Top level:
- manage.py, recovery_tool/ (project settings), workflow_builder/ (core app), workflow_yamls/ (persisted YAMLs), db.sqlite3
- start-project.sh, .gitignore, README.md
- In recovery_tool/:
- settings.py, urls.py, wsgi.py, asgi.py → Django configuration & entry points
- In workflow_builder/:
- models.py → WorkflowStep, WorkflowExecution, etc.
- views.py, urls.py, forms.py, admin.py → MVC/Web layer
- action_handlers.py, event_handlers.py, workflow_executor.py → execution logic & connectors
- migrations/ → DB schema evolution
- templates/workflow_builder/ → HTML templates for builder, execution status, logs
- templatetags/custom_filters.py → UI helper filters
- workflow_yamls/: example YAML files autogenerated from workflows

##### README for additional insights
- Confirms Django 4.2 + Python 3.8+, uses SQLite by default but configurable
- Features: visual builder, multiple infra connectors, YAML generation, real-time tracking, extensibility
- Lists supported event types and infra types (Kafka, MQ, DB, Service Bus, File System)
- Development notes: how to add new event or infra types by extending models.py and handlers

##### Main components
a. User Interface (Web Browser)
- UI templates + JavaScript for workflow builder, execution dashboard, real-time updates
b. Django Application Server
- ASGI/WSGI entrypoint → URL router → Views → Forms → Models
- Core “workflow_builder” app
c. Database
- Django ORM persistence (Workflow, WorkflowStep, Execution, Logs)
d. Workflow Executor Service
- workflow_executor.py orchestrating step execution
- action_handlers.py / event_handlers.py implementing connector logic
e. YAML Store
- filesystem folder “workflow_yamls/” holding YAML configs for versioning
f. External Infrastructure Systems
- Kafka cluster
- MQ (e.g., IBM MQ)
- SQL/NoSQL databases
- Service Bus (Azure/AWS)
- File System

##### Relationships and interactions
- Browser → HTTP(S) → Django URL Router → Views → ORM → DB
- View “Create Workflow” writes both DB and generates YAML file in workflow_yamls/
- “Execute Workflow” request → View triggers workflow_executor → reads workflow steps from DB or YAML → for each step:
- invokes corresponding handler in action_handlers/event_handlers
- handler communicates with external infra (via network protocols or SDKs)
- updates step status in DB
- Real-time execution status: Browser polls or uses WebSocket (ASGI) → Django → Views → DB → UI
- Admin interface (optional) interacting directly with Django Admin

##### Architectural patterns and design principles
- MVC (Model-View-Controller) for the web layer
- Modular “workflow_builder” app encapsulating UI, models, execution logic
- Plugin-style handlers: event_handlers and action_handlers for extensibility
- YAML as externalized configuration for portability and version control
- Separation of concerns: UI, orchestration engine, persistence, and connectors are distinct

##### Detailed elements to capture
- HTTP request flow from browser to Django views and back
- DB CRUD flow for workflows, steps, and execution logs
- Executor loop invoking handlers and updating status
- Per-step connections to external systems
- Real-time update mechanism (polling or WebSocket channel)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["Web Browser\n(UI Templates & JS)"]:::ui
    end

    %% Application Layer
    subgraph "Application Layer"
        subgraph "Django Entry Points"
            ManagePY["manage.py"]:::backend
            ASGI["ASGI Server"]:::backend
            WSGI["WSGI Server"]:::backend
            DjangoURLs["URL Router"]:::backend
            Settings["Settings"]:::backend
        end

        subgraph "Core App: workflow_builder"
            CoreApp["workflow_builder"]:::backend
            Views["views.py"]:::backend
            AppURLs["urls.py"]:::backend
            Forms["forms.py"]:::backend
            Admin["admin.py"]:::backend
            Models["models.py"]:::backend
            Filters["custom_filters.py"]:::backend
            Migrations["migrations/"]:::backend
        end

        subgraph "Executor Service"
            Executor["workflow_executor.py"]:::backend
            Actions["action_handlers.py"]:::backend
            Events["event_handlers.py"]:::backend
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        DB["SQLite (DB)"]:::datastore
        YAML["YAML Store\n(workflow_yamls/)"]:::datastore
    end

    %% External Systems
    subgraph "External Infrastructure"
        Kafka["Kafka Cluster"]:::external
        MQ["Message Queue"]:::external
        ExtDB["SQL/NoSQL DB"]:::external
        ServiceBus["Service Bus"]:::external
        FileSystem["File System"]:::external
    end

    %% Relationships
    Browser -->|"HTTP(S) Request"| DjangoURLs
    DjangoURLs -->|routes| Views
    Views -->|uses ORM| Models
    Models -->|CRUD| DB
    Views -->|generate YAML| YAML
    Views -->|trigger| Executor
    Executor -->|calls| Actions
    Executor -->|calls| Events
    Actions -->|connects| Kafka
    Actions -->|connects| MQ
    Actions -->|connects| ExtDB
    Actions -->|connects| ServiceBus
    Actions -->|connects| FileSystem
    Executor -->|update status| DB
    Browser -.->|poll/WebSocket| Views
    Views -->|fetch status| DB
    DB -->|data| Browser

    %% Click Events
    click Browser "https://github.com/absurdcoder/app_recovery_tool/tree/main/recovery_tool/workflow_builder/templates/workflow_builder/"
    click ManagePY "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/manage.py"
    click ASGI "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/recovery_tool/asgi.py"
    click WSGI "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/recovery_tool/wsgi.py"
    click DjangoURLs "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/recovery_tool/urls.py"
    click Settings "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/recovery_tool/settings.py"
    click CoreApp "https://github.com/absurdcoder/app_recovery_tool/tree/main/recovery_tool/workflow_builder/"
    click Views "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/workflow_builder/views.py"
    click AppURLs "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/workflow_builder/urls.py"
    click Forms "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/workflow_builder/forms.py"
    click Admin "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/workflow_builder/admin.py"
    click Models "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/workflow_builder/models.py"
    click Filters "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/workflow_builder/templatetags/custom_filters.py"
    click Migrations "https://github.com/absurdcoder/app_recovery_tool/tree/main/recovery_tool/workflow_builder/migrations/"
    click Executor "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/workflow_builder/workflow_executor.py"
    click Actions "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/workflow_builder/action_handlers.py"
    click Events "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/workflow_builder/event_handlers.py"
    click DB "https://github.com/absurdcoder/app_recovery_tool/blob/main/recovery_tool/db.sqlite3"
    click YAML "https://github.com/absurdcoder/app_recovery_tool/tree/main/recovery_tool/workflow_yamls/"
    click README "https://github.com/absurdcoder/app_recovery_tool/blob/main/README.md"
    click Script "https://github.com/absurdcoder/app_recovery_tool/blob/main/start-project.sh"

    %% Styles
    classDef ui fill:#a8f0c6,stroke:#333,stroke-width:1px
    classDef backend fill:#8ecae6,stroke:#333,stroke-width:1px
    classDef datastore fill:#ffb703,stroke:#333,stroke-width:1px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px
```
