Serverpod Architecture & Development Guide
Overview
Serverpod splits projects into three modules: server, client, and shared. Models defined in .spy.yaml files generate type-safe Dart classes and database migrations via serverpod generate.
Process
High-Level Workflow
Phase 1: Research & Modeling
1.1 Understand Project Structure
Serverpod separates code into server, client, and shared modules. Endpoint logic lives in server; generated client code goes into client.
1.2 Define Data Models
Define database models using .spy.yaml files, then run serverpod generate to produce Dart classes and database migrations. Use explicit foreign key mappings for relational tables.
Phase 2: Implementation
2.1 Develop Endpoints
Implement business logic inside endpoint classes. Use session parameters for authentication context, built-in caching, and native JSON serialization.
2.2 Authentication & Caching
Use the serverpod_auth module for token-based authentication. Configure Redis for caching to reduce repeated database queries.
2.3 Database-less Backends (Serverpod Mini)
Use Serverpod Mini when you only need proxy/BFF endpoints without a PostgreSQL database.
Phase 3: Deployment
3.1 Docker & Production
Use docker-compose to orchestrate local and production environments. Configure environment variables for credentials and connection strings.
Reference Files
Documentation Library
Core Framework (Load First)
Schema and Logic (Load During Phase 1/2)
Security, Scaling & Testing (Load During Phase 2/3)
1---
2name: "developing-serverpod-backend"
3description: "Develops full-stack Dart backends using the Serverpod framework with PostgreSQL, Redis, and Docker. Use when building type-safe API endpoints, defining YAML data models, configuring Serverpod auth, writing server-side tests, running database migrations, deploying to Docker/AWS/GCP, or using Serverpod Mini for database-less BFF proxy endpoints."
4metadata:
5 source: https://skillmd.com/skills/aibot88/developing-serverpod-backend
6 last_modified: "2026-04-01 14:35:00 (GMT+8)"
7---
8
9# Serverpod Architecture & Development Guide
10
11## Overview
12
13Serverpod splits projects into three modules: `server`, `client`, and `shared`. Models defined in `.spy.yaml` files generate type-safe Dart classes and database migrations via `serverpod generate`.
14
15---
16
17# Process
18
19## High-Level Workflow
20
21### Phase 1: Research & Modeling
22
23#### 1.1 Understand Project Structure
24Serverpod separates code into `server`, `client`, and `shared` modules. Endpoint logic lives in `server`; generated client code goes into `client`.
25
26#### 1.2 Define Data Models
27Define database models using `.spy.yaml` files, then run `serverpod generate` to produce Dart classes and database migrations. Use explicit foreign key mappings for relational tables.
28- [Core Architecture & Models Guide](./references/core-and-models.md) - YAML model definitions, project structure, and relationship mapping.
29
30---
31
32### Phase 2: Implementation
33
34#### 2.1 Develop Endpoints
35Implement business logic inside endpoint classes. Use session parameters for authentication context, built-in caching, and native JSON serialization.
36- [Endpoints & Database Guide](./references/endpoints-and-database.md) - Typed ORM queries, transactions, and API endpoint patterns.
37
38#### 2.2 Authentication & Caching
39Use the `serverpod_auth` module for token-based authentication. Configure Redis for caching to reduce repeated database queries.
40- [Authentication & Caching Guide](./references/auth-and-caching.md) - `serverpod_auth` setup, endpoint protection, and Redis caching.
41
42#### 2.3 Database-less Backends (Serverpod Mini)
43Use Serverpod Mini when you only need proxy/BFF endpoints without a PostgreSQL database.
44- [Serverpod Mini Guide](./references/serverpod-mini.md) - Lightweight API routing without database dependencies.
45
46---
47
48### Phase 3: Deployment
49
50#### 3.1 Docker & Production
51Use `docker-compose` to orchestrate local and production environments. Configure environment variables for credentials and connection strings.
52- [Deployment & Docker Guide](./references/deployment-and-docker.md) - Production Dockerfiles, AWS/GCP deployment, environment configuration.
53
54---
55
56# Reference Files
57
58## Documentation Library
59
60### Core Framework (Load First)
61- [Serverpod Overview](./references/overview.md) - Setup, project structure, and architecture decisions.
62
63### Schema and Logic (Load During Phase 1/2)
64- [Core Architecture & Models Guide](./references/core-and-models.md) - YAML models, database schema, directory structure.
65- [Endpoints & Database Guide](./references/endpoints-and-database.md) - ORM, typed queries, API endpoints.
66- [Serverpod Mini Guide](./references/serverpod-mini.md) - Database-less proxy routing.
67
68### Security, Scaling & Testing (Load During Phase 2/3)
69- [Authentication & Caching Guide](./references/auth-and-caching.md) - `serverpod_auth`, endpoint protection, Redis caching.
70- [Deployment & Docker Guide](./references/deployment-and-docker.md) - AWS/GCP, Docker, environment management.
71- [Testing Guide](./references/serverpod-testing.md) - Isolated database testing, endpoint simulation, auto-generated test utilities.