id Int @id @default(autoincrement())- Auto-incrementing primary key- Ensures unique records
Source Code:
src/gaia/agents/code/This is Part 2 of 3. If you haven’t completed Part 1, start there: Part 1: Introduction & Architecture
- Time to complete: 20-25 minutes
- What you’ll build: Understanding of how GAIA Code generates complete applications
- What you’ll learn: Schema generation, API creation, React components, MVP approach
- Platform: Runs locally on AI PCs with Ryzen AI (NPU/iGPU acceleration)
Generating Your First App
Let’s walk through creating a movie tracking app to understand each component.The Prompt
Component 1: Database Schema Generation
The agent’s first task is creating the database schema via Prisma.How Schema Generation Works
Generated Schema
From our movie tracker prompt:prisma/schema.prisma
title, genre→StringfieldsdateWatched→DateTimefieldscore out of 10→Intfield- Auto-added:
id,createdAt,updatedAt(standard fields)
Schema Features
Primary Keys & IDs
Primary Keys & IDs
Every model gets:
Timestamps
Timestamps
Automatic tracking:
createdAt DateTime @default(now())- When record was createdupdatedAt DateTime @updatedAt- Auto-updates on changes
Field Types
Field Types
LLM intelligently maps:
- Text →
String - Numbers →
IntorFloat - Dates →
DateTime - True/False →
Boolean - Optional fields →
String?(nullable)
Component 2: API Route Generation
Next, the agent creates REST API endpoints with validation.API Structure
For each model, the agent generates two route files:GET All Movies
src/app/api/movies/route.ts
POST Create Movie
src/app/api/movies/route.ts
PUT Update Movie
src/app/api/movies/[id]/route.ts
DELETE Movie
src/app/api/movies/[id]/route.ts
API Features
Validation
Zod schemas validate all inputs before database operations
Error Handling
Try-catch blocks with appropriate HTTP status codes
Type Safety
Full TypeScript integration with Prisma types
REST Standards
Proper HTTP methods and status codes
Component 3: React Component Generation
The agent generates four types of pages for each resource.Generated Page Structure
List View
src/app/movies/page.tsx
Create Form
src/app/movies/new/page.tsx
Component 4: Styling with Tailwind CSS
The agent applies consistent styling using Tailwind CSS.Generated Styles
src/app/globals.css
Styling Features
- Consistent color scheme
- Responsive design
- Form styling
- Button states
- Loading states
- Error messages
The MVP Creation Process
Understanding how the agent determines what to build:1
Analyze Prompt
LLM parses the user’s request and extracts key information
2
Identify Core Entities
Determines main models needed (e.g., “Movie”)
3
Extract Fields
Lists specific fields mentioned (“title, genre, date watched, score”)
4
Determine Types
Maps fields to appropriate types (String, DateTime, Int)
5
Generate Minimal Schema
Creates MVP schema without extra features
6
Build Full Stack
Generates API routes, React components, and styling
Working Examples
Here are verified prompts that generate complete applications:Movie Tracking App
Workout Tracking App
Restaurant Rating App
AI Tool Rating with Leaderboard
Simple Todo Tracker
What’s Next?
Part 3: Validation & Building
Learn how TypeScript validation works, the build process, and how the agent iterates to fix errors