231}
232
233// Helper functions to map database rows to TypeScript types
234function mapDbUserToUser(row: any): User {
235 return {
4import { INFERENCE_CALLS_TABLE, USAGE_TABLE } from "./schema.tsx";
5
6// Eventually we'll have a user database,
7// but in the meantime, we can cache user info in memory
8const userIdCache: { [key: string]: any } = {};
23```
24โโโ backend/
25โ โโโ database/
26โ โ โโโ migrations.ts # Database schema
27โ โ โโโ queries.ts # Database operations
28โ โโโ routes/
29โ โ โโโ products.ts # Product management endpoints
62
63- **Backend**: Hono.js API framework
64- **Database**: SQLite for data storage
65- **Frontend**: React with TypeScript
66- **Styling**: TailwindCSS
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import type { ChatMessage, ApiResponse } from "../../shared/types.ts";
3import { createChatMessage, getChatMessages } from "../database/queries.ts";
4
5const app = new Hono();
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2
3// Database schema setup for Daily Blog platform
4export async function runMigrations() {
5 console.log("Running database migrations...");
6
7 // Users table
77 await sqlite.execute(`CREATE INDEX IF NOT EXISTS idx_likes_user_post ON likes(user_id, post_id)`);
78
79 console.log("Database migrations completed successfully");
80}
81
7 updateProperty,
8 deleteProperty
9} from "../database/queries.ts";
10
11const app = new Hono();
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
3import { runMigrations } from "./database/migrations.ts";
4import properties from "./routes/properties.ts";
5import chat from "./routes/chat.ts";
12});
13
14// Initialize database
15await runMigrations();
16
35 `);
36
37 console.log('Database migrations completed');
38}
39
16```
17โโโ backend/
18โ โโโ database/
19โ โ โโโ migrations.ts # Database schema setup
20โ โ โโโ queries.ts # Database query functions
21โ โโโ routes/
22โ โ โโโ auth.ts # Authentication routes
44- **Backend**: Hono (TypeScript API framework)
45- **Frontend**: React 18.2.0 with TypeScript
46- **Database**: SQLite
47- **Styling**: TailwindCSS
48- **Storage**: Val Town Blob for user avatars
50## Getting Started
51
521. The backend automatically sets up the database on first run
532. Visit the main page to start browsing posts
543. Create an account to start posting and interacting
11```
12โโโ backend/
13โ โโโ database/
14โ โ โโโ migrations.ts # Database schema setup
15โ โ โโโ queries.ts # Database query functions
16โ โโโ routes/
17โ โ โโโ properties.ts # Property CRUD operations
41## Tech Stack
42
43- **Backend**: Hono.js with SQLite database
44- **Frontend**: React with TypeScript
45- **Styling**: TailwindCSS