This repository bridges OLTP and OLAP workflows using MongoDB as a NoSQL intermediary, offering a clean local + cloud interface to load and explore Supabase-style JSON exports.
It supports full-stack deployment across DEV (local) and PROD (Render + Streamlit Cloud) environments using a Makefile-based pipeline and environment-driven logic.
π₯ Download Demo Video (1.2MB)
Interactive MongoDB dashboard: JSON ingestion β Analytics β Streamlit visualization
οΏ½ How to watch: Click the thumbnail or download link above to save the video locally and watch the complete demo
git clone https://gitlab.com/stripe_b2/nosql.git
cd nosqlWe recommend uv for fast dependency installs:
uv venv
source .venv/bin/activate
uv syncRun make help to list all available targets.
make all ENV=DEVThis starts:
- MongoDB via Docker
- A data load from GCS (or local)
- FastAPI backend via Uvicorn
- Streamlit dashboard in a new tab
make prod_deploy ENV=PRODThis runs:
- Supabase β MongoDB data ingestion
- Git push to GitHub (for Streamlit Cloud triggers)
Explore your database manually:
make mongoshTo learn manual connection URIs, example aggregation queries, and how to debug your collections:
π Read π MongoDB Shell & Query Cheatsheet
The backend is environment-aware (ENV=DEV|PROD) and connects to either local Mongo or Atlas. It exposes:
/customers,/customers/{id}/subscriptions/active/charges/fraud/payment_intents/3ds
Run locally:
make apiThe Streamlit app reads from your backend API and lets you:
- Inspect customers, subscriptions, payment intents, and fraud patterns
- Query by endpoint
- Visualize 3DS usage and suspicious charges
Run locally:
make uiThe primary data ingestion script:
- Downloads the latest Supabase-style
db_dump_prod_*.jsonfrom GCS - Parses JSON by collection
- Writes to MongoDB
Run standalone:
ENV=PROD python scripts/gcs_to_mongo.py| Task | Tool | Command |
|---|---|---|
| Start MongoDB | Docker | make up |
| Load JSON to MongoDB | Python | make load |
| Launch API (DEV) | FastAPI | make api |
| Launch UI (DEV) | Streamlit | make ui |
| Query DB manually | mongosh | make mongosh |
| Full local pipeline | Makefile | make all ENV=DEV |
| Deploy to cloud | Makefile | make prod_deploy ENV=PROD |
| Run tests | pytest | make test |
At the root of the repo, create a file named .env with:
ENV=DEV
MONGO_URI=mongodb://localhost:27017
GCP_CREDS_FILE=your-raw-json-credentials-content-hereIf you're using MongoDB Atlas in production:
ENV=PROD
MONGO_URI=mongodb+srv://<user>:<pass>@cluster.mongodb.net/supabase_snapshot𧬠These variables are loaded automatically by
python-dotenvand are used across scripts and Streamlit/FastAPI.
To enable CI/CD pipelines on GitLab to push to GitHub (for example to trigger Streamlit Cloud redeploys), follow these steps:
Run locally:
ssh-keygen -t rsa -b 4096 -C "gitlab-ci@nosql" -f deploy_key_gitlab_to_github_rsaThis creates two files:
deploy_key_gitlab_to_github_rsa(private key)deploy_key_gitlab_to_github_rsa.pub(public key)
- Go to GitHub β Your repo β Settings β Deploy Keys
- Click "Add deploy key"
- Title:
GitLab CI deploy - Paste the contents of
deploy_key_gitlab_to_github_rsa.pub - β Enable βAllow write accessβ
- Go to GitLab β Settings β CI/CD β Variables
- Add a new variable:
| Key | Value | Type |
|---|---|---|
GITHUB_SSH_KEY |
Contents of deploy_key_gitlab_to_github_rsa |
π File |
β Must be a file-type variable for it to work with
ssh-agent.
Your pipeline should include:
before_script:
- eval "$(ssh-agent -s)"
- mkdir -p ~/.ssh
- echo "$GITHUB_SSH_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan github.com >> ~/.ssh/known_hostsIn your Makefile, ensure the push command uses:
git push github HEAD:mainπ‘οΈ SSH setup is only required if you're triggering GitHub deploys from GitLab CI via
make all ENV=PROD.
- π₯ͺ MongoDB Shell & Query Cheatsheet β manual queries & shell usage
- π Integration Guide (Mongo + FastAPI + Streamlit) β fullstack architecture, local & cloud setup
Supabase JSON (GCS/local)
β
MongoDB
β
FastAPI Backend
β
Streamlit Frontend
| Mode | MongoDB | API | UI |
|---|---|---|---|
| DEV | Local via Docker | Uvicorn | Streamlit localhost |
| PROD | MongoDB Atlas | Render | Streamlit Cloud |
Want to contribute or adapt this setup to your own OLAP/OLTP bridge? PRs welcome β¨