moai-domain-backend

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

2|Updated May 27, 2026
One-click install
npx skills add https://github.com/yekinya/moai-novel --skill moai-domain-backend-yekinya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moai-domain-backend
Source: https://github.com/yekinya/moai-novel/tree/main/moai-novel/.claude/skills/moai-domain-backend
Command: npx skills add https://github.com/yekinya/moai-novel --skill moai-domain-backend-yekinya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Designing secure, scalable backend systems requires coordinating API design, database integration, authentication, caching, and event-driven messaging, which is error-prone when done ad hoc. This Skill provides proven patterns and working code for building production backend services. ## Core Features & Use Cases - API Design: Build REST, GraphQL, and gRPC services with FastAPI, OpenAPI 3.1, JWT authentication, and request validation middleware. - Database Integration: Configure PostgreSQL with SQLAlchemy connection pooling, MongoDB with Motor, and Redis caching with automatic invalidation. - Microservices & Resilience: Implement event-driven architecture with RabbitMQ, service discovery with Consul, and circuit breakers for external calls. - Use Case: When building a user management service, use this Skill to scaffold JWT-authenticated endpoints, a cached repository layer, and order events published to a message broker. ## Quick Start Ask the agent to design a FastAPI user service with JWT authentication, PostgreSQL persistence, and Redis caching using the backend development skill.

Frequently Asked Questions about moai-domain-backend

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

FAQPage Schema
How do I add JWT authentication to a FastAPI application?

Create a SecurityManager with passlib CryptContext for bcrypt hashing, then encode tokens with HS256 and an expiration claim. Protect routes by injecting an HTTPBearer dependency that decodes the token and raises 401 on expired or invalid credentials.

How to implement Redis caching with a database repository pattern?

Check Redis for a cached key before querying the database, then store results with a TTL using setex. On create, update, or delete operations, invalidate the corresponding cache keys so reads never return stale data.

What is the difference between SQLAlchemy pooling and Motor for MongoDB?

SQLAlchemy uses QueuePool with pool_size, max_overflow, and pool_pre_ping for relational databases like PostgreSQL. Motor provides an async client for MongoDB with maxPoolSize and minPoolSize settings, suited for document storage rather than relational queries.

Does this approach support event-driven microservices with RabbitMQ?

Yes, it uses aio-pika to declare a topic exchange, publish JSON events with routing keys, and subscribe queues with durable bindings. Services like order processing and notifications communicate through events without direct coupling.

Why do database connections get exhausted under load?

Connection pools exhaust when sessions are not closed or pool sizes are too small for concurrency. Increase pool_size and max_overflow, enable pool_pre_ping for health checks, and always use async context managers to return connections.

When should I avoid adding another endpoint to an existing service?

Unbounded endpoint growth creates a monolith-in-disguise with tangled responsibilities. Evaluate service boundaries first, and consider extracting a separate microservice with its own data store when the domain logic diverges.