Skip to content

Reports

EcoCtrl's reporting system lets administrators define scheduled report plans and generate documents from templates. Report generation runs asynchronously through the queue system so large exports never block the API.

Concepts

TermDescription
Report planA scheduled job that defines what data to collect, how to format it, and when to run.
Report templateA reusable document layout (e.g. PDF header, footer, chart placement).
Report instanceA single generated document produced by executing a plan.

Data model

report_plans

ColumnTypeNotes
iduuid PK
namevarcharHuman-readable plan name.
descriptiontextOptional.
templateIduuid FK→ report_templates(id).
schedulevarcharCron expression or manual.
configjsonbData source, filters, format (pdf / csv / xlsx).
enabledbooleanWhether the plan is active.
lastRunAttimestamptzNullable.
createdAttimestamptz

report_templates

ColumnTypeNotes
iduuid PK
namevarcharTemplate name.
descriptiontextOptional.
contentjsonbLayout definition (headers, sections, chart configs).
createdAttimestamptz

Admin UI

The Reports page in the admin dashboard provides:

  • A list of existing report plans with status, last run time and next scheduled run.
  • CRUD operations on plans (create, edit, enable/disable, delete).
  • A template gallery showing available layouts.
  • Manual execution trigger for any plan (runs immediately via queue).
  • Download links for generated report instances.

API

MethodPathDescription
GET/api/reports/plansList report plans
POST/api/reports/plansCreate a plan
GET/api/reports/plans/:idGet plan details
PUT/api/reports/plans/:idUpdate plan
DELETE/api/reports/plans/:idDelete plan
POST/api/reports/plans/:id/runExecute plan manually
GET/api/reports/templatesList templates

Execution flow

Schedule fires (or manual trigger)


Queue job: report-generation


Worker collects data from configured sources


Applies template layout


Renders to target format (PDF / CSV / XLSX)


Stores result and updates plan.lastRunAt

Adding a report data source

  1. Add the data collection logic in packages/server/src/services/reporting/.
  2. Register the source name in the report plan config schema.
  3. Update the admin UI to allow selecting the new source in the plan editor.
  4. The worker automatically picks up the new source by name at runtime.

Released under the MIT License.