openai-client.cursorrules2 matches
198```
199โโโ backend/
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
257```
258259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
openai-clientknowledge.md2 matches
198```
199โโโ backend/
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
257```
258259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
reactHonoStarterREADME.md1 match
21## Further resources
2223- [React Hono Example](https://www.val.town/x/stevekrouse/reactHonoExample) is a bigger example project, with a SQLite database table, queries, client-side CSS, a favicon, and shared code that runs on both client and server.
sqliteExplorerApp1README.md1 match
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
securityknowledge.md2 matches
198```
199โโโ backend/
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
257```
258259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
security.cursorrules2 matches
198```
199โโโ backend/
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
257```
258259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
hm-invoicesv1PLAN.md16 matches
56## Phase Completion Checklist
7- [x] Phase 1: Foundation & Database Setup
8- [x] Phase 2: Core Backend API
9- [x] Phase 3: Frontend Foundation
11- [ ] Phase 5: Polish & Optimization
1213## Database Schema
14```sql
15CREATE TABLE invoices (
31```
3233## Phase 1: Foundation & Database Setup
34**Goal**: Set up project structure and database with admin tools
3536### Tasks:
40- Create `shared/types.ts` for TypeScript interfaces
41422. **Database Admin Tools**
43- Create `admin/db-tools.tsx` for database management
44- Create `admin/db-viewer.tsx` for raw data inspection
45- Implement seed data with 16 placeholder vendors
46- Add SQL commands section with common queries for manual operations
47- Include link to database explorer: https://arfan25-admin-sqliteexplorerapp.val.run/
48493. **Backend Database Layer**
50- Create `backend/database/queries.ts` with CRUD operations
51- Implement vendor management functions
52- Implement invoice management functions
5354### Deliverables:
55- Working admin interface for database management
56- Seeded database with 16 vendors
57- Complete CRUD operations for invoices and vendors
581571583. **Performance & Polish**
159- Optimize database queries
160- Add pagination for large datasets
161- Improve mobile responsiveness
172## Technical Stack
173- **Backend**: Hono.js for API routes
174- **Database**: SQLite with Val Town's sqlite service
175- **Frontend**: React 18.2.0 with TypeScript
176- **Styling**: DaisyUI + TailwindCSS with nord theme
186- **Dashboard**: Overview statistics and trends
187- **Filtering**: By vendor, type, status, date range
188- **Admin Tools**: Database management, seeding, and SQL command helpers
189- **Database Explorer**: Direct link to external SQLite explorer for advanced queries
190191## Deployment Strategy
192Each phase will be deployable and functional, allowing for iterative development and testing. The admin tools will be available throughout for database management and debugging.
hm-invoicesv1VAL-TOWN-RULES.md33 matches
158```
159โโโ admin/
160โ โโโ db-viewer.tsx # Raw database table viewer
161โ โโโ db-tools.tsx # Database management interface (seed, clear, status)
162โ โโโ README.md
163โโโ backend/
164โ โโโ database/
165โ โ โโโ queries.ts # DB query functions (CRUD operations)
166โ โ โโโ README.md
182โโโ shared/
183โโโ README.md
184โโโ config.ts # Database table names and shared config
185โโโ utils.ts # Shared types and functions
186```
187188### Admin Folder - Database Management
189190The `admin/` folder contains standalone utilities for database management, separate from your main application logic:
191192#### **db-viewer.tsx** - View raw database tables
193```ts
194import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
202```
203204#### **db-tools.tsx** - Database management interface
205```ts
206import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
210const app = new Hono();
211212// HTML interface for the database tools
213const HTML_INTERFACE = `
214<!DOCTYPE html>
217<meta charset="UTF-8">
218<meta name="viewport" content="width=device-width, initial-scale=1.0">
219<title>Database Tools</title>
220<script src="https://cdn.twind.style" crossorigin></script>
221</head>
222<body class="bg-gray-100 min-h-screen py-8">
223<div class="max-w-2xl mx-auto bg-white rounded-lg shadow-md p-6">
224<h1 class="text-3xl font-bold text-gray-800 mb-6">Database Tools</h1>
225
226<div class="space-y-4 mb-6">
227<div class="bg-blue-50 border border-blue-200 rounded-lg p-4">
228<h2 class="text-lg font-semibold text-blue-800 mb-2">Database Status</h2>
229<p class="text-blue-700">Table: <code class="bg-blue-100 px-2 py-1 rounded">${TABLE_NAME}</code></p>
230<button onclick="getStatus()" class="mt-2 bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded transition-colors">
234
235<div class="bg-green-50 border border-green-200 rounded-lg p-4">
236<h2 class="text-lg font-semibold text-green-800 mb-2">Seed Database</h2>
237<p class="text-green-700 mb-2">Load initial data into the database.</p>
238<button onclick="seedDatabase()" class="bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded transition-colors">
239Seed Data
240</button>
250
251<div class="bg-red-50 border border-red-200 rounded-lg p-4">
252<h2 class="text-lg font-semibold text-red-800 mb-2">Clear Database</h2>
253<p class="text-red-700 mb-2">Remove all data from the database.</p>
254<button onclick="clearDatabase()" class="bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded transition-colors">
255Clear Database
256</button>
257</div>
283}
284285function seedDatabase() {
286makeRequest('seed');
287}
291}
292293function clearDatabase() {
294if (confirm('Are you sure you want to clear all data from the database?')) {
295makeRequest('clear');
296}
304app.get("/", (c) => c.html(HTML_INTERFACE));
305306// Handle POST requests - perform database operations
307app.post("/", async (c) => {
308const url = new URL(c.req.url);
315return c.json({
316success: true,
317message: "Database status retrieved",
318data: { table: TABLE_NAME, rowCount: count[0]?.count || 0 }
319});
337}
338
339return c.json({ success: true, message: "Database seeded successfully", data: { seeded: seedData.length } });
340341case "force-seed":
352}
353
354return c.json({ success: true, message: "Database force re-seeded successfully", data: { seeded: newSeedData.length } });
355356case "clear":
357await sqlite.execute(`DELETE FROM ${TABLE_NAME}`);
358return c.json({ success: true, message: "Database cleared successfully" });
359360default:
373- Hono is the recommended API framework
374- Main entry point should be `main.tsx`
375- **Database Setup:** Use the admin utilities to handle table creation and seeding. Backend should focus on CRUD operations only
376- **Database Queries:** Keep all query functions in `backend/database/queries.ts` with proper TypeScript typing
377- **Static asset serving:** Use the utility functions to read and serve project files:
378```ts
406```
407408### Database Patterns
409- **Setup:** Use admin utilities (`db-tools.tsx`) to create tables and seed initial data
410- **Development:** Use `db-viewer.tsx` to inspect database contents during development
411- **Reset:** Use `db-tools.tsx` to clear database when needed
412- **Backend Focus:** Backend database queries should only handle CRUD operations, not table creation
413- Change table names when modifying schemas rather than altering (update in `shared/config.ts`)
414- Export clear query functions with proper TypeScript typing
hm-invoicesv1main.tsx7 matches
3import { serveFile, readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
4import {
5initializeDatabase,
6getAllVendors,
7getVendorById,
14seedVendors,
15getTableCounts
16} from "./backend/database/queries.ts";
17import {
18isValidStatus,
61});
6263// Initialize database on startup
64try {
65await initializeDatabase();
66console.log("Database initialized successfully");
67} catch (error) {
68console.error("Database initialization failed:", error);
69}
70501});
502503// GET /api/test - Test database functionality
504app.get("/api/test", async (c) => {
505try {
hm-invoicesv1queries.ts2 matches
12} from "../../shared/types.ts";
1314// Database initialization
15export async function initializeDatabase(): Promise<void> {
16// Create vendors table
17await sqlite.execute(`