A demonstration of an easy-to-start, end-to-end business intelligence pipeline using modern data engineering tools.
This repository showcases a complete BI pipeline that:
- Ingests raw order data into PostgreSQL
- Transforms data using SQLMesh's incremental processing
- Provides analytics-ready tables for visualization
- Serves dashboards via Metabase
Data Flow:
- Ingestion: Python script generates and loads dummy order data into
raw.orders - Transformation: SQLMesh transforms data through models:
stg_orders: Filters valid orders (excludes cancelled/refunded)fct_revenue: Aggregates daily revenue metrics
- Visualization: Metabase connects to transformed data for dashboards
Ensure you have the following installed:
- Docker - For running Postgres and Metabase
- uv - Fast Python package manager and runner
Inside the repo, launch Postgres and Metabase in the background:
docker compose up -duv syncLoad dummy data into the raw schema:
uv run ingestion/ingest.pyThis creates:
- Schema:
raw - Table:
raw.orders(50 sample orders)
Apply models to the dev environment for testing:
uv run sqlmesh plan devReview the plan and confirm to apply. Use database admin tools to inspect the created schemas and tables.
Promote the validated models to production:
uv run sqlmesh plan prodSQLMesh will automatically create new schema for dev and prod environment upon first run as specify in a models file, in this case it's store_dev and store respectively
business-intelligence-demo/
├── config.yaml # SQLMesh configuration
├── docker-compose.yaml # Postgres & Metabase services
├── pyproject.toml # Python dependencies
├── ingestion/
│ └── ingest.py # Data ingestion script
├── models/
│ ├── stg_orders.sql # Staging model: filter valid orders
│ └── fct_revenue.sql # Fact model: daily revenue metrics
Once services are running:
- Open your browser and navigate to:
http://localhost:3000 - Set up your Metabase account (first time only)
- Connect to the database
- Build dashboards using the transformed data from the
storeschema
Available schemas in Metabase:
You can setup Metabase to only allow query from store (prod)
- Normally
ingestion/ingest.pywill be your ETL script (can be somewhere else) - Edit SQL files in the
models/directory - Run
uv run sqlmesh plan devto test changes - Validate results using a database tool (e.g., DBeaver, pgAdmin)
- Run
uv run sqlmesh plan prodto deploy to production
Your data in raw schema will never touched again after ingestion, the only thing that change over time is your SQLMesh models, learn more using keyword medallion architecture
Stop and remove all containers and volumes:
docker compose down -v # -v removes volumes including Postgres dataThis is a demonstration project. Feel free to fork and customize for your own BI pipeline needs.
This project is a public domain.