Phase 1: auth, room CRUD, WebSocket chat, PWA frontend

Invite-only FastAPI + SQLAlchemy(async) + Postgres backend (session-cookie
auth via CLI-provisioned accounts, open-room CRUD, single-instance /ws/chat)
and a React + Vite PWA frontend (login, room list, chat view). Backend tests
pass against a local Postgres DB. See README.md and backend/README.md for
setup, and ARCHITECTURE.md for the full phased design.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-13 20:01:17 -06:00
co-authored by Claude Sonnet 5
parent 8ac35062dc
commit 99aa029c0d
77 changed files with 9042 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
import { apiFetch } from './client'
import type { User } from '../types'
// No register() here: this is an invite-only site. Accounts are created by
// an operator via the backend CLI (`python -m app.cli create-user`), not
// through a public endpoint.
export function login(usernameOrEmail: string, password: string): Promise<User> {
return apiFetch<User>('/api/auth/login', {
method: 'POST',
body: JSON.stringify({ username_or_email: usernameOrEmail, password }),
})
}
export function logout(): Promise<void> {
return apiFetch<void>('/api/auth/logout', { method: 'POST' })
}
export function me(): Promise<User> {
return apiFetch<User>('/api/auth/me')
}
+33
View File
@@ -0,0 +1,33 @@
export class ApiError extends Error {
status: number
constructor(status: number, message: string) {
super(message)
this.status = status
}
}
export async function apiFetch<T>(path: string, init?: RequestInit): Promise<T> {
const response = await fetch(path, {
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
...init,
})
if (!response.ok) {
let detail = response.statusText
try {
const body = await response.json()
detail = body.detail ?? detail
} catch {
// response had no JSON body
}
throw new ApiError(response.status, detail)
}
if (response.status === 204) {
return undefined as T
}
return (await response.json()) as T
}
+21
View File
@@ -0,0 +1,21 @@
import { apiFetch } from './client'
import type { Message, Room, RoomListItem } from '../types'
export function listRooms(): Promise<RoomListItem[]> {
return apiFetch<RoomListItem[]>('/api/rooms')
}
export function createRoom(name: string, description?: string): Promise<Room> {
return apiFetch<Room>('/api/rooms', {
method: 'POST',
body: JSON.stringify({ name, description: description || null }),
})
}
export function joinRoom(roomId: string): Promise<Room> {
return apiFetch<Room>(`/api/rooms/${roomId}/join`, { method: 'POST' })
}
export function getRoomMessages(roomId: string): Promise<Message[]> {
return apiFetch<Message[]>(`/api/rooms/${roomId}/messages`)
}