AI FundamentalsModule 5

5.3Capstone: Build Your AI Command Center

35 min 8 code blocks Practice Lab Quiz (4Q)

Capstone: Build Your AI Command Center

Congratulations — you have made it to the final lesson of AI Command & Control. You now understand multi-model strategy, API security, cost optimization, team governance, and RAG. This capstone lesson is your assembly manual. You are going to build a working AI Command Center: a personal or agency-level system that puts everything from this course into a single, coherent infrastructure. This is not a theoretical exercise — by the end of this lesson, you will have a functional system running on your machine.

Section 1: What Is an AI Command Center?

An AI Command Center is a centralized system that:

  • Manages your AI model selection intelligently (right model for right task)
  • Stores your business knowledge in a RAG system
  • Tracks costs automatically
  • Exposes a clean interface for you or your team to use

Think of it as your personal AI operations dashboard — the layer between your business workflows and the raw AI APIs. Professionals in Karachi, Lahore, and Islamabad who have built systems like this report saving 15-25 hours per week on tasks that previously required manual AI interaction.

code
WHY AN AI COMMAND CENTER?
┌──────────────────────────────────────────────────┐
│                                                    │
│  WITHOUT Command Center:                          │
│  ├── Open Claude tab → paste prompt → copy result │
│  ├── Open Gemini tab → paste prompt → copy result │
│  ├── Manually track which model you used          │
│  ├── No cost visibility                           │
│  ├── No knowledge base — re-explain everything    │
│  └── Time per task: 15-20 minutes                 │
│                                                    │
│  WITH Command Center:                             │
│  ├── One command → auto-routes to best model      │
│  ├── RAG pulls your business context              │
│  ├── Cost logged per task automatically            │
│  ├── Results saved and searchable                  │
│  └── Time per task: 2-3 minutes                   │
│                                                    │
│  Savings: 12+ hours/week = PKR 50,000+/month      │
│  (at PKR 1,000/hr consulting rate)                 │
└──────────────────────────────────────────────────┘

Section 2: Architecture Overview

code
┌─────────────────────────────────────────────────────────┐
│                  AI COMMAND CENTER                       │
├─────────────────────────────────────────────────────────┤
│                                                          │
│  ┌──────────────┐    ┌──────────────┐   ┌────────────┐ │
│  │ Task Router  │    │ Knowledge    │   │  Cost      │ │
│  │              │    │ Base (RAG)   │   │  Tracker   │ │
│  │ Gemini Flash │    │              │   │            │ │
│  │ → Simple     │    │ ChromaDB     │   │ Per-model  │ │
│  │ Claude Haiku │    │ + Your Docs  │   │ logging    │ │
│  │ → QC tasks   │    │              │   │            │ │
│  │ Claude Sonnet│    └──────────────┘   └────────────┘ │
│  │ → Complex    │                                       │
│  └──────────────┘                                       │
│         ↑                                               │
│  ┌──────────────────────────────────────────────────┐  │
│  │              Command Interface                    │  │
│  │   (CLI / Slack / Web form — your choice)         │  │
│  └──────────────────────────────────────────────────┘  │
│                                                          │
└─────────────────────────────────────────────────────────┘

Section 3: Building the Command Center

Step 1: Create the Project Structure

bash
mkdir ai-command-center
cd ai-command-center
mkdir knowledge_base outputs logs
touch .env main.py task_router.py rag_engine.py cost_tracker.py

Step 2: The Task Router (task_router.py)

python
import os
from anthropic import Anthropic
from google import genai

claude = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"))
gemini = genai.Client(api_key=os.environ.get("GEMINI_API_KEY"))

TASK_ROUTING = {
    "research": ("gemini", "gemini-2.5-flash"),
    "draft": ("gemini", "gemini-2.5-flash"),
    "strategy": ("claude", "claude-sonnet-4-6"),
    "qc": ("claude", "claude-haiku-4-5-20251001"),
    "code": ("claude", "claude-sonnet-4-6"),
    "complex": ("claude", "claude-sonnet-4-6"),
}

def route_task(task_type, prompt, max_tokens=1000):
    """Route to optimal model based on task type"""
    provider, model = TASK_ROUTING.get(task_type, ("claude", "claude-sonnet-4-6"))

    if provider == "gemini":
        response = gemini.models.generate_content(model=model, contents=prompt)
        return response.text, model
    else:
        message = claude.messages.create(
            model=model,
            max_tokens=max_tokens,
            messages=[{"role": "user", "content": prompt}]
        )
        return message.content[0].text, model

Step 3: The Cost Tracker (cost_tracker.py)

python
import json
from datetime import datetime
from pathlib import Path

COST_PER_1K_TOKENS = {
    "gemini-2.5-flash": {"input": 0.000075, "output": 0.0003},
    "claude-haiku-4-5-20251001": {"input": 0.00025, "output": 0.00125},
    "claude-sonnet-4-6": {"input": 0.003, "output": 0.015},
}
PKR_RATE = 285

def log_cost(model, input_tokens, output_tokens, task_type):
    rates = COST_PER_1K_TOKENS.get(model, {"input": 0.003, "output": 0.015})
    cost_usd = (input_tokens / 1000 * rates["input"]) + (output_tokens / 1000 * rates["output"])
    entry = {
        "timestamp": datetime.now().isoformat(),
        "model": model,
        "task": task_type,
        "input_tokens": input_tokens,
        "output_tokens": output_tokens,
        "cost_usd": round(cost_usd, 5),
        "cost_pkr": round(cost_usd * PKR_RATE, 2)
    }
    log_path = Path("logs/cost_log.jsonl")
    with open(log_path, "a") as f:
        f.write(json.dumps(entry) + "\n")
    return entry

def get_daily_summary():
    """Generate daily cost summary from logs."""
    log_path = Path("logs/cost_log.jsonl")
    if not log_path.exists():
        return "No cost data yet."
    
    today = datetime.now().strftime("%Y-%m-%d")
    daily_costs = {}
    daily_total = 0
    
    with open(log_path) as f:
        for line in f:
            entry = json.loads(line)
            if entry["timestamp"].startswith(today):
                model = entry["model"]
                daily_costs[model] = daily_costs.get(model, 0) + entry["cost_usd"]
                daily_total += entry["cost_usd"]
    
    report = f"\n=== DAILY AI COST REPORT ({today}) ===\n"
    for model, cost in sorted(daily_costs.items()):
        report += f"  {model}: ${cost:.4f} (PKR {cost * PKR_RATE:.2f})\n"
    report += f"  TOTAL: ${daily_total:.4f} (PKR {daily_total * PKR_RATE:.2f})\n"
    return report

Step 4: The Main Interface (main.py)

python
import sys
from task_router import route_task
from cost_tracker import log_cost, get_daily_summary

def command_center(task_type, prompt):
    print(f"\n[AI Command Center] Running task: {task_type}")
    result, model_used = route_task(task_type, prompt)

    # Estimate tokens (rough: 1 token = 4 chars)
    input_tokens = len(prompt) // 4
    output_tokens = len(result) // 4
    cost = log_cost(model_used, input_tokens, output_tokens, task_type)

    print(f"[Model: {model_used}] [Cost: PKR {cost['cost_pkr']}]")
    print(f"\nOUTPUT:\n{result}")
    return result

if __name__ == "__main__":
    if len(sys.argv) > 1 and sys.argv[1] == "costs":
        print(get_daily_summary())
    else:
        # Example: python main.py strategy "Write a 3-step growth plan for a Karachi restaurant"
        task = sys.argv[1] if len(sys.argv) > 1 else "strategy"
        prompt = sys.argv[2] if len(sys.argv) > 2 else "What is AI?"
        command_center(task, prompt)

Section 4: Extending the Command Center

Once the core works, add these modules over time:

code
EXTENSION ROADMAP
┌──────────────────────────────────────────────────────┐
│  WEEK 1: Core (task router + cost tracker)    ← NOW  │
│  WEEK 2: RAG engine (ChromaDB + your docs)           │
│  WEEK 3: Slack/WhatsApp interface                    │
│  WEEK 4: Team access (API key per team member)       │
│  MONTH 2: Client-facing dashboards                   │
│  MONTH 3: Automated workflows (cron-based tasks)     │
└──────────────────────────────────────────────────────┘

Adding a new task type is trivial:

python
# Add to TASK_ROUTING in task_router.py:
"translate": ("gemini", "gemini-2.5-flash"),  # Urdu↔English translation
"legal": ("claude", "claude-sonnet-4-6"),     # Contract review
"social": ("gemini", "gemini-2.5-flash"),     # Social media posts

Each new task type costs zero development time — just one line in the routing dictionary.

Pakistan Case Study: 0213 Solutions Lahore Agency

Ahmed runs a small digital agency in Lahore with 3 team members. Before building their AI Command Center, the team's AI usage was chaotic:

Before:

  • Each team member had their own Claude/Gemini subscriptions (PKR 15,000/month total)
  • No cost visibility — month-end surprises
  • Same questions asked to AI repeatedly (no knowledge base)
  • Client proposals took 3-4 hours each
  • AI output quality varied wildly (no QC routing)

After building their Command Center:

MetricBeforeAfter
Monthly AI spendPKR 15,000PKR 4,200 (API-based)
Proposal generation time3-4 hours45 minutes
Client report generation2 hours20 minutes
Cost visibilityNoneReal-time dashboard
Knowledge retentionZero (re-explain every time)RAG with 200+ docs
Team consistencyEach person, different qualityStandardized via routing

Ahmed's key insight: "The Command Center isn't about AI — it's about systems. When every task goes through the router, the junior team member produces the same quality output as the senior one. The RAG engine means we never lose institutional knowledge when someone leaves. And the cost tracker means I know exactly how much each client project costs in AI spend."

Monthly savings: PKR 10,800/month in subscriptions + ~60 hours/month in time savings. At their billing rate of PKR 2,000/hour, that's PKR 120,000+ in recovered capacity per month.

Practice Lab

Practice Lab

Exercise 1: Run the Command Center Follow the code above, create the project, install dependencies (pip install anthropic google-genai), and run it with 5 different task types. Verify that different tasks route to different models. Check logs/cost_log.jsonl to confirm costs are being tracked.

Exercise 2: Add Your Knowledge Base Take 3 documents from your business (client briefs, project specs, SOPs) and add them to a RAG engine using ChromaDB. Integrate a rag_answer function into your command center so that a "knowledge" task type queries your documents before generating a response.

Exercise 3: Monthly Cost Report After running your command center for a week, write a Python script that reads logs/cost_log.jsonl and generates a summary: total spend per model, most expensive task type, average cost per task, and projected monthly cost. Format it as a clean report with both USD and PKR values. This is your AI CFO report.

Exercise 4: Team Access Layer Add a simple API key system to your command center. Each team member gets a unique key (stored in a JSON file). Every task logged includes who ran it. Build a team_report() function that shows: tasks per team member, cost per team member, most-used task types per person. This is how you manage AI usage in an agency setting.

Key Takeaways

  • An AI Command Center centralizes your multi-model strategy, RAG knowledge base, and cost tracking in one system — eliminating the chaos of individual AI subscriptions and ad-hoc usage
  • The task router automatically selects the optimal model based on task type, saving cost without sacrificing quality — Gemini for cheap research, Haiku for QC, Sonnet for complex reasoning
  • Cost tracking in both USD and PKR gives you real financial visibility over your AI operations — most Pakistani agencies have no idea what they spend on AI until the bill arrives
  • The system starts simple and grows — add new task types, new documents, new team interfaces as you scale, without rewriting any core logic
  • RAG integration means your AI remembers your business context across every interaction — no more re-explaining your client list, pricing, or project history
  • For Pakistani agencies, the Command Center approach typically saves PKR 10,000-50,000/month in subscriptions alone, plus 40-60 hours of team time
  • You now have everything you need to operate AI at a professional, enterprise level — the same infrastructure pattern that powers agencies generating $5,000+/month with minimal human overhead

Lesson Summary

Includes hands-on practice lab8 runnable code examples4-question knowledge check below

Capstone: Build Your AI Command Center Quiz

4 questions to test your understanding. Score 60% or higher to pass.