This guide covers local development setup, followed by full GCP deployment. Follow sections in order.
| Tool | Version | Install |
|---|---|---|
| Python | 3.12+ | Pre-installed on macOS or brew install python@3.12 |
| Docker Desktop | Latest | docker.com/products/docker-desktop |
| gcloud CLI | Latest | brew install google-cloud-sdk |
| Terraform | 1.7+ | brew install terraform |
| Astronomer CLI | Latest | brew install astro |
| git | Any | Pre-installed on macOS |
git clone https://github.com/iamdpsingh/Project-4-Financial-Risk-Fraud-Detection-Data-Platform.git
cd Project-4-Financial-Risk-Fraud-Detection-Data-Platformpython3.11 -m venv .venv
source .venv/bin/activate # macOS/Linux
# .venv\Scripts\activate # Windows
pip install --upgrade pip
pip install -e ".[dev]"cp .env.example .env
# Edit .env with your local values (PostgreSQL password, etc.)docker compose up -d
# Starts: PostgreSQL (5432), Pub/Sub emulator (8085), Adminer UI (8080)
# Verify services
docker compose ps
docker compose logs postgresAccess Adminer DB admin at: http://localhost:8080
- System: PostgreSQL
- Server: postgres
- Username: fraud_user
- Password: (from your .env)
- Database: financial_risk
python data/generators/generate_all.py \
--customers 10000 \
--merchants 2000 \
--transactions 500000
# Output: data/raw/<entity>/*.csv
# Also loads into PostgreSQL automaticallypython pipelines/batch/run_local.py \
--date $(date +%Y-%m-%d) \
--runner DirectRunner
# Output: data/processed/*.parquetpython data_quality/run_checks.py \
--suite all \
--environment local
# Opens Great Expectations Data Docs at http://localhost:8888pytest tests/ -v --cov=. --cov-report=html
# Open htmlcov/index.html for coverage report# Terminal 1 — Pub/Sub emulator should already be running via docker compose
# Terminal 2 — Start the Dataflow streaming pipeline locally
python pipelines/streaming/run_local.py \
--project local-project \
--runner DirectRunner
# Terminal 3 — Start the event generator
python data/generators/generate_streaming_events.py \
--rate 10 \ # 10 transactions/second
--duration 300 # run for 5 minutes
⚠️ Complete Part 1 (local) before attempting GCP deployment.
gcloud auth login
gcloud auth application-default logincd infrastructure/terraform
# Review and set variables
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your billing account, org ID, etc.
terraform init
terraform plan -out=tfplan
terraform apply tfplanThis creates:
- GCP project (
financial-risk-platform-<random-suffix>) - All GCP APIs enabled
- Service accounts with least-privilege IAM
- GCS bucket with folder structure + lifecycle policies
- BigQuery datasets (raw, staging, core, analytics)
- Pub/Sub topics and subscriptions
- Secret Manager secrets
- Artifact Registry repository
- Cloud Monitoring dashboards
cd airflow
astro dev init # first time only
astro dev start # starts local Airflow at http://localhost:8888
# For Cloud Composer deployment to GCP:
# See docs/cloud-composer-setup.md# Authenticate to Artifact Registry
gcloud auth configure-docker ${ARTIFACT_REGISTRY_REGION}-docker.pkg.dev
# Build and push ingestion API
docker build -t ${DOCKER_IMAGE_INGESTION_API}:latest ./docker/ingestion-api/
docker push ${DOCKER_IMAGE_INGESTION_API}:latestgcloud run deploy ${CLOUD_RUN_SERVICE_NAME} \
--image=${DOCKER_IMAGE_INGESTION_API}:latest \
--region=${CLOUD_RUN_REGION} \
--service-account=cloudrun-sa@${GCP_PROJECT_ID}.iam.gserviceaccount.com \
--no-allow-unauthenticated \
--set-secrets="PUBSUB_TOPIC=PUBSUB_TOPIC_TRANSACTIONS:latest"python ingestion/batch/upload_to_gcs.py \
--bucket=${GCS_BUCKET_NAME} \
--date-range 2024-01-01:2024-12-31python pipelines/batch/run_dataflow.py \
--project=${GCP_PROJECT_ID} \
--region=${GCP_REGION} \
--date 2024-12-31python pipelines/streaming/run_dataflow.py \
--project=${GCP_PROJECT_ID} \
--region=${GCP_REGION} \
--subscription=projects/${GCP_PROJECT_ID}/subscriptions/${PUBSUB_SUBSCRIPTION_DATAFLOW}Every push to main triggers:
- Ruff lint check
- Mypy type check
- Pytest unit tests
- Docker image build
- Push to Artifact Registry (tagged with commit SHA)
terraform planvalidation- Cloud Run deployment (on merge to
mainonly)
See .github/workflows/ for pipeline definitions.
See .env.example for the full list of required environment variables.
docker compose ps # check if postgres container is healthy
docker compose logs postgres# Ensure PUBSUB_EMULATOR_HOST is set in your shell
export PUBSUB_EMULATOR_HOST=localhost:8085
echo $PUBSUB_EMULATOR_HOST# Check Python path and that you're in the venv
which python # should point to .venv/bin/python
pip list | grep apache-beamterraform validate # check syntax
terraform plan # preview changes
gcloud projects list # verify project exists