Build
SCALABLE
Apps
Next.js monorepo following Clean Architecture and Domain-Driven Design. Production-ready, type-safe, and built for scale.
Built for Claude Code, Cursor & AI assistants
Built for AI Assistants
CleanStack is the first starter kit designed specifically for AI-assisted development. Every architectural decision is documented and optimized for AI comprehension.
Claude Code Ready
Complete CLAUDE.md with full architecture context. AI understands your codebase instantly.
Explicit Patterns
Result<T>, Option<T>, and DDD patterns documented for AI comprehension. No guessing.
.cursorrules Included
Architectural rules and anti-patterns defined. AI follows Clean Architecture automatically.
AI-Optimized DX
Rich documentation, type-safe patterns, and helper scripts. Build faster with AI assistance.
# AI Development Guidelines
## Mandatory Architectural Rules
### 1. Respect the Dependency Rule (CRITICAL)
**NEVER violate the dependency direction:**
- Domain MUST NOT import from Application
- Application MUST NOT import from Infrastructure
- All dependencies point INWARD
### 2. Error Handling Pattern (MANDATORY)
**NEVER throw exceptions** in Domain/Application.
Use Result<T> pattern for explicit error handling.
✅ CORRECT:
const result = Email.create(input.email)
if (result.isFailure) {
return Result.fail(result.error)
}
❌ WRONG:
if (!input.email) {
throw new Error('Email required') // NEVER
}Features
Clean Architecture
Separation of concerns with clear boundaries. Testable, maintainable, and independent of frameworks.
Domain-Driven Design
Rich domain models with Entities, Value Objects, and Aggregates. Business logic where it belongs.
Type Safety
End-to-end TypeScript with Zod validation. Catch errors at compile time, not runtime.
Monorepo Ready
Turborepo + PNPM workspaces. Shared packages, optimized builds, and seamless development.
How It Works
┌─ CLEANSTACK ARCHITECTURE ────────────────────┐ │ │ │ HTTP Request │ │ ↓ │ │ ┌──────────────────────────────────────┐ │ │ │ [Adapters] │ │ │ │ Controllers & Presenters │ │ │ └──────────────────────────────────────┘ │ │ ↓ │ │ ┌──────────────────────────────────────┐ │ │ │ [Application] │ │ │ │ Use Cases & Business Logic │ │ │ └──────────────────────────────────────┘ │ │ ↓ │ │ ┌──────────────────────────────────────┐ │ │ │ [Domain] │ │ │ │ Entities & Value Objects │ │ │ │ Aggregates & Domain Events │ │ │ └──────────────────────────────────────┘ │ │ ↓ │ │ ┌──────────────────────────────────────┐ │ │ │ [Infrastructure] │ │ │ │ Database & External APIs │ │ │ └──────────────────────────────────────┘ │ │ │ └───────────────────────────────────────────────┘
CleanStack follows Clean Architecture principles with clear layer separation:
- →Adapters handle HTTP requests and present responses
- →Application layer contains use cases and orchestrates business logic
- →Domain layer holds pure business rules and entities
- →Infrastructure layer manages external dependencies
Code Examples
export class Email extends ValueObject<EmailProps> {
protected validate(props: EmailProps): Result<EmailProps> {
if (!emailRegex.test(props.value)) {
return Result.fail("Invalid email");
}
return Result.ok(props);
}
get value(): string {
return this.props.value;
}
}Ready to build better apps?
Get started in less than 5 minutes