Skip to content

Architecture

Overview

Bantr is a monorepo built with Turborepo, consisting of multiple packages and applications:

bantr-stack/
├── bantr/
│   ├── apps/
│   │   ├── bantr-web          # Frontend — Vike + React 19 + Ant Design 6
│   │   ├── bantr-api          # Backend — Express + WebSocket + Prisma
│   │   └── bantr-docs         # Documentation — VitePress
│   ├── packages/
│   │   ├── bantr-ui           # Shared UI components
│   │   ├── bantr-prisma       # Database schema + Prisma client
│   │   └── bantr-types        # Shared Zod schemas + TypeScript types
│   └── modules/
│       └── bantr-analytics    # Pluggable analytics (GA4)

Frontend (bantr-web)

  • Framework: Vike (SSR + client-side routing)
  • UI: React 19 + Ant Design 6 (dark theme)
  • Styling: Inline styles + Ant Design tokens
  • State: React Context (UserContext, WebSocketContext)
  • Build: Vite 7

Pages

RoutePurpose
/Main chat (welcome room)
/r/:roomRoom-specific chat
/loginSign in form
/registerAccount creation
/u/:userUser profile

Backend (bantr-api)

  • Server: Express 4 + native HTTP
  • WebSocket: ws library on same server
  • Database: PostgreSQL via Prisma (with in-memory fallback)
  • Auth: bcrypt (12 rounds) + httpOnly session cookies
  • Runtime: tsx (TypeScript directly, no build step)

Data Flow

mermaid
graph LR
    A[Browser] -->|REST| B[Express API]
    A -->|WebSocket| C[WS Server]
    B -->|Prisma| D[(PostgreSQL)]
    C -->|Broadcast| A
    B -->|Cookie| A

Rate Limits

ScopeLimit
General API60 req/min per IP
Auth endpoints10 req/min per IP
Message posting20 req/min per IP
Free posts5/day per user

Shared Packages

@bantr/bantr-ui

Reusable React components: MessageRow, RoomItem, StatusBadge, BantrLogo, UserIdBadge, SectionLabel. Source-only (no build step — Vite resolves TS directly).

@bantr/bantr-prisma

Prisma schema + singleton client. Models: User, Session, Room, Message, RoomMembership.

@bantr/bantr-types

Zod schemas for messages, users, rooms, and WebSocket protocol messages.

Deployment

Deployed on Railway with automatic GitHub push-to-deploy:

Bantr — Say anything.