moai-domain-backend

Implements backend APIs, database integration, and microservices patterns with FastAPI and SQLAlchemy.

Updated Jun 18, 2026
One-click install
npx skills add https://github.com/h102-log/pdfrag --skill moai-domain-backend-h102-log
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: moai-domain-backend
Source: https://github.com/h102-log/pdfrag/tree/main/.claude/skills/moai-domain-backend
Command: npx skills add https://github.com/h102-log/pdfrag --skill moai-domain-backend-h102-log

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building production backend services requires coordinating API design, database connections, authentication, caching, and event-driven messaging, and this Skill provides proven implementation patterns for each of these concerns. ## Core Features & Use Cases - API Design: REST endpoints with FastAPI, GraphQL with Strawberry, and OpenAPI 3.1 specifications with JWT authentication. - Database Integration: PostgreSQL via SQLAlchemy with connection pooling, MongoDB via Motor, and Redis caching with automatic invalidation. - Microservices Patterns: Event-driven architecture with RabbitMQ/aio-pika, service discovery with Consul, and circuit breakers for external calls. - Use Case: When building a user management service, apply the repository pattern with Redis caching, JWT authentication middleware, and health check endpoints to get a working async FastAPI service. ## Quick Start Ask the assistant to create a FastAPI endpoint with JWT authentication and PostgreSQL connection pooling for a user management service.

Frequently Asked Questions about moai-domain-backend

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement JWT authentication in FastAPI?▼

JWT authentication in FastAPI uses HTTPBearer or OAuth2PasswordBearer security dependencies with python-jose for token encoding. Create tokens with HS256 algorithm and expiration claims, then validate them in a dependency that raises 401 errors on expired or invalid tokens.

How to set up SQLAlchemy connection pooling for async APIs?▼

Configure create_async_engine with QueuePool, pool_size of 20, max_overflow of 30, pool_pre_ping enabled, and pool_recycle of 3600 seconds. Pair it with an async sessionmaker and a context manager that commits on success and rolls back on exceptions.

What is the repository pattern with Redis caching?▼

The repository pattern encapsulates data access in a class that checks Redis before querying the database and caches results with a TTL. Write operations invalidate the corresponding cache keys to keep data consistent.

Does FastAPI support event-driven microservices with RabbitMQ?▼

Yes, aio-pika provides async RabbitMQ integration for FastAPI services. Declare a topic exchange, publish JSON messages with routing keys, and subscribe with durable queues so services like notifications react to events such as order.created.

Why do async APIs block when calling external services?▼

Blocking occurs when synchronous libraries like requests run inside async endpoints, freezing the event loop. Use httpx.AsyncClient or run blocking calls in a thread pool, and add circuit breakers with tenacity retries for resilience.

When should I avoid the circuit breaker pattern?▼

Circuit breakers add unnecessary complexity for internal calls on reliable networks or low-traffic prototypes. They are most valuable for external payment or third-party APIs where cascading failures and timeouts must be contained.