Skip to content

Story 7.1: Database Schema + Mastra Setup (3 pts) #33

@Peleke

Description

@Peleke

Epic 7: LLM-Powered Content Generation

Story 7.1: Database Schema + Mastra Setup

Scope (3 pts, ~4.8 hours)

Foundation setup for Mastra workflow system and database schema.

Tasks

  • Create ai_generations table with Supabase migration
  • Add indexes on (lesson_id, generation_type, created_at)
  • Set up Mastra project structure (lib/mastra/)
  • Configure OpenAI/Anthropic provider
  • Create base workflow config with error handling
  • Add environment variables for API keys
  • Test database connection and basic workflow execution

Database Schema

```sql
CREATE TABLE ai_generations (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
lesson_id UUID NOT NULL REFERENCES lessons(id),
generation_type TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'pending',
input_data JSONB NOT NULL,
output_data JSONB,
tokens_used INTEGER,
cost_usd DECIMAL(10,6),
error TEXT,
created_at TIMESTAMPTZ DEFAULT NOW(),
completed_at TIMESTAMPTZ
);
```

Success Criteria

  • Database migration runs successfully
  • Mastra initializes without errors
  • Can execute simple test workflow
  • Environment properly configured

Related: PR #32, docs/prd/EPIC_7_MASTRA_ARCHITECTURE.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestepic:07-llm-genEpic 7: LLM-Powered Content Generation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions