Public
Basic Assistance Request App
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

🤖 Townie AI Assistant

A request tracker app built on Val Town with persistent storage — submitted requests are saved to SQLite and automatically loaded when the page opens.

How Persistence Works

Rendering mermaid diagram...

Two Persistence Layers

LayerPurposeHow
SQLite (primary)Durable, queryable storagestd/sqlite/main.ts — per-val database
Blob Storage (backup)Redundant mirrorstd/blob — JSON snapshot synced on every write

Data Structure

CREATE TABLE requests ( id INTEGER PRIMARY KEY AUTOINCREMENT, text TEXT NOT NULL, status TEXT NOT NULL DEFAULT 'pending', -- pending | in-progress | resolved timestamp TEXT NOT NULL DEFAULT (datetime('now')) )

Validation (3 layers)

LayerChecks
Frontend (React)Empty input, min 3 chars, max 1000 chars, disables button
Backend (Hono)Type check, empty/whitespace, min/max length
Database-levelDuplicate detection within 60 seconds, NOT NULL constraints

API Endpoints

MethodPathDescription
GET/api/requestsRetrieve all saved requests
POST/api/requestsSubmit a new request
PATCH/api/requests/:idUpdate status (pending → in-progress → resolved)
DELETE/api/requests/:idDelete a request
GET/api/validation-rulesGet validation rules
GET/api/backup-infoView blob backup status

File Structure

  • main.ts — Hono backend: SQLite + blob persistence, validation, API routes
  • frontend/index.html — HTML shell with Twind
  • frontend/index.tsx — React entry point
  • frontend/components/App.tsx — State management, fetches saved data on load
  • frontend/components/RequestForm.tsx — Form with client-side validation
  • frontend/components/RequestList.tsx — Displays requests with status badges