Skip to content

Latest commit

 

History

History
115 lines (73 loc) · 3.73 KB

File metadata and controls

115 lines (73 loc) · 3.73 KB

Bedstack Lite Architecture

Overview

Bedstack Lite is a distilled version of the full Bedstack architecture. It keeps the feature-sliced, modular structure but simplifies the layering for rapid prototyping.

Each feature is self-contained and designed for clarity, fast development, and maintainability - without the overhead of full enterprise layering.

Design Philosophy

  • Keep the structure familiar by following the same horizontal layout as Bedstack (one folder per domain feature).

  • Collapse vertical layers by combining controller, service, and repository logic in a single plugin file.

  • Prioritize speed-to-code by minimizing boilerplate and maximizing clarity.

  • Maintain modularity by keeping each domain isolated and portable.

Layer Breakdown (Per Feature)

Each domain entity (e.g. articles/, comments/, users/) looks like this:

entities/
├── plugin.ts               # Unified entry point (controller + service + repo)
├── schema.ts               # Drizzle ORM schema
├── model.ts                # TypeBox DTOs (request/response shapes)
├── interfaces/             # TypeScript types and interfaces
│   └── article.interface.ts
├── mappers/                # Small helper mappers (if needed)
│   └── to-article.dto.ts

Note

Notice the usage of entities instead of entity - this is on purpose. We follow the NestJS convention of pluralizing the entity in the folder and filenames.

🧩 entities.plugin.ts

Controller, service, and repository - all in one file.

Defines routes, handles logic, and interacts with the database, powered by ElysiaJS.

🧬 entities.schema.ts

Database tables and relations using Drizzle ORM.

🧾 entities.model.ts

DTOs defined with Elysia.t (a thin wrapper around TypeBox), with types inferred automatically.

Example:

export const CreateArticle = t.Object({
  title: t.String(),
  body: t.String(),
});

export type CreateArticle = typeof CreateArticle.static;

🧠 interfaces/

Domain models and type definitions.

Example: Article, ArticleRow, etc.

🔁 mappers/

Map between DB rows and DTOs (e.g. camelCase conversion, date formatting).

Note

Bedstack Lite has much fewer mappers than the full Bedstack - since there are fewer layers.

Project-Level Structure

src/
├── articles/              # Domain entity
├── comments/              # Domain entity
├── users/                 # Domain entity
├── profiles/              # Domain entity
├── tags/                  # Domain entity
├── core/                  # Core (app, db, env, core plugins)
├── shared/                # Shared constants, utils, types, plugins, etc.
├── index.ts               # Main entry point, mounts plugins
drizzle/                   # Migrations, reset, seed

When to Use Bedstack Lite

✅ Ideal for:

  • Internal tools

  • MVPs and prototypes

  • Hackathons or proof-of-concept apps

  • Fast experimentation with full-stack logic

❌ Not ideal for:

  • Large-scale systems with deep domain logic

  • Complex business rules requiring separation of concerns

  • Teams that need fine-grained testing or enterprise observability

See Also