64}
65
66// Run this function to reset the database (for development only)
67export async function resetDatabase() {
68 await sqlite.execute(`DROP TABLE IF EXISTS ${ACCOUNTS_TABLE}`);
69 await sqlite.execute(`DROP TABLE IF EXISTS ${KYC_TABLE}`);
16```
17โโโ backend/
18โ โโโ database/
19โ โ โโโ migrations.ts # Schema definitions
20โ โ โโโ queries.ts # DB query functions
49- Backend: Hono (TypeScript)
50- Frontend: React with Tailwind CSS
51- Database: SQLite
52- Authentication: JWT
53- File Storage: Val Town Blob Storage
6
7- `index.ts` - Main entry point for the Hono API server
8- Database tables:
9 - `job_postings` - Stores job listings
10 - `chat_messages` - Stores chat messages
22- `POST /api/chat` - Post a new chat message
23
24## Database Schema
25
26### job_postings
14## Project Structure
15
16- `/backend` - Hono API server and SQLite database
17- `/frontend` - HTML, CSS, and JavaScript for the client-side application
18- `/shared` - Shared types and utilities
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { cors } from "https://esm.sh/hono@3.11.7/middleware";
3import { setupDatabase } from "./database/migrations.ts";
4import jobRoutes from "./routes/jobs.ts";
5import chatRoutes from "./routes/chat.ts";
19app.use("*", cors());
20
21// Setup database on startup
22app.use("*", async (c, next) => {
23 try {
24 await setupDatabase();
25 } catch (error) {
26 console.error("Database setup error:", error);
27 }
28 return next();
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { createChatMessage, getRecentChatMessages } from "../database/queries.ts";
3
4const chat = new Hono();
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { createJobPosting, getAllJobPostings, getJobPostingById } from "../database/queries.ts";
3
4const jobs = new Hono();
5export const CHAT_MESSAGES_TABLE = "chat_messages_v1";
6
7export async function setupDatabase() {
8 // Create job postings table
9 await sqlite.execute(`
30 `);
31
32 console.log("Database setup complete");
33}
15
16- `/backend`: Server-side code using Hono
17 - `/database`: SQLite database setup and queries
18 - `/routes`: API endpoints
19- `/frontend`: Client-side code
25
26- Backend: Hono (TypeScript)
27- Database: SQLite
28- Frontend: HTML, JavaScript, Tailwind CSS
29- Authentication: Simple username-based identification
193```
194โโโ backend/
195โ โโโ database/
196โ โ โโโ migrations.ts # Schema definitions
197โ โ โโโ queries.ts # DB query functions
253 ```
254
255### Database Patterns
256- Run migrations on startup or comment out for performance
257- Change table names when modifying schemas rather than altering