Skip to content

StephanOrgiazzi/Bun-as-everything

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bun-as-everything

Bun Runtime Bun Packages Bun Server Bun Bundler Bun SQLite Bun WebSockets Bun Tests React 19 SQLite

License: MIT Open Source

A fun little demo where Bun does almost everything.

This project exists for one reason: I wanted to play with Bun's built-in features and see what it feels like to let Bun handle almost everything in a small app.

Bun runs the server, handles WebSocket upgrades, bundles the frontend, manages packages, runs the tests, and talks to SQLite directly. The dependency list stays intentionally small so the project highlights Bun itself rather than a stack of abstractions.

The app itself is a small live polling room. Hosts can create rooms, queue draft polls, open a poll, and watch results update in real time while participants vote. It's simple on purpose. That simplicity makes it easier to explore Bun's capabilities.

App screenshot

What this demo is testing

  • Bun as the package manager instead of npm, pnpm, or yarn
  • Bun as the runtime instead of node
  • Bun as the HTTP server via Bun.serve instead of adding Express or Hono
  • Bun as the bundler for the browser app instead of vite
  • Bun as SQLite support via bun:sqlite
  • Bun as WebSocket support for room-level realtime updates
  • Bun as the test runner via bun test instead of vitest or jest

What's in the stack

  • React 19
  • Tailwind CSS v4
  • SQLite

That's basically it. Bun handles everything else.

Why the dependency list is so small

If I add an ORM, a WebSocket abstraction, a router framework, a schema layer, a migration tool, a state library, and three utility packages, then I learn less about Bun and more about the packages I chose. Those tools can be great. They just aren't the point here.

Keeping the dependency list lean means:

  • the code is small enough to read in one sitting
  • the platform capabilities are doing real work
  • the overall system is easier to understand end to end

Not a Production blueprint or a full Bun tour

I would not treat this repo as a blueprint for every real production app. It's a fun demo and a learning project, not a serious argument that every app should skip the usual layers. For instance, in real life, I'd strongly consider an ORM like Prisma or Drizzle, schema validation with zod, or at least a more deliberate data access layer once the schema starts growing and the queries become more complex.

And yes, Bun has more built-ins we could have explored here too. For example, we could have pushed the demo further with Bun's Redis integration and used it to experiment with caching.

The takeaway

This repo shows that Bun can carry a surprising amount of a small app while keeping the setup lightweight. Not sure if everything is production-ready, but pretty cool anyway!

Features

  • Create rooms with short codes
  • Store host access with a generated host token
  • Compose draft polls before opening them
  • Allow only one open poll per room
  • Persist rooms, polls, options, and votes in SQLite
  • Broadcast live room state over WebSockets
  • Track presence from active socket connections
  • Keep closed polls in room history

Quick start

bun install
bun run dev

Open http://localhost:3000.

Scripts

  • bun run dev starts the app with hot reload
  • bun run start starts the app without hot reload
  • bun run test runs the test suite
  • bun run test:coverage runs tests with coverage
  • bun run seed seeds the database
  • bun run db:reset removes the SQLite database files

By default the SQLite database lives at data/bun-as-everything.sqlite.

License

This project is open source and available under the MIT License.

See LICENSE for the full text.

About

A fun little demo where Bun does almost everything.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors