Skip to content

Architecture

ByteBox is a local-first Next.js application with optional Docker and Electron runtime targets.

  • Frontend and API live in one Next.js App Router project.
  • API routes are implemented under src/app/api/*.
  • Persistence uses Prisma with SQLite.
  • UI is componentized by domain (cards, layout, ui, settings).
  1. Presentation React components under src/components/* and pages under src/app/*.
  2. State and behavior Hooks and contexts under src/hooks/* and src/contexts/*.
  3. Data access DB abstraction in src/lib/db/queries.ts.
  4. Storage SQLite via better-sqlite3 and Prisma schema in prisma/schema.prisma.
  • Web development: npm run dev on http://localhost:1334.
  • Docker: containerized Next.js server with persistent volume-backed SQLite.
  • Electron: desktop shell that points to local Next dev server in dev, and in production starts a bundled Next server plus migrations.
  1. User interaction in the dashboard triggers local state updates.
  2. CRUD operations call route handlers in src/app/api.
  3. Route handlers call DB helpers in src/lib/db.
  4. Prisma persists entities in SQLite.
  5. Updated payloads hydrate UI immediately.
  • Single codebase for web + desktop keeps behavior aligned.
  • Local SQLite keeps startup and reads fast.
  • Route handlers provide a stable contract for UI and future integrations.
  • Prisma migrations keep schema evolution manageable across releases.
  • src/app/page.tsx
  • src/app/api/cards/route.ts
  • src/lib/db/queries.ts
  • prisma/schema.prisma
  • electron/main.ts
  • docker-entrypoint.sh