# aliceo2group/bookkeeping architecture

> Architecture diagram of the GitHub repository aliceo2group/bookkeeping, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aliceo2group/bookkeeping
- Repository: https://github.com/aliceo2group/bookkeeping

## Overview

ALICE Bookkeeping is a service for tracking runs, logs, environments, detector quality-control flags, data and simulation passes, and processing metadata. The principal workflow is a client request entering an HTTP or gRPC controller, being handled by application services or use cases, and accessing persistent records through the database layer. The application also schedules integrations and synchronization. The tree documents a C++ API client for several gRPC services. Some domain branches are represented by their exact directories because their implementation files were not sampled; their internal links are therefore omitted where evidence is unavailable.

Main entry points: [`lib/database/index.js`](https://github.com/aliceo2group/bookkeeping/blob/main/lib/database/index.js) (Database), [`lib/application.js`](https://github.com/aliceo2group/bookkeeping/blob/main/lib/application.js) (HTTP server), [`lib/server/controllers`](https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/controllers) (HTTP controllers), [`lib/server/gRPC`](https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/gRPC) (gRPC server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry points"]
  node_http["HTTP server<br/>[application.js]"]
  node_httpcontrollers["HTTP controllers"]
  node_usecases["Use cases"]
  node_grpc["gRPC server"]
  node_cpp["C++ API client<br/>[BkpClient.h]"]
end

subgraph group_domain["Bookkeeping domains"]
  node_runs["Run management"]
  node_logs["Log management<br/>[logs.controller.js]"]
  node_qc["QC flags"]
  node_passes["Data passes"]
  node_dpl["DPL executions"]
  node_environment["Environments"]
end

subgraph group_storage["Persistence"]
  node_database[("Database<br/>[index.js]")]
  node_repositories["Repositories"]
  node_adapters["Entity adapters"]
  node_models["Persistence models"]
  node_query["Query builder<br/>[QueryBuilder.js]"]
end

subgraph group_integration["Integrations"]
  node_scheduler["Process scheduler"]
  node_monalisa["MonALISA sync"]
  node_ccdb["CCDB sync"]
  node_kafka["ECS messages"]
end

node_user(("API consumer"))
node_external(("External services"))

node_user -->|"requests"| node_http
node_http -.->|"serves"| node_httpcontrollers
node_httpcontrollers -->|"invokes"| node_usecases
node_httpcontrollers -->|"calls"| node_runs
node_httpcontrollers -->|"calls"| node_qc
node_httpcontrollers -.->|"routes"| node_logs
node_httpcontrollers -.->|"serves"| node_grpc
node_grpc -->|"calls"| node_runs
node_grpc -->|"calls"| node_qc
node_cpp -.->|"calls"| node_external
node_http -->|"schedules"| node_scheduler
node_http -->|"starts sync"| node_monalisa
node_http -->|"schedules sync"| node_ccdb
node_http -->|"configures"| node_kafka
node_monalisa -.->|"synchronizes"| node_external
node_ccdb -.->|"synchronizes"| node_external
node_kafka -.->|"consumes"| node_external
node_runs -->|"accesses"| node_database
node_qc -->|"accesses"| node_database
node_passes -.->|"accesses"| node_database
node_dpl -.->|"accesses"| node_database
node_environment -.->|"accesses"| node_database
node_database -->|"exports"| node_repositories
node_repositories -->|"uses"| node_query
node_repositories -->|"queries"| node_database
node_adapters -.->|"maps"| node_models

click node_http "https://github.com/aliceo2group/bookkeeping/blob/main/lib/application.js"
click node_httpcontrollers "https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/controllers"
click node_usecases "https://github.com/aliceo2group/bookkeeping/tree/main/lib/usecases"
click node_grpc "https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/gRPC"
click node_cpp "https://github.com/aliceo2group/bookkeeping/blob/main/cxx-client/include/BookkeepingApi/BkpClient.h"
click node_runs "https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/services/run"
click node_logs "https://github.com/aliceo2group/bookkeeping/blob/main/lib/server/controllers/logs.controller.js"
click node_qc "https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/services/qualityControlFlag"
click node_passes "https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/services/dataPasses"
click node_dpl "https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/services/dpl"
click node_environment "https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/services/environment"
click node_database "https://github.com/aliceo2group/bookkeeping/blob/main/lib/database/index.js"
click node_repositories "https://github.com/aliceo2group/bookkeeping/tree/main/lib/database/repositories"
click node_adapters "https://github.com/aliceo2group/bookkeeping/tree/main/lib/database/adapters"
click node_models "https://github.com/aliceo2group/bookkeeping/tree/main/lib/database/models"
click node_query "https://github.com/aliceo2group/bookkeeping/blob/main/lib/database/utilities/QueryBuilder.js"
click node_scheduler "https://github.com/aliceo2group/bookkeeping/blob/main/lib/server/services/ScheduledProcessesManager.js"
click node_monalisa "https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/externalServicesSynchronization/monalisa"
click node_ccdb "https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/externalServicesSynchronization/ccdb"
click node_kafka "https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/kafka"

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_http,node_httpcontrollers,node_usecases,node_grpc,node_cpp toneBlue
class node_runs,node_logs,node_qc,node_passes,node_dpl,node_environment toneAmber
class node_database,node_repositories,node_adapters,node_models,node_query,node_user toneMint
class node_scheduler,node_monalisa,node_ccdb,node_kafka toneRose
class node_external toneIndigo
```

## Components

### API entry points

- [HTTP server](https://github.com/aliceo2group/bookkeeping/blob/main/lib/application.js): `lib/application.js`
- [HTTP controllers](https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/controllers): `lib/server/controllers`
- [Use cases](https://github.com/aliceo2group/bookkeeping/tree/main/lib/usecases): `lib/usecases`
- [gRPC server](https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/gRPC): `lib/server/gRPC`
- [C++ API client](https://github.com/aliceo2group/bookkeeping/blob/main/cxx-client/include/BookkeepingApi/BkpClient.h): `cxx-client/include/BookkeepingApi/BkpClient.h`

### Bookkeeping domains

- [Run management](https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/services/run): `lib/server/services/run`
- [Log management](https://github.com/aliceo2group/bookkeeping/blob/main/lib/server/controllers/logs.controller.js): `lib/server/controllers/logs.controller.js`
- [QC flags](https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/services/qualityControlFlag): `lib/server/services/qualityControlFlag`
- [Data passes](https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/services/dataPasses): `lib/server/services/dataPasses`
- [DPL executions](https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/services/dpl): `lib/server/services/dpl`
- [Environments](https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/services/environment): `lib/server/services/environment`

### Persistence

- [Database](https://github.com/aliceo2group/bookkeeping/blob/main/lib/database/index.js): `lib/database/index.js`
- [Repositories](https://github.com/aliceo2group/bookkeeping/tree/main/lib/database/repositories): `lib/database/repositories`
- [Entity adapters](https://github.com/aliceo2group/bookkeeping/tree/main/lib/database/adapters): `lib/database/adapters`
- [Persistence models](https://github.com/aliceo2group/bookkeeping/tree/main/lib/database/models): `lib/database/models`
- [Query builder](https://github.com/aliceo2group/bookkeeping/blob/main/lib/database/utilities/QueryBuilder.js): `lib/database/utilities/QueryBuilder.js`

### Integrations

- [Process scheduler](https://github.com/aliceo2group/bookkeeping/blob/main/lib/server/services/ScheduledProcessesManager.js): `lib/server/services/ScheduledProcessesManager.js`
- [MonALISA sync](https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/externalServicesSynchronization/monalisa): `lib/server/externalServicesSynchronization/monalisa`
- [CCDB sync](https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/externalServicesSynchronization/ccdb): `lib/server/externalServicesSynchronization/ccdb`
- [ECS messages](https://github.com/aliceo2group/bookkeeping/tree/main/lib/server/kafka): `lib/server/kafka`

### Other components

- **API consumer**
- **External services**

## Connections

- API consumer → HTTP server: requests (evidence: `lib/application.js`)
- HTTP server → HTTP controllers: serves
- HTTP controllers → Use cases: invokes (evidence: `lib/server/controllers/runs.controller.js`)
- HTTP controllers → Run management: calls (evidence: `lib/server/controllers/runs.controller.js`)
- HTTP controllers → QC flags: calls (evidence: `lib/server/controllers/qcFlag.controller.js`)
- HTTP controllers → Log management: routes
- HTTP controllers → gRPC server: serves
- gRPC server → Run management: calls
- gRPC server → QC flags: calls
- C++ API client → External services: calls
- HTTP server → Process scheduler: schedules (evidence: `lib/application.js`)
- HTTP server → MonALISA sync: starts sync (evidence: `lib/application.js`)
- HTTP server → CCDB sync: schedules sync (evidence: `lib/application.js`)
- HTTP server → ECS messages: configures (evidence: `lib/application.js`)
- MonALISA sync → External services: synchronizes
- CCDB sync → External services: synchronizes
- ECS messages → External services: consumes
- Run management → Database: accesses (evidence: `lib/server/services/run/RunService.js`)
- QC flags → Database: accesses (evidence: `lib/server/services/qualityControlFlag/QcFlagService.js`)
- Data passes → Database: accesses
- DPL executions → Database: accesses
- Environments → Database: accesses
- Database → Repositories: exports (evidence: `lib/database/index.js`)
- Repositories → Query builder: uses (evidence: `lib/database/repositories/Repository.js`)
- Repositories → Database: queries (evidence: `lib/database/repositories/Repository.js`)
- Entity adapters → Persistence models: maps
