# ============================================================================== # Olist Agentic BI — Makefile (Kaggle Dataset Version) # ============================================================================== .PHONY: help setup setup-data start stop clean etl analytics test all help: ## Show this help @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' # ============================================================ # SETUP # ============================================================ setup: ## Install Python dependencies pip install -r requirements.txt setup-data: ## Download Olist dataset from Kaggle and extract @echo "Downloading dataset from Kaggle..." @mkdir -p data/raw kaggle datasets download -d olistbr/brazilian-ecommerce -p data/ @echo "Extracting CSV files to data/raw/..." unzip -o data/brazilian-ecommerce.zip -d data/raw/ || python3 -c "import zipfile; z=zipfile.ZipFile('data/brazilian-ecommerce.zip'); z.extractall('data/raw/')" @echo "Dataset ready in data/raw/" # ============================================================ # INFRASTRUCTURE # ============================================================ start: ## Start all Docker services docker-compose up -d @echo "Waiting for services to initialize..." @sleep 15 @echo "Services started. Kafka UI: http://localhost:8080" stop: ## Stop all Docker services docker-compose down restart: ## Restart all services docker-compose down && docker-compose up -d logs: ## View Docker logs docker-compose logs -f --tail=50 status: ## Check service status docker-compose ps # ============================================================ # ETL PIPELINE # ============================================================ etl: etl-bronze etl-gold ## Run full ETL pipeline etl-bronze: ## Bronze → Silver (requires data/raw/ CSV files) python transforms/bronze_to_silver.py --data-dir ./data/raw --output-dir ./data/silver etl-gold: ## Silver → Gold python transforms/silver_to_gold.py --silver-dir ./data/silver --output-dir ./data/gold etl-preprocess: ## Run data preprocessing python analytics/data_preprocessing.py --data-dir ./data/raw --output-dir ./data/processed # ============================================================ # ANALYTICS & ML # ============================================================ analytics: ## Run all analytics (requires data/raw/ CSV files) python analytics/association_rules.py --data-dir ./data/raw --output-dir ./data/analytics python analytics/customer_segmentation.py --data-dir ./data/raw --output-dir ./data/analytics python analytics/satisfaction_model.py --data-dir ./data/raw --output-dir ./data/analytics association: ## Run Association Rules Mining python analytics/association_rules.py --data-dir ./data/raw --output-dir ./data/analytics segmentation: ## Run Customer Segmentation (K-Means + DBSCAN) python analytics/customer_segmentation.py --data-dir ./data/raw --output-dir ./data/analytics ml-model: ## Run Satisfaction Prediction Models python analytics/satisfaction_model.py --data-dir ./data/raw --output-dir ./data/analytics # ============================================================ # STREAMING # ============================================================ stream: ## Start streaming simulator with Kaggle data python streaming_simulator/simulator.py --data-dir ./data/raw --speed 1000 stream-fast: ## Fast streaming (10000x, test mode) python streaming_simulator/simulator.py --data-dir ./data/raw --speed 10000 --max-events 5000 stream-test: ## Test data loading without Kafka (no Kafka required) python -c "from streaming_simulator.simulator import OlistStreamSimulator; \ sim = OlistStreamSimulator(data_dir='./data/raw', speed_factor=1000); \ sim.load_data(); \ print(f'Events loaded: {len(sim.events):,}'); \ from collections import Counter; \ c = Counter(e.event_type for e in sim.events); \ [print(f' {k}: {v:,}') for k, v in sorted(c.items())]" # ============================================================ # AGENTIC BI # ============================================================ agent: ## Start Agentic BI interactive session python agentic_bi/orchestrator.py app: ## Start Streamlit frontend streamlit run frontend/streamlit_app.py --server.port 8501 # ============================================================ # TESTING & QUALITY # ============================================================ test: ## Run tests python -m pytest tests/ -v quality: ## Run data quality checks python -c "from governance.data_governance import demo; demo()" # ============================================================ # CLEANUP # ============================================================ clean: ## Remove processed data (keep raw) rm -rf data/silver data/gold data/analytics data/processed @echo "Cleaned processed data. Raw data preserved in data/raw/" clean-all: clean ## Remove everything including Docker volumes docker-compose down -v @echo "All data and volumes removed." # ============================================================ # FULL PIPELINE # ============================================================ all: setup-data etl analytics ## Run complete pipeline @echo "============================================" @echo " PIPELINE COMPLETE!" @echo " Gold tables: data/gold/" @echo " Analytics: data/analytics/" @echo "============================================"