# gowdavarun/checkpoint_driven_task_handler architecture

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

- Interactive diagram: https://gitdiagram.com/gowdavarun/checkpoint_driven_task_handler
- Repository: https://github.com/gowdavarun/checkpoint_driven_task_handler

## Overview

##### Main Components
- C Task Handler:
- File: TaskHandler.c
- Purpose: Performs the low-level task execution in chunks, simulates random crashes (memory, I/O, network), and supports checkpoint-driven progress.
- Backend Server:
- Files: server.js, package.json, package-lock.json
- Technology: Node.js with Express
- Role: Provides REST API endpoints (e.g., adding tasks, fetching task lists, recovering tasks, and retrieving crash logs), interfaces with the task handler, and coordinates automatic and manual recovery mechanisms.
- Frontend UI:
- Files: public/index.html, public/script.js, public/styles.css
- Functionality: Displays task progress (using progress bars), shows crash logs, and includes buttons for manual recovery actions. The UI periodically updates (every 2 seconds) for real-time feedback.

##### Relationships and Interactions
- The Frontend interacts with the Backend REST API:
- The Backend and C Task Handler:
- Data Flow:
- Flows for adding a task (POST /add-task), retrieving task data (GET /tasks), recovering tasks (POST /recover-task/:taskId), and fetching crash logs (GET /crash-log).

##### Architectural Patterns and Design Principles
- Clearly Separate the Concerns:
- Treat the C-based task handler as a dedicated component for simulation and recovery handling.
- Distinguish the Node.js server as the service layer that provides a well-defined REST API.
- The Frontend UI should be depicted as a consumer of the API.
- Real-time Data/Feedback:
- Automatic refresh mechanism (2-second interval) on the UI that maintains an updated view of the system’s state.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Task Processing Layer"
        TH["Task Handler (C)\nCheckpoint-driven execution & crash simulation"]:::task
    end

    subgraph "Backend Server Layer"
        BS["Backend Server (Node.js/Express)\nREST API: POST/add-task, GET/tasks, POST/recover-task/:taskId, GET/crash-log"]:::backend
    end

    subgraph "Frontend UI Layer"
        FE["Frontend UI (HTML/CSS/JS)\nDisplays task progress, crash logs, & triggers recovery (auto-refresh every 2s)"]:::frontend
    end

    FE -->|"calls"| BS
    BS -->|"monitors & triggers"| TH
    TH -->|"sends updates"| BS
    BS -->|"pushes data"| FE

    classDef frontend fill:#ade6a3,stroke:#333,stroke-width:2px;
    classDef backend fill:#a2cffe,stroke:#333,stroke-width:2px;
    classDef task fill:#f9d3b4,stroke:#333,stroke-width:2px;

    click TH "https://github.com/gowdavarun/checkpoint_driven_task_handler/blob/main/TaskHandler.c"
    click BS "https://github.com/gowdavarun/checkpoint_driven_task_handler/blob/main/server.js"
    click BS "https://github.com/gowdavarun/checkpoint_driven_task_handler/blob/main/package.json"
    click BS "https://github.com/gowdavarun/checkpoint_driven_task_handler/blob/main/package-lock.json"
    click FE "https://github.com/gowdavarun/checkpoint_driven_task_handler/blob/main/public/index.html"
    click FE "https://github.com/gowdavarun/checkpoint_driven_task_handler/blob/main/public/script.js"
    click FE "https://github.com/gowdavarun/checkpoint_driven_task_handler/blob/main/public/styles.css"
```
