Clean Architecture template for high-performance web applications
Built with Bun, TypeScript, Elysia & Clean Architecture
Ready-to-use template by Gesttione Solutions ⚡️
| Componente | Propósito | Status |
|---|---|---|
| Domain Layer | Business logic, entities, value objects | ✅ Implementado |
| Application Layer | Use cases, DTOs, orchestration | ✅ Implementado |
| Infrastructure Layer | Repositories, external services | ✅ Implementado |
| Presentation Layer | HTTP routes, controllers, middleware | ✅ Implementado |
| Testing Suite | Unit, integration, e2e tests | ✅ Implementado |
# 1. Clonar e instalar
git clone <repo-url> && cd template-elysia && bun install
# 2. Executar aplicação
bun run dev
# 3. Verificar quality gates
bun run genex && bun run lint && bun run type-check && bun run testVerificar:
- Aplicação: Rodando sem erros
- Testes: 25+ tests passing
- Quality Gates: ✅ All passed
Este projeto possui comandos personalizados para Claude Code que otimizam o workflow de desenvolvimento:
/dev # TaskMaster-driven development
/qa # Quality gates validation
/commit-flow # Organized commit process
/pr-create # Automated PR creation with push/new-feature # Manual feature development guide
/refactor # Safe refactoring process
/test-focus # Targeted testing strategies
/arch-check # Architecture compliance analysis
/debug-help # Troubleshooting assistantSetup inicial:
# Os comandos estão em .claude/commands/
# Use diretamente no Claude Code: /dev, /qa, etc.graph LR
A[Domain] --> B[Application]
B --> C[Infrastructure]
C --> D[Presentation]
D --> E[Quality Gates]
# 1. Desenvolvimento com TaskMaster
/dev # Escolher task e implementar
# 2. Validação contínua
/qa # Quality gates completos
# 3. Commit organizado
/commit-flow # Estruturar e commitar
# 4. Pull Request
/pr-create # Push e criar PR automaticamente# Sequência completa (uso do comando /qa)
bun run genex && bun run lint && bun run type-check && bun run test
# Comandos individuais
bun run genex # Generate/update index files
bun run lint # Biome linting and formatting
bun run type-check # TypeScript validation
bun run test # Vitest test suite (25+ tests)| Camada | Responsabilidade | Tecnologias |
|---|---|---|
| Domain | Business logic, entities, value objects | TypeScript puro |
| Application | Use cases, DTOs, orchestration | TypeScript |
| Infrastructure | Repositories, external services | Bun, implementações |
| Presentation | HTTP routes, controllers | Elysia framework |
| Categoria | Tecnologias |
|---|---|
| Runtime | Bun (fast JavaScript runtime) |
| Language | TypeScript (strict mode) |
| Framework | Elysia (fast & type-safe web framework) |
| Testing | Vitest (NOT Bun's test runner) |
| Code Quality | Biome (linting + formatting) |
| Git Hooks | Husky + lint-staged |
| Architecture | Clean Architecture + SOLID principles |
src/
├── domain/
│ ├── entities/ # Business objects (User)
│ ├── value-objects/ # Immutable primitives (Email, UserId)
│ ├── ports/ # Interfaces (UserRepository)
│ └── services/ # Domain business logic
├── application/
│ ├── use-cases/ # Application business rules
│ ├── dtos/ # Data transfer objects
│ ├── ports/ # Application interfaces
│ └── services/ # Application orchestration
├── infrastructure/
│ ├── controllers/ # HTTP request handlers
│ ├── persistence/ # Data access implementations
│ └── http/ # HTTP configurations
└── presentation/
├── routes/ # HTTP route definitions
├── middleware/ # Request/response middleware
└── controllers/ # Presentation controllers
tests/
└── unit/
├── domain/ # Domain layer tests
├── application/ # Application layer tests
└── infrastructure/ # Infrastructure tests
utils/
└── genex/ # Index file generator
├── processors/ # Generation strategies
├── types.ts # Type definitions
└── utils.ts # Utility functions
.claude/
└── commands/ # Claude Code custom commands
├── dev.md # TaskMaster development
├── qa.md # Quality gates
├── commit-flow.md # Commit organization
└── pr-create.md # PR automation- Unit Tests: Domain and Application logic (25+ tests implemented)
- Test Structure: Mirrors
src/directory structure - Coverage: Comprehensive coverage for business logic
- Framework: Vitest with strict TypeScript
# Complete quality check
/qa # Use Claude Code command
# Individual validations
bun run genex # ✅ Index files updated
bun run lint # ✅ Biome formatting applied
bun run type-check # ✅ TypeScript strict compliance
bun run test # ✅ All tests passing (25+)Automated quality gates via Husky:
- Branch protection - Prevents commits to protected branches
- Lint-staged - Auto-formatting with Biome
- Type checking - TypeScript validation
- Unit tests - Complete test suite execution
- Architecture analysis - Clean Architecture compliance
- Index generation - Auto-update exports
"Functionality first, perfect architecture second. Apply Clean Architecture and DDD patterns where they add clear value, not everywhere."
- Small commits with comprehensive quality gates
- Delete unused variables instead of using
_prefix - Functionality over perfect architecture
- Clean separation of concerns where it adds value
- Quality gates as foundation of development workflow
# 🚨 RULE: Never work on protected branches
git checkout -b feat/feature-description
# Development cycle
/dev # Implement with TaskMaster guidance
/qa # Validate quality gates
/commit-flow # Organize and commit
/pr-create # Push and create PR
# Protected branches: main, master, develop, staging, production# Desenvolvimento
bun run dev # Start development server with watch
bun run build # Build for production
bun run start # Run built application
# Quality & Testing (Use Vitest, NOT Bun's test runner)
bun run test # Run all tests (uses Vitest)
bun run test:watch # Tests in watch mode
bun run test:coverage # Tests with coverage report
bun run test:ui # Vitest UI for interactive testing
# Code Quality
bun run genex # Generate index.ts files automatically
bun run lint # Biome linter and formatter (auto-fixes)
bun run type-check # TypeScript type checking
# Quality Gates Sequence
bun run genex && bun run lint && bun run type-check && bun run test
# Utilities
bun run clean # Clean build artifacts
bun install # Install dependencies| Problema | Solução |
|---|---|
| Tests not exiting | Use bun run test (not bun test) |
| TypeScript errors | Run bun run genex to update index files |
| Linting issues | Run bun run lint for auto-fix |
| Import/export errors | Check if files follow naming conventions |
| Architecture violations | Use /arch-check command for analysis |
| Pre-commit hook fails | Run /qa to identify and fix issues |
| Protected branch error | Create feature branch: git checkout -b |
| Build failures | Run bun install && bun run type-check |
Para debugging detalhado: Use o comando /debug-help no Claude Code
# Files: kebab-case.type.extension
user.entity.ts
email.vo.ts
create-user.use-case.ts
user.controller.ts
# Classes: PascalCase
export class User {}
export class Email {}
export class CreateUserUseCase {}// Path aliases configured
import { User } from '@/domain/entities'
import { CreateUserUseCase } from '@/application/use-cases'
// Auto-generated exports via genex
export * from './entities'
export * from './value-objects'
export * from './ports'# Conventional commits
feat(domain): add User entity with email validation
fix(tests): resolve async test timing issues
refactor(infrastructure): extract common repository patterns
docs: update development workflow documentationexport class Email {
private constructor(private readonly value: string) {}
static create(value: string): Email {
// Validation logic
return new Email(value);
}
equals(other: Email): boolean {
return this.value === other.value;
}
}export class CreateUserUseCase {
constructor(private userRepository: UserRepository) {}
async execute(input: CreateUserInput): Promise<CreateUserOutput> {
// Application logic
}
}export class InMemoryUserRepository implements UserRepository {
async save(user: User): Promise<void> {
// Implementation
}
}- Domain Layer: ✅ Complete (User entity, Email/UserId VOs)
- Application Layer: ✅ Complete (CreateUser/GetUser use cases)
- Infrastructure Layer: ✅ Basic implementation (InMemory repository)
- Testing: ✅ 25+ tests passing (100% domain coverage)
- Quality Gates: ✅ All automated and passing
- ✅ Clean Architecture layers respected
- ✅ Domain layer has zero external dependencies
- ✅ Dependency inversion properly implemented
- ✅ Repository pattern for data access
- ✅ Value objects for domain primitives
- Automatic
index.tsfile generation - Configurable via
genex.json - Modular processor architecture
- Clean exports for each layer
- Pre-commit hooks with comprehensive checks
- Real-time quality validation
- Architecture compliance analysis
- Automated code formatting
- Custom development commands
- TaskMaster AI integration
- Workflow automation
- Context-aware assistance
Projeto desenvolvido seguindo Clean Architecture e SOLID principles.
Bun + TypeScript + Elysia Template – High-performance web applications with Clean Architecture Built by Gesttione Solutions with modern development practices 🚀