Skip to content

RealWorld backend implementation built with ElysiaJS and Drizzle ORM

License

Notifications You must be signed in to change notification settings

bedstack/elysia-drizzle-realworld-example

RealWorld Example App

ElysiaJS + Drizzle ORM codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

Tests Status License ElysiaJS Drizzle ArkType Scalar Bun Biome Star

This codebase was created to demonstrate a fully fledged backend application built with ElysiaJS and Drizzle ORM including CRUD operations, authentication, routing, pagination, and more.

We've gone to great lengths to adhere to the ElysiaJS and Drizzle ORM community styleguides & best practices.

For more information on how this works with other frontends/backends, head over to the RealWorld repo.

How it works

Architecture

This project follows the Bedstack architecture - a modular, layered approach to building TypeScript backends:

  • Modular structure - Each domain (users, articles, comments, etc.) is a self-contained module with its own controller, service, repository, and DTOs
  • Layered design - Clear separation between Controller (HTTP handling) → Service (business logic) → Repository (data access)
  • Type-safe data flow - DTOs define request/response shapes, mappers transform between layers, schemas define database tables
src/
├── users/          # User module
│   ├── users.controller.ts
│   ├── users.service.ts
│   ├── users.repository.ts
│   ├── users.schema.ts
│   ├── dto/
│   └── mappers/
├── articles/       # Article module (same structure)
├── shared/         # Shared utilities and error handling
└── app.module.ts   # Root module composing all features

Read more about the Bedstack architecture →

Technologies

  • ElysiaJS - Web framework for HTTP
  • Drizzle ORM - TypeScript ORM for PostgreSQL
  • ArkType - Runtime validation
  • Scalar - API documentation
  • Bun - JavaScript runtime and package manager
  • Biome - Linting and formatting

Getting started

  1. Install dependencies

    bun i
  2. Create a .env file

    cp .env.example .env

    Use the provided example values or replace them with your own.

  3. Ensure Docker daemon is running and start the database service

    bun db:start
  4. Migrate the schema to the database

    bun db:migrate
  5. Run the development server

    bun dev
  6. Run the API tests

    bun run test # not `bun test`!
  7. (Optional) Start the database studio

    bun db:studio

Deploy to production

Tip

See more info in ElysiaJS's Deploy to production pattern.

  1. Build the app

    bun run build # not `bun build`!
  2. Run the server

    bun preview

Need help?

If you have questions or ideas:

Contributors

You are welcome to contribute to the project!

Yam C Borodetsky
Yam C Borodetsky

💬 🤔 📖 🐛 💡 🚇 ⚠️
Hajbo
Hajbo

🚇 💻 🎨 🤔 ⚠️ 💬
Aruay Berdikulova
Aruay Berdikulova

💻 🤔

About

RealWorld backend implementation built with ElysiaJS and Drizzle ORM

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Contributors 10