Build Enterprise-Grade
Backends that Scale.
The hexagonal architecture framework for TypeScript.
Type-safe, framework-agnostic, and designed for long-term maintainability.
Works with your favorite frameworks
Why Onion Lasagna?
Stop debating folder structure. Start shipping features with a proven architectural pattern.
Onion Architecture Standard
Strict separation of concerns. Your business logic (Domain) sits at the center, completely isolated from frameworks, databases, and external APIs. Dependencies flow inward, making your core logic easy to test and maintain.
Framework Agnostic
Switch from Express to Fastify or Hono without rewriting a single line of business logic.
Type-Safe Core
End-to-end type safety with generics. Catch errors at compile time, not runtime.
Zero-Dependency Core
The core package has zero runtime dependencies. You only install what you need (validators, framework adapters) as peer dependencies. Keeps your bundle size small and your supply chain secure.
The Flow of Control
See how data flows through the layers. Clean, predictable, and unidirectional.
Developer Experience First
Write code that reads like english. Clear contracts, explicit dependencies.
import { BaseInboundAdapter } from '@cosmneo/onion-lasagna'
export class CreateUserUseCase extends BaseInboundAdapter<
CreateUserInput,
CreateUserOutput
> {
constructor(
private readonly userRepo: UserRepository,
private readonly emailService: EmailService
) {
super()
}
async handle(input: CreateUserInput): Promise<CreateUserOutput> {
// 1. Domain logic stays pure
const user = User.create(input.email, input.name)
// 2. Infrastructure through ports
await this.userRepo.save(user)
await this.emailService.sendWelcome(user.email)
return { id: user.id.value }
}
}Ready to standardise your backend?
Join the developers building scalable, maintainable systems with Onion Lasagna. Production-ready architecture, straight out of the box.