A clear architecture for growing TypeScript applications
Beignet brings APIs, business workflows, and production infrastructure into one consistent application model. Start with authentication and persistence, add capabilities as you need them, and use the CLI to scaffold and check your changes.
Next.js handles pages and rendering. Beignet connects your APIs, application behavior, and infrastructure. Start with Next.js or use the Web Fetch adapter.
Alpha software. APIs may change between releases.
bun beignet make resource projectsfeatures/projects/
contracts.ts HTTP API
schemas.ts Shared validation
use-cases.ts Business workflows
ports.ts Dependency interfaces
routes.ts Route bindings
tests/ Feature behaviorThe generator also adds repository adapters and registers the feature in your app. Make it yours, then check the result.
bun beignet checkAnswers for the next requirement
Keep business rules in feature workflows, describe APIs with shared contracts, and connect databases and services through typed dependency interfaces. Each new feature follows the same structure.
The full-stack Next.js starter includes sign-in, a database-backed Todos feature with ownership checks, and a UI shell. Generators add jobs, uploads, notifications, and other capabilities when you need them. Configure providers for the services and runtime you choose.
- Who can read or change this?
Identify the caller at the request boundary and enforce ownership in the business workflow. Add resource ownership with authentication and feature policies.
- How do I run work reliably after a request?
Save work alongside the database change, then deliver it through an outbox and retry failed jobs. Build a background workflow.
- How do I handle files and messages?
Use shared application ports to send email, accept private uploads, and deliver notifications through configured providers.
- How do I inspect failures and deploy changes?
Follow requests in devtools, test feature behavior, and deploy with migrations and readiness checks.
Keep the whole feature connected
A feature owns its API, business rules, and dependencies. Change the Projects name limit from 120 to 24 characters, try the form, and follow that rule through the contract, use case, client, and checks.
12345export const CreateProjectInputSchema = z.object({ name: z.string().trim().min(1).max(120), description: z.string().max(500).optional(),});
1234567export const createProject = projects .post("/api/projects") .body(CreateProjectInputSchema) .responses({ 201: ProjectSchema, });
- One contract across the stack
Define the API shape once. Request validation, typed client calls, React adapters, and OpenAPI use the same contract. Explore contracts
- Business rules you can reuse
Put application behavior in use cases. Call them from routes, jobs, or scripts, and test them with in-memory dependencies. Explore use cases
- Infrastructure with a defined place
Use typed ports for the dependencies a workflow needs. Connect databases and external services in adapters, and supply in-memory implementations in tests. Explore ports and adapters
Keep the structure as you make changes
If a use case imports a database adapter from infra/, beignet lint reports
the dependency violation. Access storage through the feature's port and wire
the adapter in infrastructure, so the business workflow can run with different
dependencies in tests.
beignet check runs architecture linting, strict wiring diagnostics, and the
app's configured lint, typecheck, and test scripts. These checks catch specific
boundary and setup mistakes; your tests verify the feature's behavior.
A shared way to understand and change the app
Predictable file locations and dependency rules give an agent a structure to follow. The CLI can map the app, explain a feature, scaffold its next piece, and return check failures to work through.
Versioned package guidance, generated app instructions, and MCP tools support the same workflow. Review the behavior and checks together.
From an API to a feature you can use
Build a Projects feature with persistent data, account ownership, and a React UI. Learn where each responsibility belongs through three chapters, with a working result and checks at every stage.
Build the API
Generate the resource, add a field, and follow it into the database.
Add ownership
Enforce who can read and change each project, then test those rules.
Connect the UI
Create, list, edit, and delete projects through a typed client.
Built for early explorers
Beignet is alpha software. Evaluate it for TypeScript products with a REST
API, persistent data, authorization, and workflows beyond a request.
APIs can change between 0.0.x releases.