Skip to content

Budget Generation Process

This document provides a high-level sequence diagram of how the NGSB application generates budgets based on the district’s previous year budget files, district settings, and user-provided input from our Budget Wizard.

Step 1: Upload Previous Year Budget Files

In order for us to effectively generate budget files for the current year, we need to pull in data from the past 2 previous year budget files and (optionally) last year’s desegregation budget file.

When districts upload budget files, an asynchronous job will be started that extracts information from the file to be used later. This works by pulling down a Scribe “extraction” template from the bucket, injecting it with any necessary data, and then letting Scribe run the file.

The “extraction” templates should always include a series of COPY commands to gather data from the file, followed by a DUMP command. This command will export all of the currently copied values into a JSON file. This JSON file will then be read into memory and saved on the file itself. This allows the data to be easily accessible by the wizard for display/manipulation by the user.

sequenceDiagram participant UI %% For this diagram, the Backend represents the API, Worker, Database, and GCP Buckets participant B as Backend participant S as Scribe UI->>+B: District user uploads budget file B->>B: Start extraction job B->>-UI: Success/Error message B->>B: Search for extractor Scribe template related to the budget file B->>B: Inject data into Scribe template B->>+S: Extract wizard data from budget file using Scribe file S->>-B: Export JSON file of wizard data, insert into files table on budget file

Step 2: The Wizard

The wizard UI will begin by prompting the user to upload any missing files (if there are any missing), and then use the data extracted from the previous budget files to prompt the user with values to change.

As the user makes changes and navigates through the wizard, their answers are being recorded in the database and their current location in the wizard is being saved to their local storage. This guarantees that users can stop and come back whenever they like without losing their place.

sequenceDiagram participant UI %% For this diagram, the Backend represents the API, Worker, Database, and GCP Buckets participant B as Backend UI->>+B: Request data for wizard B->>-UI: Receive data for wizard %% In the future, we would like to make this more data-driven using some kind of %% declarative language, but for now this will be easy enough to add new %% wizards year-over-year UI->>UI: Generate wizard UI from wizard definitions file (year-based) loop UI->>+B: Save modified wizard data to account's fiscal year table as questions are answered B->>-UI: Success/Error message UI->>UI: Save wizard progress to user's local storage end

Step 3: Generate Budget

Once the user has completed the wizard and resolved each of the questions, they are presented with a final button to generate the budget. When they click this, an asynchronous job is started to fill out the current year’s budget template with the values determined in the wizard.

The job pulls down the district’s previous year budget files, the current year budget template, and the current year’s Scribe template for generating the budget file. It then injects the Scribe template with district data and filepaths, and sends it over to Scribe to populate the budget template. From there, it adds the completed budget file to the district and uploads it to the Google Cloud bucket for later downloading by the user.

sequenceDiagram participant UI %% For this diagram, the Backend represents the API, Worker, Database, and GCP Buckets participant B as Backend participant S as Scribe UI->>+B: Kick off budget generation job B->>-UI: Success/Error message B->>B: Download budget files, Scribe template, budget template B->>B: Inject modified wizard data and district settings into Scribe template B->>+S: Populate budget template with data using Scribe file S->>-B: Export final budget file B->>B: Upload final budget file