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
| Route | Purpose |
|---|---|
/ | Main chat (welcome room) |
/r/:room | Room-specific chat |
/login | Sign in form |
/register | Account creation |
/u/:user | User profile |
Backend (bantr-api)
- Server: Express 4 + native HTTP
- WebSocket:
wslibrary 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| ARate Limits
| Scope | Limit |
|---|---|
| General API | 60 req/min per IP |
| Auth endpoints | 10 req/min per IP |
| Message posting | 20 req/min per IP |
| Free posts | 5/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-web→ bantr.ingbantr-api→ api.bantr.ingbantr-docs→ docs.bantr.dev