MAM Implementation Roadmap
Based on: architecture.md (v1.0)
Author: Architect Agent
Date: 2026-02-24
Target: MVP in 4 weeks, beta in 6 weeks, first revenue in 8 weeks
Week-by-Week Breakdown
Week 1: Foundation & Infrastructure
Goal: Working backend skeleton + database + basic auth
Day 1-2: Project Setup
``bash`Repository structure
/mam
/backend # FastAPI
/app
/api # API routes
/core # Config, security, db
/models # SQLAlchemy models
/services # Business logic
/tasks # Celery tasks
/tests
requirements.txt
Dockerfile
/frontend # Next.js 15
/src
/app # App Router pages
/components # React components
/lib # Utils, hooks
package.json
Dockerfile
/docker # Docker Compose configs
/infra # Nginx, Prometheus, etc.
Tasks:
- [ ] Initialize Git repo, create branch structure (main, develop, feature/*)
- [ ] Docker Compose file: PostgreSQL 16, Redis 7, MinIO, Meilisearch
- [ ] FastAPI project init: poetry/pip, .env template, config loader
- [ ] Database connection: SQLAlchemy async engine, Alembic migrations
- [ ] Basic health check endpoint: GET /health returns DB status
Day 3-4: Database Schema
- [ ] Create all 8 tables from architecture.md schema
- [ ] Alembic migration: 001_initial_schema.py
- [ ] Seed data: admin user, test categories
- [ ] Indexes: agents (category, tags), agent_runs (partition setup)
- [ ] Test: Insert/query test data successfully
Day 5-7: Authentication System
- [ ] JWT token service: generate, verify, refresh
- [ ] User model: bcrypt password hashing, role enum
- [ ] Auth endpoints:
- POST /api/v1/auth/register — create userPOST /api/v1/auth/login
- — return access + refresh tokensPOST /api/v1/auth/refresh
- — rotate tokens@require_auth
- [ ] Auth middleware: decorator for protected routes
- [ ] Test: Register → login → call protected endpoint with JWT
Deliverables:
- Working FastAPI app with auth
- PostgreSQL schema deployed
- Docker Compose runs all services
- Health check returns green
Week 2: Meta-Agent Engine Core
Goal: First AI-generated agent from opportunity to published listing
Day 1-2: Market Intelligence Layer (MIL)
`python`/backend/app/services/market_intelligence.py
class MarketScanner:
async def scrape_reddit(self, subreddit: str) -> List[Post]
async def extract_problems(self, posts: List[Post]) -> List[Problem]
async def cluster_problems(self, problems: List[Problem]) -> List[OpportunityCard]
async def score_opportunities(self, cards: List[OpportunityCard]) -> List[OpportunityCard]
Tasks:
- [ ] Reddit scraper: PRAW library, fetch last 100 posts from r/entrepreneur
- [ ] LLM problem extractor: Claude Sonnet prompt to extract pain points
- [ ] Clustering: sentence-transformers embeddings + DBSCAN
- [ ] Opportunity scoring: frequency × urgency × monetization (LLM rates 0-10)
- [ ] Save to DB: market_opportunities table
- [ ] Celery task: scheduled every 4 hours
- [ ] Test: Run scan, verify opportunities saved with scores
Day 3-5: Meta-Agent Engine (MAE) Pipeline
`python`/backend/app/services/meta_agent_engine.py
class MetaAgentEngine:
async def generate_spec(self, opportunity: OpportunityCard) -> AgentSpec
async def generate_code(self, spec: AgentSpec) -> str # Python code
async def test_agent(self, code: str) -> TestResults
async def score_quality(self, code: str, tests: TestResults) -> float
async def publish_agent(self, code: str, spec: AgentSpec) -> Agent
Tasks:
- [ ] Stage 1: Spec generator (LLM: Claude Sonnet)
- Template: YAML agent spec format
- Prompt engineering: opportunity → complete AgentSpec
- Validation: Pydantic schema for AgentSpec
- [ ] Stage 2: Code generator (LLM: GPT-4o or Claude)
- Template library: 3 base templates (monitoring, data-processing, communication)
- Fill gaps with LLM
- Output: FastAPI endpoint + agent logic
- [ ] Stage 3: Automated tester
- Spin up Docker container with generated code
- Run 5 simulated inputs, check outputs
- Security scan: basic prompt injection tests
- Performance: measure response time
- [ ] Stage 4: Quality scorer
- LLM evaluator: usefulness, reliability, UX, safety (0-10)
- Threshold: >= 7.0 to proceed
- [ ] Stage 5: Publisher
- Build Docker image, push to local registry
- Generate marketing copy (Claude Haiku)
- Calculate price (algorithm from architecture.md)
- Insert into agents table, set status='published'
- Index in Meilisearch
Day 6-7: End-to-End Test
- [ ] Celery task: generate_agent_job pulls from opportunity queue/run
- [ ] Run full pipeline: opportunity → published agent
- [ ] Verify: Agent appears in DB, Docker image exists, Meilisearch indexed
- [ ] Manual test: Call agent's endpoint, get valid response
Deliverables:
- First AI-generated agent live
- MIL scans Reddit every 4h
- MAE generates agents autonomously
- Docker registry has agent images
Week 3: Marketplace & Frontend
Goal: Browse marketplace, demo agents, Stripe checkout
Day 1-2: Backend API (Public Endpoints)
`python/backend/app/api/v1/agents.py
@router.get("/agents")
async def list_agents(category: str = None, page: int = 1)
@router.get("/agents/{slug}")
async def get_agent(slug: str)
@router.post("/agents/{slug}/demo")
@rate_limit("3/hour")
async def demo_agent(slug: str, input: dict)
`
Tasks:
- [ ] List agents: pagination, category filter, sorting (quality, sales, recent)
- [ ] Agent detail: full spec, quality score, reviews (mock for now)
- [ ] Demo endpoint: run agent in sandbox, rate limit by IP (3/hour)
- [ ] Search integration: Meilisearch client, index on publish
- [ ] Categories endpoint: return unique categories from DB
Day 3-5: Frontend (Next.js)
``
/src/app
/page.tsx # Homepage: featured agents, categories
/agents/page.tsx # Marketplace: list with filters
/agents/[slug]/page.tsx # Agent detail: spec, demo, buy button
/dashboard/page.tsx # User dashboard (auth required)
Tasks:
- [ ] Homepage: Hero section, featured agents grid, CTA
- [ ] Marketplace page:
- Agent cards: name, description, price, quality badge
- Filters: category, price range
- Search bar (Meilisearch)
- "Created by AI" badge
- [ ] Agent detail page:
- Spec display, use cases
- Demo widget: input form → POST /demo → show result
- Pricing, "Buy Now" button
- Reviews section (mock data for MVP)
- [ ] Auth UI: Register/Login modals, JWT storage in cookies
- [ ] Dashboard: My subscriptions, usage stats (placeholder)
- [ ] Tailwind CSS + shadcn/ui components
Day 6-7: Stripe Integration
`python`/backend/app/services/stripe_service.py
class StripeService:
async def create_checkout_session(self, agent_id: str, user_id: str) -> str
async def handle_webhook(self, event: dict) -> None
Tasks:
- [ ] Stripe account: platform account (MAM Ltd)
- [ ] Create Checkout Session: returns URL for Stripe hosted page
- [ ] Webhook endpoint: POST /webhooks/stripecheckout.session.completed
- → create subscription recordinvoice.payment_succeeded
- → log revenue eventcustomer.subscription.deleted
- → mark canceled
- [ ] Frontend: "Buy Now" → create session → redirect to Stripe
- [ ] Post-purchase: redirect to dashboard, show API key
- [ ] Test: Buy agent with test card, verify subscription created
Deliverables:
- Marketplace live: browse, search, filter
- Agent demo works (rate limited)
- Stripe checkout flow complete
- First test purchase successful
Week 4: Agent Runtime & Polish
Goal: Agent execution environment, API keys, production-ready MVP
Day 1-3: Agent Runtime Environment (ARE)
`python`/backend/app/services/agent_runtime.py
class AgentRuntime:
async def deploy_agent(self, agent: Agent) -> str # returns container_id
async def run_agent(self, agent_id: str, user_id: str, input: dict) -> dict
async def check_quota(self, user_id: str, subscription_id: str) -> bool
async def log_run(self, agent_id: str, user_id: str, run_data: dict) -> None
Tasks:
- [ ] Docker agent deployment:
- Base image: Python 3.12-slim
- Install dependencies, copy agent code
- Expose port, health check
- Deploy to Docker daemon
- [ ] Run agent:
- Validate auth (JWT or API key)
- Check subscription active + within quota
- Forward request to agent container: POST /runagent_runs
- Log to table: input, output, tokens, duration
- Return result or job_id (for async)
- [ ] API key management:
- Generate on subscription creation
- Store as bcrypt hash, show only prefix in UI
- Rotate/revoke endpoints
- [ ] Usage metering:
- Redis counter: runs_today_user_{user_id}
- PostgreSQL flush every 60s (Celery task)
- Email notification at 80% quota
- [ ] Security:
- Rate limiting: 100 req/min per user (Redis sliding window)
- Input sanitization: strip