# private-dev-ph/libreflow-annotate architecture

> Architecture diagram of the GitHub repository private-dev-ph/libreflow-annotate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/private-dev-ph/libreflow-annotate
- Repository: https://github.com/private-dev-ph/libreflow-annotate

## Overview

#### Purpose and entry points
This is a browser-based image annotation and project-management application with model/inference support. The Node.js HTTP server starts at `server.js`; static user interfaces are served from `public/index.html`, `public/annotator.html`, and related page-specific HTML files. Inference is a separate Python process rooted at `py_scripts/infer_server.py`.

#### Browser application
The frontend is a multi-page vanilla JavaScript application rather than a SPA. Shared API and application behavior are centered in `public/js/api.js` and `public/js/app.js`. Page controllers separate major workflows:
- Annotation workspace: `public/annotator.html`, `public/js/canvas.js`, `public/js/project.js`
- Dashboard and jobs: `public/dashboard.html`, `public/js/dashboard.js`, `public/js/jobs-page.js`
- Model management: `public/models.html`, `public/js/models-page.js`

The browser-to-server boundary is the API client in `public/js/api.js`; UI code should not directly own backend persistence or inference execution.

#### Authentication and user-scoped experience
Authentication is handled through `routes/auth.js`, with corresponding browser behavior in `public/js/auth.js` and `public/login.html`. Notification/inbox behavior is independently surfaced through `routes/notifications.js`, `public/js/notifications.js`, and `public/js/nav-inbox.js`, indicating user-facing asynchronous status or activity is part of the core experience.

#### Projects, images, and annotations
The central data domain appears to be projects containing images and annotation data. Backend ownership is partitioned by resource:
- Projects: `routes/projects.js`
- Images: `routes/images.js`
- Annotations: `routes/annotations.js`

The annotation UI combines the project controller with an interactive drawing/rendering layer in `public/js/project.js` and `public/js/canvas.js`. The expected control flow is: select or load a project/image, retrieve image and existing annotation state through route APIs, edit on the canvas, then persist annotation changes through the annotations API.

#### Batch jobs and model lifecycle
Longer-running work is modeled separately from interactive annotation. `routes/batches.js` exposes batch-oriented operations, while `public/js/jobs.js` and `public/js/jobs-page.js` present job status or controls. Model-facing operations are isolated in `routes/models.js` and `public/js/models-page.js`.

This separation suggests a key boundary: browser interactions initiate work through the Node server, while job/batch processing and model inference should remain asynchronous rather than block annotation requests.

#### Python inference boundary and runtime
Inference functionality is implemented outside the Node runtime in `py_scripts/infer_server.py`, with supporting execution logic in `py_scripts/pipeline.py` and Python dependencies in `py_scripts/requirements.txt`. The repository includes separate launch scripts—`start_app.bat`, `start_app.ps1`, and `start_inference.bat`—which reinforce that the web/API service and inference service are independently started processes.

The material runtime architecture is therefore:
1. Node.js server/API (`server.js`, `routes/*.js`)
2. Static browser client (`public/`)
3. Python inference service/pipeline (`py_scripts/`)

No database, message broker, cloud provider, or third-party model service can be confirmed from the supplied tree.

Main entry points: [`public/js/api.js`](https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/api.js) (API client), [`server.js`](https://github.com/private-dev-ph/libreflow-annotate/blob/main/server.js) (HTTP server), [`public/js/project.js`](https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/project.js) (Project controller), [`routes/batches.js`](https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/batches.js) (Batch jobs API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser client"]
  node_shared_app["Shared app behavior<br/>browser JavaScript<br/>[app.js]"]
  node_api_client["API client<br/>browser JavaScript<br/>[api.js]"]
  node_login["Login experience<br/>page controller<br/>[auth.js]"]
  node_annotation_workspace["Annotation workspace<br/>page<br/>[annotator.html]"]
  node_project_controller["Project controller<br/>browser JavaScript<br/>[project.js]"]
  node_canvas["Drawing canvas<br/>browser JavaScript<br/>[canvas.js]"]
  node_dashboard_jobs["Dashboard and jobs<br/>page controller<br/>[jobs-page.js]"]
  node_models_page["Model management<br/>page controller<br/>[models-page.js]"]
  node_inbox["Inbox notifications<br/>browser JavaScript<br/>[nav-inbox.js]"]
end

subgraph group_node["Node.js API"]
  node_server{{"HTTP server<br/>Node.js<br/>[server.js]"}}
  node_auth_route["Auth API<br/>route<br/>[auth.js]"]
  node_projects_route["Projects API<br/>route<br/>[projects.js]"]
  node_images_route["Images API<br/>route<br/>[images.js]"]
  node_annotations_route["Annotations API<br/>route<br/>[annotations.js]"]
  node_batches_route["Batch jobs API<br/>route<br/>[batches.js]"]
  node_models_route["Models API<br/>route<br/>[models.js]"]
  node_notifications_route["Notifications API<br/>route<br/>[notifications.js]"]
end

subgraph group_python["Python inference"]
  node_inference_server{{"Inference service<br/>Python process<br/>[infer_server.py]"}}
  node_pipeline["Inference pipeline<br/>Python module<br/>[pipeline.py]"]
end

node_server -->|"mounts"| node_auth_route
node_server -->|"mounts"| node_projects_route
node_server -->|"mounts"| node_images_route
node_server -->|"mounts"| node_annotations_route
node_server -->|"mounts"| node_batches_route
node_server -->|"mounts"| node_models_route
node_server -->|"mounts"| node_notifications_route
node_server -->|"serves"| node_shared_app
node_shared_app -->|"uses"| node_api_client
node_login -->|"auth requests"| node_api_client
node_annotation_workspace -->|"loads"| node_project_controller
node_project_controller -->|"edits with"| node_canvas
node_project_controller -->|"loads and saves"| node_api_client
node_dashboard_jobs -->|"job controls"| node_api_client
node_models_page -->|"model operations"| node_api_client
node_inbox -->|"activity requests"| node_api_client
node_api_client -->|"HTTP API"| node_server
node_api_client -->|"authentication"| node_auth_route
node_api_client -->|"projects"| node_projects_route
node_api_client -->|"images"| node_images_route
node_api_client -->|"annotation state"| node_annotations_route
node_api_client -->|"batch status"| node_batches_route
node_api_client -->|"models"| node_models_route
node_api_client -->|"notifications"| node_notifications_route
node_batches_route -.->|"asynchronous work"| node_inference_server
node_models_route -.->|"inference operations"| node_inference_server
node_inference_server -->|"runs"| node_pipeline

click node_server "https://github.com/private-dev-ph/libreflow-annotate/blob/main/server.js"
click node_auth_route "https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/auth.js"
click node_projects_route "https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/projects.js"
click node_images_route "https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/images.js"
click node_annotations_route "https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/annotations.js"
click node_batches_route "https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/batches.js"
click node_models_route "https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/models.js"
click node_notifications_route "https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/notifications.js"
click node_shared_app "https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/app.js"
click node_api_client "https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/api.js"
click node_login "https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/auth.js"
click node_annotation_workspace "https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/annotator.html"
click node_project_controller "https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/project.js"
click node_canvas "https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/canvas.js"
click node_dashboard_jobs "https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/jobs-page.js"
click node_models_page "https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/models-page.js"
click node_inbox "https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/nav-inbox.js"
click node_inference_server "https://github.com/private-dev-ph/libreflow-annotate/blob/main/py_scripts/infer_server.py"
click node_pipeline "https://github.com/private-dev-ph/libreflow-annotate/blob/main/py_scripts/pipeline.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_shared_app,node_api_client,node_login,node_annotation_workspace,node_project_controller,node_canvas,node_dashboard_jobs,node_models_page,node_inbox toneBlue
class node_server,node_auth_route,node_projects_route,node_images_route,node_annotations_route,node_batches_route,node_models_route,node_notifications_route toneAmber
class node_inference_server,node_pipeline toneMint
```

## Components

### Browser client

Multi-page vanilla JavaScript application.

- [Shared app behavior](https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/app.js): browser JavaScript · `public/js/app.js`
- [API client](https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/api.js): browser JavaScript · Browser-to-server boundary for UI code. · `public/js/api.js`
- [Login experience](https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/auth.js): page controller · `public/js/auth.js`
- [Annotation workspace](https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/annotator.html): page · `public/annotator.html`
- [Project controller](https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/project.js): browser JavaScript · `public/js/project.js`
- [Drawing canvas](https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/canvas.js): browser JavaScript · Interactive annotation rendering and editing. · `public/js/canvas.js`
- [Dashboard and jobs](https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/jobs-page.js): page controller · `public/js/jobs-page.js`
- [Model management](https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/models-page.js): page controller · `public/js/models-page.js`
- [Inbox notifications](https://github.com/private-dev-ph/libreflow-annotate/blob/main/public/js/nav-inbox.js): browser JavaScript · `public/js/nav-inbox.js`

### Node.js API

HTTP server and resource routes.

- [HTTP server](https://github.com/private-dev-ph/libreflow-annotate/blob/main/server.js): Node.js · Serves static pages and API routes. · `server.js`
- [Auth API](https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/auth.js): route · `routes/auth.js`
- [Projects API](https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/projects.js): route · `routes/projects.js`
- [Images API](https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/images.js): route · `routes/images.js`
- [Annotations API](https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/annotations.js): route · `routes/annotations.js`
- [Batch jobs API](https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/batches.js): route · `routes/batches.js`
- [Models API](https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/models.js): route · `routes/models.js`
- [Notifications API](https://github.com/private-dev-ph/libreflow-annotate/blob/main/routes/notifications.js): route · `routes/notifications.js`

### Python inference

Independently started inference runtime.

- [Inference service](https://github.com/private-dev-ph/libreflow-annotate/blob/main/py_scripts/infer_server.py): Python process · Separate runtime for model inference. · `py_scripts/infer_server.py`
- [Inference pipeline](https://github.com/private-dev-ph/libreflow-annotate/blob/main/py_scripts/pipeline.py): Python module · `py_scripts/pipeline.py`

## Connections

- HTTP server → Auth API: mounts
- HTTP server → Projects API: mounts
- HTTP server → Images API: mounts
- HTTP server → Annotations API: mounts
- HTTP server → Batch jobs API: mounts
- HTTP server → Models API: mounts
- HTTP server → Notifications API: mounts
- HTTP server → Shared app behavior: serves
- Shared app behavior → API client: uses
- Login experience → API client: auth requests
- Annotation workspace → Project controller: loads
- Project controller → Drawing canvas: edits with
- Project controller → API client: loads and saves
- Dashboard and jobs → API client: job controls
- Model management → API client: model operations
- Inbox notifications → API client: activity requests
- API client → HTTP server: HTTP API
- API client → Auth API: authentication
- API client → Projects API: projects
- API client → Images API: images
- API client → Annotations API: annotation state
- API client → Batch jobs API: batch status
- API client → Models API: models
- API client → Notifications API: notifications
- Batch jobs API → Inference service: asynchronous work
- Models API → Inference service: inference operations
- Inference service → Inference pipeline: runs
