Switchain Services — Conventions & Architecture
Switchain Services is a TypeScript monorepo built with Domain-Driven Design and ports & adapters architecture.
Stack
- Runtime: Bun
- Language: TypeScript
- HTTP: Elysia
- Frontend: Next.js 16
- Data layer: Prisma and package-owned repositories
Project Structure
text
switchain-services/
├── apps/ # Deployable applications and workers
├── packages/ # Bounded contexts and shared packages
├── docs/ # Conventions, commands, security, decisions, development docs
├── .agents/ # Canonical shared agents, commands, and skills
├── .claude/ # Claude-native projection
└── .github/ # Copilot-native instructions, prompts, agents, and skillsBounded Context Structure
Each bounded context follows the same dependency direction:
text
Domain <- Application <- InfrastructureTypical package structure:
text
packages/<context>/
├── domain/
│ ├── entities/
│ ├── valueObjects/
│ ├── repositories/
│ ├── services/
│ ├── events/
│ └── ports/
├── application/
│ ├── services/
│ └── eventSubscribers/
├── infrastructure/
│ ├── repositories/
│ ├── adapters/
│ ├── controllers/
│ └── factories/
└── test/Current Defaults
- Files use
PascalCase.ts. - Services expose a public
run()method. - Constructor injection is the default dependency pattern.
- Repository interfaces live in domain and implementations live in infrastructure.
- Entity persistence boundaries use
static fromDto()andtoDto(). - Tests use Bun and Object Mothers where the codebase already follows that pattern.
Convention Files
- Naming Conventions
- File Organization
- Pre-Commit Workflow
- DDD Principles
- Service Patterns
- Repository Patterns
- Testing with Bun
- Error Handling
- Event Patterns
