System Design Atlas

Generation forecasts and energy balances

10 / 10Worked example

Final design

Which tests verify concurrency protection and forecast-run completion in the overall architecture?

The final step uses the complete topology from step 6. Inside the boundary: interface → forecast API → time-series revisions, run manifests and comparison versions. Forecast computation reads durable work from this datastore. The measurement source is external. Processing exchanges the domain messages described in the main flow; results reach the interface through the API. The evidence plan for P-33 covers concurrency, retries, boundaries and terminal completion. The table contains expected results of tests yet to be executed.

Starting point Correction permissions are scoped to facilities.

Assumptions for the example case

A fictional example design for a generation facility using fixed 15-minute intervals and separate forecast and measurement versions. Each interval spans 900 seconds, inclusive at the start and exclusive at the end; a measurement at exactly 900 seconds belongs to the next interval. All figures and test targets are illustrative assumptions.

Overall architecture with checks and review loops

Runtime topology

  1. 1 · Measurement source → Measurement ingestion
  2. 2 · Measurement ingestion → Time-series datastore
  3. 3 · Time-series datastore → Forecast computation
  4. 4 · Forecast computation → Metadata datastore
  5. 5 · Metadata datastore → Comparison path
  6. 6 · Comparison path → Energy balance team
Measurement data sourceProvides authenticated measurement revisions
Energy balance teamReads versioned comparisons

Forecasting and comparison system

Measurement ingestionchecks source, interval and revision
Time-series datastoreMeasurements and provenance per interval
Forecast computationComputes from a frozen input version
Forecast APIManages approvals and comparison references
Metadata datastoreRun manifest, versions and comparisons
Comparison pathConnects a forecast with a measurement revision
Measurement data source → Measurement ingestionAuthenticated measurement revision
Measurement ingestion → Time-series datastoreValidated interval values
Time-series datastore → Forecast computationFrozen input version
Forecast computation → Metadata datastoreRun manifest and forecast
Forecast API → Metadata datastoreApproval and current reference
Time-series datastore → Comparison pathselected measurement revision
Metadata datastore → Comparison pathApproved forecast
Comparison path → Energy balance teamVersioned comparison
Replay 4 · State 5 · Flow 7 · Operations 9Interval [0, 900 s) · 900 s starts the next interval

Each comparison binds forecast version, measurement revision and the same interval.

The measurement source sends versioned values to a time-series store. Forecast computation reads a frozen input version and writes a run manifest and forecast. The forecast API manages approvals and current comparison references in the relational metadata store. A separate comparison path combines an approved forecast with a selected measurement revision. The energy balance team reads the comparison; corrections to actual measurements trigger new comparisons while preserving historical forecasts. The components and arrows match step 6. Test markers: API/commit → concurrency and replay (4/5/7); boundary check → exact boundary (2); domain role/completion → terminal evidence (9).

Test plan for the complete design

ComponentTest and expected resultReturn to an earlier step
Forecast APIMeasurement revisions 4 and 5 arrive in both orders. The current actual-value view remains at revision 5; the comparison using revision 4 remains available in history.Steps 3 and 5
Command journalIdentical retries take effect once; changed content produces a conflict.Steps 4 and 7
Domain boundary checkTest 899, 900 and 901 seconds. Expected result: an interval spans 900 seconds, inclusive at the start and exclusive at the end; a measurement at exactly 900 seconds starts the next interval.Step 2
Time-series revisions, run manifests and comparison versionsA new correction to actual measurements does not alter a completed forecast run; it creates a new comparison revision with provenance.Steps 5 and 9
Forecast computationAccept a new measurement revision durably, then start a new comparison calculation. A late job using an older measurement revision may update the current comparison reference only after a version check; otherwise its result remains historical.Steps 6 and 7

Forecast API

Test and expected result
Measurement revisions 4 and 5 arrive in both orders. The current actual-value view remains at revision 5; the comparison using revision 4 remains available in history.
Return to an earlier step
Steps 3 and 5

Command journal

Test and expected result
Identical retries take effect once; changed content produces a conflict.
Return to an earlier step
Steps 4 and 7

Domain boundary check

Test and expected result
Test 899, 900 and 901 seconds. Expected result: an interval spans 900 seconds, inclusive at the start and exclusive at the end; a measurement at exactly 900 seconds starts the next interval.
Return to an earlier step
Step 2

Time-series revisions, run manifests and comparison versions

Test and expected result
A new correction to actual measurements does not alter a completed forecast run; it creates a new comparison revision with provenance.
Return to an earlier step
Steps 5 and 9

Forecast computation

Test and expected result
Accept a new measurement revision durably, then start a new comparison calculation. A late job using an older measurement revision may update the current comparison reference only after a version check; otherwise its result remains historical.
Return to an earlier step
Steps 6 and 7

First end-to-end test and outstanding evidence

End-to-end path
Test an actual-measurement correction after approval end to end. Accept a new measurement revision durably, then start a new comparison calculation. A late job using an older measurement revision may update the current comparison reference only after a version check; otherwise its result remains historical.
Clarify before extending the scope
Agree the real measurement-source contract, retention periods, recovery targets and assigned roles. Every limit here is a design assumption. The evidence table describes tests to execute; technical integration, browser checks and comprehension checks with readers follow separately.

Test an actual measurement correction after approval end to end

Test an actual measurement correction after approval end to end

Test an actual measurement correction after approval end to end.

A corrected measurement arrives after a forecast is finalised. The comparison reflects the correction while preserving the original forecast. Completion requires technical and business evidence.

Measurement revisions 4 and 5 arrive in both orders. The current actual-value view remains at revision 5; the comparison using revision 4 remains available in history. The exercise specifies the input and expected result.

Alternative considered
An initial end-to-end path limited to lists and forms postpones the critical state checks.
Trade-off
The first end-to-end path needs controlled concurrency and failure points.
Reassess
Passing the counterexample tests and checks with readers provides grounds for extending the case.

Try it yourself

Choose two architectural decisions: concurrency protection and evidence-backed completion. For each, name the test, expected result and step to revisit.

A hint for your attempt

Link the markers of the overall architecture with the associated design steps.

Compare with a possible solution
Concurrency control
Measurement revisions 4 and 5 arrive in both orders. The current actual-value view remains at revision 5; the comparison using revision 4 remains available in history. Expected invariant: Each comparison identifies the forecast version, measurement revision and matching time interval; later actual measurements do not change historical forecasts. A deviation leads back to step 5 and the command contract in step 4.
Test completion and retries
Start with a completed run that has an approved forecast version and a confirmed actual-value comparison. Submit an evidenced new actual revision for the same UTC interval and repeat the correction identically. Expected result: exactly one new comparison revision with provenance; the original forecast and historical completion comparison remain unchanged. Replay returns the same correction record without creating another comparison. Revisit step 9 for responsibility and step 7 for the failure sequence if results differ.

Apply to your project

Which two counterexample tests will you run first in your own end-to-end implementation?

Transfer the architecture and counterexamples to the editable Markdown design template.

Start your own design

Choose a small case from your project. The template collects the ten design tasks and leaves space for your sketches, decisions, and open assumptions. You can edit it in your text editor or note-taking app.

Download design template (.md)
Compare the ten tasks with the example case
  1. Purpose and boundary

    Which evidence for a forecast run would originate outside the application in your own project?

    In the example: Forecasts and actual measurements retain separate versions. A fictional analysis of a generation facility in fixed 15-minute intervals, with separate forecast and measurement versions.

  2. Requirements

    Which rule of your project remains binding even with slow processing?

    In the example: Check the time interval and unit before comparison. An interval spans 900 seconds, inclusive at the start and exclusive at the end; a measurement at exactly 900 seconds starts the next interval.

  3. Scale estimates

    Which single entity concentrates load more than the daily average when comparing generation and forecasts?

    In the example: Interval corrections need a separate load profile. An average of 1.11111 events/s says little about 96 interval corrections for one day at the same facility.

  4. Interfaces

    Which input fields make two change intentions different in your project?

    In the example: Approval binds the model and input version. The interval, model version, input hash and forecast energy must remain identical on replay.

  5. Data and states

    Which states must remain protected in your model against late replay?

    In the example: Corrections extend the comparison history. A new correction to actual measurements does not alter a completed forecast run; it creates a new comparison revision with provenance.

  6. Overall architecture

    Which planned service boundary would distribute a currently local guarantee across the network?

    In the example: Computation jobs use frozen manifests. Time-series revisions, run manifests and comparison versions must express the same valid state.

  7. Critical flow

    What feedback could be missing even though the underlying action has already taken place?

    In the example: Older jobs must not overwrite current measurement revisions. Each comparison identifies the forecast version, measurement revision and matching time interval; later actual measurements do not change historical forecasts.

  8. Bottlenecks and trade-offs

    Which similar display could have two different causes in your project?

    In the example: Investigate data gaps before model quality. Large forecast deviations may result from model errors or missing measurement intervals. Completeness, input age and forecast error are considered separately.

  9. Operations and security

    Which open state in your project needs a domain specialist as well as technical operations?

    In the example: Correction permissions are scoped to facilities. A new correction to actual measurements does not alter a completed forecast run; it creates a new comparison revision with provenance.

  10. Final design

    Which two counterexample tests will you run first in your own end-to-end implementation?

    In the example: Test an actual measurement correction after approval end to end. Measurement revisions 4 and 5 arrive in both orders. The current actual-value view remains at revision 5; the comparison using revision 4 remains available in history.