server-domain-architecture

Organizes Express server code into domain routers, repositories, and a composition root.

Updated Dec 24, 2025
One-click install
npx skills add https://github.com/JoyJoin-Tech-Limited/JoyJoin_app_v0.1 --skill server-domain-architecture-joyjoin-tech-limited
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: server-domain-architecture
Source: https://github.com/JoyJoin-Tech-Limited/JoyJoin_app_v0.1/tree/main/.github/skills/server-domain-architecture
Command: npx skills add https://github.com/JoyJoin-Tech-Limited/JoyJoin_app_v0.1 --skill server-domain-architecture-joyjoin-tech-limited

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Server codebases tend to accumulate business logic in monolithic route files and legacy storage modules, making changes risky and reviews slow. This Skill enforces a clear layered structure so every new route, service, or query has an obvious home. ## Core Features & Use Cases - Layered ownership rules: routes.ts acts as the composition root, routes/domains/* owns domain handlers, repositories/* holds new persistence logic, and storage.ts remains a frozen compatibility facade. - Domain ownership table: A reference guide maps each domain (auth, payments, event pools, admin, and more) to its router and repository files. - Migration guidance: Step-by-step patterns for moving logic out of storage.ts into repositories without breaking existing callsites. - Use Case: When asked to add a POST /api/payments/create endpoint, the Skill directs you to extend routes/domains/payments.ts, add the query to repositories/paymentsRepo.ts, mount the router in routes.ts, and leave storage.ts untouched. ## Quick Start Ask the AI to add a new API endpoint to the Express server and follow the domain architecture rules for where the handler and query code should live.

Frequently Asked Questions about server-domain-architecture

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

FAQPage Schema
How do I add a new API route to an Express server without bloating routes.ts?▼

Create or extend a domain router in routes/domains/<domain>.ts with the handler and validation, then mount that router in routes.ts. Keep persistence logic in a matching repositories/ file rather than inline in the route.

Where should new database query code live in a layered Node.js backend?▼

New persistence logic belongs in repositories/ as plain TypeScript functions using db or tx handles. Do not add new methods to the legacy storage.ts facade; it should only delegate to repositories.

How do I migrate logic out of a legacy storage.ts facade?▼

Extract the logic into the appropriate repositories/ file, then update storage.ts to delegate to the repository so existing callsites keep working. The goal is to shrink the storage.ts surface over time until it can be removed.

When should Express middleware not be placed inside route files?▼

Express middleware such as request ID correlation or metrics collection belongs in a dedicated middleware/ directory, not inside routes.ts or domain router files. Domain files should contain only handlers, validation, and service calls.

What are the limitations of a composition root pattern for large Express apps?▼

The composition root centralizes router mounting, so it grows as domains are added and requires discipline to keep free of inline handlers. Teams must enforce the boundary with review checklists and structural tests to prevent logic from drifting back in.