Skip to content

Conversation

@cpfiffer
Copy link

New skill for building production-ready serverless REST APIs on Modal with FastAPI.

Overview

This skill teaches developers how to build serverless REST APIs using Modal and FastAPI, covering the complete stack from API design to deployment.

What's Included

SKILL.md

  • Overview of Modal serverless platform
  • Quick start patterns
  • Common workflows
  • Best practices

References (70KB total)

  • fastapi_patterns.md - CRUD operations, authentication, validation, error handling
  • modal_volumes.md - Persistent storage patterns, directory organization, performance optimization
  • polling_scheduler.md - Cron-based task scheduling, time-bucketed storage, race condition handling
  • multi_tenant_storage.md - User isolation with hash-based directories, row-level security
  • security_patterns.md - Encryption at rest, secrets management, input validation

Examples (14KB total)

  • basic_rest_api.py - Complete todo list API with authentication
  • scheduled_tasks.py - Polling scheduler with time-bucketed storage

Why This Skill?

Fills a gap: No existing skill covers serverless deployment or infrastructure patterns

Real production patterns: Based on actual working code from a production service (Letta Switchboard)

Broadly applicable: Not company-specific - useful for anyone building on Modal

Comprehensive: Covers API design, storage, scheduling, multi-tenancy, and security

Key Patterns

  1. Modal + FastAPI integration for serverless REST APIs
  2. Polling-based schedulers using cron (simpler than APScheduler/Celery)
  3. Time-bucketed storage for O(current hour) performance
  4. Multi-tenant isolation with hash-based directories
  5. Delete-before-execute pattern for race condition prevention
  6. Encryption at rest and secrets management

Testing

All examples are deployable with:

modal deploy basic_rest_api.py
modal serve scheduled_tasks.py  # Local testing

License

Apache 2.0 (matching other example skills)

New skill for building production-ready serverless REST APIs on Modal with FastAPI.

Covers:
- REST API design patterns with FastAPI
- Persistent storage with Modal volumes
- Polling-based schedulers using cron
- Multi-tenant data isolation with hash-based directories
- Security patterns (encryption, auth, rate limiting)
- Time-bucketed storage for performance
- Race condition handling for scheduled tasks

Includes:
- SKILL.md - Overview and quick start patterns
- references/ - Detailed guides on:
  - FastAPI patterns (CRUD, auth, validation, errors)
  - Modal volumes (storage, organization, performance)
  - Polling scheduler (cron jobs, time buckets, race conditions)
  - Multi-tenant storage (isolation, ownership, security)
  - Security patterns (encryption, secrets, validation)
- examples/ - Working implementations:
  - basic_rest_api.py - Todo list API with auth
  - scheduled_tasks.py - Polling scheduler with time buckets

This skill fills a gap in deployment/infrastructure patterns and demonstrates
real-world serverless architecture suitable for production use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant