- Overview
- Getting Started
- Set up the WBR App
- Using the WBR App
- Testing
- Additional Information
- Toolchain used for developing WBR
- License
- Helpful Links
The WBR App is a web application that takes your organization's business data and builds an HTML-based report called a WBR Report, so that you can implement an Amazon-style WBR process in your organization.
Most data visualization applications such as Tableau and Looker cannot generate an Amazon-style WBR Report out of the box. The WBR App was created to reduce the effort it takes to ingest, transform, and visualize your business data, so you can focus on improving your business performance each week. In addition to the HTML WBR Report, the WBR App also produces a JSON version of your WBR Report, so you can quickly import the transformed data without reprocessing it.
The WBR Report allows you to quickly review hundreds of metrics and easily spot noteworthy variances in the data. A well-constructed WBR provides a comprehensive, data-driven answer to the following three questions each week:
- How did the business do last week?
- Are we on track to hit our targets?
- What did our customers experience last week?
This document explains how to install an instance of the WBR App by cloning the code repository and running it locally in your own environment. Additionally, you can customize the source code based on your needs and even contribute to the WBR App Git repository.
To get started, you'll need to install the necessary software and run the application on your computer. The following steps will guide you through this.
The WBR App uses a WBR Configuration File (.yaml format) to define the structure and content of your report. Data
for the report can be provided in one of two ways:
- CSV File (Recommended for simplicity and backward compatibility): You can upload a
.csvfile directly in the UI. This is the easiest way to get started and is ideal for users who do not have a database. - Database Connection (For automated workflows): You can configure the WBR App to fetch data directly from a database like PostgreSQL, Snowflake, Amazon Athena, or Amazon Redshift.
The application generates the WBR Report in an HTML page. You can also download a JSON representation of your WBR Report.
The WBR App determines the data source using the following logic:
-
CSV File Upload (highest priority).
If a CSV file is uploaded via the UI, that uploaded CSV is used for the report and overrides any data specified in your WBR configuration file. This is intended for quick ad-hoc analysis and testing. -
data_sourcesin the WBR configuration file (used when no CSV is uploaded).
If no CSV is uploaded, the app uses thedata_sources:section of your main WBR config YAML to find one or more named data sources. Adata_sourcesentry can include:-
Database queries — keyed by a connection name that must match the
nameof a connection in your external Connections YAML. Each connection key may contain one or more named queries (aliases). These queries are executed against the referenced connection and the returned result sets are used as data sources for the WBR. -
CSV files — you can also define CSV sources inside
data_sources( under acsv_fileskey) where each source points to a URL or local path. Thedata_sourcessection may therefore contain any combination of database queries and CSV files; the app will load all declared sources and merge them as needed for the report.
Notes / Requirements
-
If you use database queries, you must add a
db_config_urlin your main WBR config that points to your Connections YAML (which contains credentials and connection definitions). The connectionnameindata_sourcesmust match anameentry in that Connections YAML. -
Every query used by the WBR must return the date/timestamp as the first column aliased
"Date"(for example,SELECT event_timestamp AS "Date", ...). The rest of the columns are the metric columns referenced in yourmetricssection. -
When you define multiple named queries (aliases) under a connection, those aliases are used as prefixes for columns in the merged dataset (for example,
main_metrics.Impressions).
-
-
No data source → error.
If the user has not uploaded a CSV and there are nodata_sourcesdefined in the WBR config (or the defineddata_sourcescannot be resolved), the application will show an error indicating that no data source was found.
# In your main WBR config.yaml
db_config_url: "https://your-host.com/path/to/your/connections.yaml"
data_sources:
MyProdPostgres: # MUST match a connection 'name' in your connections.yaml
main_metrics:
query: >
SELECT
event_date as "Date",
SUM(sales_value) as total_sales
FROM daily_sales_aggregates
GROUP BY event_date
ORDER BY event_date ASC;
csv_files:
external_metrics:
url_or_path: /path/to/external_metrics.csvThis example shows a mix of database queries (under MyProdPostgres) and CSVs (under csv_files). The WBR App
will load the uploaded CSV (if present) or — if no upload — will load the named data sources above and merge them on
the Date column.
See the Configuring Database Connectivity section below for the full Connections YAML and db_config_url / data_sources examples.
To connect to a database, you need to configure two files:
-
Connections YAML File:
-
Purpose: This file stores the connection details for one or more databases. It is not stored in the WBR App project itself but is hosted at a URL or a file path that you provide.
-
Structure:
# Example for local connections.yaml files version: 1.0 connections: - name: "MyProdPostgres" # A unique name for your connection type: "postgres" # Supported types: postgres, snowflake, athena, redshift description: "Production PostgreSQL DB for core metrics." # Optional config: host: "your_postgres_host.com" port: 5432 username: "db_user" password: "your_pg_password" # WARNING: Avoid hardcoding secrets. Use a secrets manager. database: "metrics_db" - name: "AnalyticsSnowflake" type: "snowflake" config: user: "snowflake_user" password: "your_sf_password" # WARNING: Avoid hardcoding secrets. account: "your_snowflake_account_id" warehouse: "COMPUTE_WH" database: "ANALYTICS_DB"
# Example for public connections.yaml files version: 1.0 connections: - name: "MyProdPostgres" # A unique name for your connection type: "postgres" # Supported types: postgres, snowflake, athena, redshift description: "Production PostgreSQL DB for core metrics." # Optional config: service: aws secret_name: my-secret
-
Security Note: It is strongly recommended to use a secure method for managing secrets like passwords and keys (e.g., AWS Secrets Manager) and have your application retrieve them at runtime, rather than hardcoding them in this file.
-
Note: As of now the WBR application only support AWS secrets manager, but in future we will release support for Google Secrets Manager, Azure Secret Vault.
-
-
WBR Configuration File (e.g.,
config.yaml):-
To use a database, you must add two sections to your main WBR configuration file:
db_config_urlanddata_sources. -
db_config_url: A single field that points to the location of your Connections YAML file.# In your main WBR config.yaml db_config_url: "https://your-host.com/path/to/your/connections.yaml"
-
data_sources: This section specifies which connection to use and what query to run. It uses a more readable dictionary-based format.# In your main WBR config.yaml data_sources: MyProdPostgres: # This key MUST match a 'name' from your connections.yaml main_metrics: # Aggregates total sales and user count by day query: > SELECT event_date as "Date", -- The date column MUST be the first column and aliased to "Date" SUM(sales_value) as total_sales, COUNT(DISTINCT user_id) as active_users FROM daily_sales_aggregates GROUP BY event_date ORDER BY event_date ASC; csv_files: external_metrics: # A descriptive name for your csv source url_or_path: /path/to/your/csv
-
Query Requirements:
- The key under
data_sources(MyProdPostgresin the example) must match thenameof a connection in your Connections YAML file. - The first column in your
SELECTstatement must be the date/timestamp column, and it must be aliased as"Date"(e.g.,select event_timestamp as "Date", ...). The rest of the WBR framework relies on this convention. - The other columns returned by your query are what you will reference in the
metricssection of your WBR config.
- The key under
-
Metric Section
- While defining metric you need to use alias, so that there would be no duplicates in the final merged daily dataframe
- If following is you data_source
data_sources: MyProdPostgres: main_metrics: # A descriptive name for your query query: > # "Aggregates total sales and user count by day" SELECT date as "Date", "Impressions" FROM wbr_sample_1;
Then the metric that you define in the metric section will now look like this
Impressions: column: main_metrics.Impressions aggf: sum
The
main_metricswill be used as the alias for all the columns from the main_metrics data_source -
Annotations Section
- You can optionally attach annotations to your report – for example, special events, launches, outages, or promotions that should be surfaced on charts.
- Configure an
annotationslist in your main WBR config YAML; each entry is a CSV path or URL that contains at least aDatecolumn plus one or more descriptive columns. Example:annotations: - https://your-host.com/path/to/special_events.csv - /path/to/local_events.csv
- These CSVs are read and merged alongside your main data so that events can be rendered in the WBR deck (for example, marked on 6_12 charts where relevant metrics are plotted).
-
- Processor - 4 Core Processor (Minimum)
- RAM size - 4GB RAM (Minimum)
- Python 3.12.x
- git 2.41.0
- Open your terminal.
- Navigate to the directory where you want to store the project.
- To get a copy of the application's code on your computer, run the following command to clone (download) the repository.
git clone https://github.com/working-backwards/wbr-app.git
- Navigate into the project directory:
Now, you have a local copy of the project on your machine!
cd wbr-app
- Open command prompt.
- Navigate to the directory where you want to store the project.
- Run the following command to clone the repository:
git clone https://github.com/working-backwards/wbr-app.git
- Navigate into the project directory:
Now, you have a local copy of the project on your machine!
cd wbr-app
- Set Up a Python Virtual Environment
Create a virtual environment in thewbr-appdirectory by running the following command:python3.12 -m venv "venv" - Activate the Virtual Environment
Activate the virtual environment by running:source venv/bin/activate - Install Dependencies
Once the virtual environment is active, install the required packages:pip install -r requirements.txt
- Run the Application
Start the app with the following command:
After successfully running the command, you should see output similar to the following
waitress-serve --port=5001 --call src.controller:start
Note: you might encounter port conflicts, so feel free to change the port.INFO:waitress:Serving on http://0.0.0.0:5001
Once the command is successful, the application will be running, and you can open your web browser and navigate to http://localhost:5001/wbr.html to view the WBR App.
- Set Up a Python Virtual Environment
Create a virtual environment in thewbr-appdirectory by running the following command:py -m venv venv
- Activate the Virtual Environment
To activate the virtual environment- Change to the venv\Scripts directory:
cd venv\Scripts
- Type activate and press enter to activate the environment:
activate
- Change to the venv\Scripts directory:
- Return to the Project Directory
Navigate back to thewbr-appdirectory:cd ..\..\
- Install Dependencies
Once the virtual environment is active, install the required packages:pip install -r requirements.txt
- Run the Application
Run the app with the following command:
After successfully running the command, you should see output similar to the following
waitress-serve --port=5001 --call src.controller:start
Note: you might encounter port conflicts, so feel free to change the port.INFO:waitress:Serving on http://0.0.0.0:5001
Once the command is run successful, the application will be running, and you can open your web browser and navigate to http://localhost:5001/wbr.html to view the WBR App.
To access the WBR App route your browser to http[s]://<domain>/wbr.html.
To create a WBR Report, you have two primary options:
Option A: Using a CSV File
- In the WBR App UI, click the menu button to open the side panel.
- Upload your dataset as a
.csvfile in the Weekly Data input section. - Upload your WBR Configuration
.yamlfile in the Configuration input section. - Click the
Generate Reportbutton.
Option B: Using a Database
- Prepare your WBR Configuration YAML file. It must contain:
- A
db_config_urlpointing to your hosted Connections YAML file. - A
data_sourcessection with your connection name and SQL query ( see Data Source Configuration for details).
- A
- In the WBR App UI, open the side panel.
- Upload only your WBR Configuration YAML file in the Configuration input section. Do not upload a CSV file.
- Click the
Generate Reportbutton. The app will fetch data from your database to generate the report.
To download the JSON file, follow the below steps,
- When a WBR report is generated a JSON button will be displayed on the application.
- Clicking on the button will download the report's JSON file on to your browser
This helps you create a WBR report on your browser without the data file and/or the config file. To accomplish this please follow the below steps.
- To create a WBR report with a JSON file you should have a valid WBR supported JSON file.
- In the side menu when clicked on
Upload JSON and generate reportlink a form will be popped which will accept a valid JSON file. - After uploading the JSON file click the
Uploadbutton to generate a WBR report.
This feature lets you publish a report, you can also publish the report with the password protection, follow the below steps to accomplish this,
- When the report is generated, a
PUBLISHbutton is displayed on the application. - When clicked on that button, a form will be popped which will let you publish the report to a URL.
- If you want to add the password protection to your report then click on the checkbox and publish the report or else you can just publish the report.
- When you click the
PUBLISHbutton in the form the report will be persisted, and a URL will be generated for it. - To view the report, copy the published URL, paste it into your web browser, and the report will be displayed.
NOTE:
If you have published the URL with password protection, the application will ask you to enter the password before you render the report onto your browser.
The reports will be saved to the local project directory named publish, if you want to save the reports to the cloud storages like s3 or gcp or azure cloud you need to use the following environment variables
-
ENVIRONMENT:
Optional. Specifies the environment and saves the files within this particular environment directory. -
OBJECT_STORAGE_OPTION:
Optional. Specifies the cloud storage service for saving reports. Supported values ares3,gcp,azure. If not provided, reports will be saved to the local project directory. -
OBJECT_STORAGE_BUCKET:
This is required only if you have set the OBJECT_STORAGE_OPTION environment variable. If you are using OBJECT_STORAGE_OPTION ass3orgcporazureyou must first create your own storage bucket. Set OBJECT_STORAGE_BUCKET equal to either S3 bucket name or GCP bucket name or Azure storage container name.
Depending on your cloud provider, define the following environment variables
- AWS_STORAGE_KEY: Your AWS Access Key ID.
- AWS_STORAGE_SECRET: Your AWS Secret Access Key.
- AWS_REGION_NAME: The AWS region where your bucket is hosted.
- S3_STORAGE_ENDPOINT: [Optional] Specifies the endpoint where reports will be stored. If not provided, reports will
be published to the
OBJECT_STORAGE_BUCKET.
Alternatively, you can use the IAM that have been set up for your local system instead of setting these environment variables.
NOTE: You can also use the same environment variables for any S3 compatible storage.
- GCP_SERVICE_ACCOUNT_PATH: Provide the JSON token file path that you downloaded from the Google Cloud.
- GCLOUD_PROJECT: If you are using IAM to authenticate then you need to set this environment variable with the project id for the cloud storage.
- AZURE_CONNECTION_STRING: The connection string from your Azure Storage Account's access keys, while setting this environment variable please encompass the value within double quotes.
- AZURE_ACCOUNT_URL: If you are using IAM to authenticate then you need to set this environment variable with the project id for the cloud storage.
To set the environment variables on your system use the following syntax
# Mac / linux:
export VARIABLE_NAME=value
# Windows:
SET VARIABLE_NAME=valueAfter setting the above environment variables you need to rerun the application using the following command
waitress-serve --port=5001 --call src.controller:startThis feature helps you create a starter WBR configuration file from a sample CSV. This is useful for quickly scaffolding
the metrics and deck sections.
Note: The generated YAML is a template. If you plan to use a database, you must edit the file to add your
db_config_url and data_sources sections.
To use this feature:
- Click on the
Generate YAMLbutton in the UI. - Upload a CSV data file that has the same columns you expect to get from your future database query.
- Click the
Downloadbutton to get the generatedwbr_config.yamlfile. - Open the file and make the following edits:
- Add the
db_config_urlfield, pointing to your Connections YAML file. - Add the
data_sourcessection with your connection name and SQL query. - Ensure the
metricssection correctly references the column names from your SQL query. - Update
setupfields likeweek_endingandtitle.
- Add the
We have a feature where you can install our AI plugin to generate the config file using the same instructions as above. To install the plugin you will have do the following.
- Clone the repository https://github.com/working-backwards/wbr-ai-yaml-generator.
- Follow the instruction to build and install the plugin from the README.md of the same repository.
- Once you have completed the installation of the plugin add the environment variables OPENAI_API_KEY and ORGANISATION_ID.
- Run the controller.py
After this plugin is installed, the AI yaml generator replaces the default rules-based yaml generator.
- OPENAI_API_KEY: Your API key provided by OpenAI.
- ORGANISATION_ID: Your organisation ID provided by OpenAI.
To set the environment variables on your system use the following syntax
# Mac / linux:
export VARIABLE_NAME=value
# Windows:
SET VARIABLE_NAME=valueAfter setting the above environment variables you need to rerun the application using the following command
waitress-serve --port=5001 --call src.controller:startAccess our automated test suite, which scans test input files from the directory, src/unit_test_case.
The test suite iterates through all scenarios from all the scenario folders, generates WBR reports, and compares results with the testconfig.yml file.
Note: Each scenario folder must contain the original.csv (data), config.yaml (configuration), and a testconfig.yml (expected result) files.
A web user interface is been developed to run the test cases, route your browser to http[s]://<domain>/unit_test_wbr.html and click Run Unit Tests button.
- For queries on customizing or building additional WBR metrics, contact [email protected].
For detailed information on how to use the WBR App's API, please refer to the API Documentation. This document provides comprehensive details on the available endpoints, request parameters, and response formats.
- Python 3.12.x compiler
- PIP Python Package Management System
- JetBrains PyCharm Community Edition IDE
The WBR App is developed and maintained by the Working Backwards engineering team. The WBR App is released under the MIT License (https://opensource.org/licenses/MIT). For more information on licensing, refer to the LICENSE.md file.