HHGtoMyDay.cursorrules2 matches
208```
209├── backend/
210│ ├── database/
211│ │ ├── migrations.ts # Schema definitions
212│ │ ├── queries.ts # DB query functions
270- Handle API calls properly with proper error catching
271272### Database Patterns
273- Run migrations on startup or comment out for performance
274- Change table names when modifying schemas rather than altering
untitled-2512new-file-9861.tsx7 matches
7* * This Val ingests an autism resource document (URL, Text, PDF Upload via POST),
8* uses an LLM to extract searchable tags and phrases relevant to parents,
9* stores these tags in an SQLite database.
10* * A GET request to this Val will display a UI to view and search stored tags,
11* and also to upload new resources.
69}
7071// --- SQLite Database Name ---
72const DB_NAME = "autism_resources_tags.sqlite"; // Used as a label, actual file name managed by @std/sqlite
73const MAX_FILE_SIZE_MB = 10;
328<div class="container">
329<div class="info-box">
330<p>This page displays searchable tags extracted from autism resource documents and allows you to upload new resources for processing. Tags are stored in an SQLite database (<code>${DB_NAME}</code>).</p>
331<p>To add new documents programmatically, send a <code>POST</code> request to <a href="${sourceUrl}" target="_blank">${sourceUrl}</a>.
332See the POST endpoint documentation for payload format (e.g., via a GET request to the same URL with a non-browser User-Agent, or check the Val's code).</p>
352</form>
353354${dbError ? `<div class="db-error"><strong>Database Error:</strong> ${dbError}</div>` : ""}
355356<input type="text" id="searchInput" placeholder="Search tags or document identifiers...">
388if (!container) return;
389if (!filteredData || filteredData.length === 0) {
390container.innerHTML = '<p class="no-tags">No tags found matching your criteria, or the database is empty.</p>';
391return;
392}
841storedCount = await storeTags(documentIdentifier, extractedTags, log);
842} catch (e) {
843log.push({ agent: "System", type: "error", message: `Database operation failed: ${e.message}` });
844}
845} else if (!documentIdentifier) {
930const hasCriticalError = finalLog.some(e =>
931e.type === "error"
932&& (e.message?.includes("Halt:") || e.agent === "System" && e.message?.includes("Database operation failed"))
933);
934
untitled-4923main.tsx6 matches
7* * This Val ingests an autism resource document (URL, Text, PDF Upload via POST),
8* uses an LLM to extract searchable tags and phrases relevant to parents,
9* stores these tags in an SQLite database.
10* * A GET request to this Val will display a UI to view and search stored tags.
11* * It utilizes the LLM-Safe Fork of @std/sqlite (adjust import if necessary).
68}
6970// --- SQLite Database Name ---
71const DB_NAME = "autism_resources_tags.sqlite"; // Used as a label, actual file name managed by @std/sqlite
72const MAX_FILE_SIZE_MB = 10;
258<div class="container">
259<div class="info-box">
260<p>This page displays searchable tags extracted from autism resource documents. Tags are stored in an SQLite database (<code>${DB_NAME}</code>).</p>
261<p>To add new documents for processing, send a <code>POST</code> request to <a href="${sourceUrl}" target="_blank">${sourceUrl}</a>.
262See the POST endpoint documentation for payload format (e.g., via a GET request to the same URL with a non-browser User-Agent, or check the Val's code).</p>
263</div>
264265${dbError ? `<div class="db-error"><strong>Database Error:</strong> ${dbError}</div>` : ""}
266267<input type="text" id="searchInput" placeholder="Search tags or document identifiers...">
287if (!container) return;
288if (!filteredData || filteredData.length === 0) {
289container.innerHTML = '<p class="no-tags">No tags found matching your criteria, or the database is empty.</p>';
290return;
291}
665storedCount = await storeTags(documentIdentifier, extractedTags, log); // No db object passed
666} catch (e) {
667log.push({ agent: "System", type: "error", message: `Database operation failed: ${e.message}` });
668}
669} else if (!documentIdentifier) {
stevensDemosetupTelegramChatDb.ts2 matches
1// Script to set up the telegram_chats table in SQLite
2// Run this script manually to create the database table
34export default async function setupTelegramChatDb() {
25`);
2627return "Telegram chat database table created successfully.";
28} catch (error) {
29console.error("Error setting up telegram_chats table:", error);
stevensDemoREADME.md3 matches
13## Technical Architecture
1415**⚠️ important caveat: the admin dashboard doesn't have auth! currently it just relies on security by obscurity of people not knowing the url to a private val. this is not very secure. if you fork this project and put sensitive data in a database you should think carefully about how to secure it.**
1617Stevens has been designed with the utmost simplicity and extensibility, much like a well-organized household. At the heart of his operation lies a single "memories" table - a digital equivalent of a butler's meticulous records. This table serves as the foundation for all of Stevens' operations.
45- `dashboard`: the admin view for showing the memories notebook + visualizing imports
46- `dailyBriefing`: stuff related to sending a daily update via telegram
47- `dbUtils`: little one-off scripts for database stuff
4849## Hiring your own Stevens
57- For the Google Calendar integration you'll need `GOOGLE_CALENDAR_ACCOUNT_ID` and `GOOGLE_CALENDAR_CALENDAR_ID`. See [these instuctions](https://www.val.town/v/stevekrouse/pipedream) for details.
5859**important caveat: the admin dashboard doesn't have auth! currently it just relies on security by obscurity of people not knowing the url to a private val. this is not very secure, if you put sensitive data in a database you should think carefully about how to secure it.**
6061Overall it's a simple enough project that I encourage you to just copy the ideas and run in your own direction rather than try to use it as-is.
stevensDemoREADME.md2 matches
45* `index.ts` - this is the **entrypoint** for this whole project
6* `database/` - this contains the code for interfacing with the app's SQLite database table
78## Hono
26## CRUD API Routes
2728This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
2930## Errors
stevensDemoREADME.md6 matches
1# Database
23This app uses [Val Town SQLite](https://docs.val.town/std/sqlite/) to manage data. Every Val Town account comes with a free SQLite database, hosted on [Turso](https://turso.tech/). This folder is broken up into two files:
45* `migrations.ts` - code to set up the database tables the app needs
6* `queries.ts` - functions to run queries against those tables, which are imported and used in the main Hono server in `/backend/index.ts`
78## Migrations
910In `backend/database/migrations.ts`, this app creates a new SQLite table `reactHonoStarter_messages` to store messages.
1112This "migration" runs once on every app startup because it's imported in `index.ts`. You can comment this line out for a slight (30ms) performance improvement on cold starts. It's left in so that users who fork this project will have the migration run correctly.
1314SQLite has much more limited support for altering existing tables as compared to other databases. Often it's easier to create new tables with the schema you want, and then copy the data over. Happily LLMs are quite good at those sort of database operations, but please reach out in the [Val Town Discord](https://discord.com/invite/dHv45uN5RY) if you need help.
1516## Queries
1718The queries file is where running the migrations happen in this app. It'd also be reasonable for that to happen in index.ts, or as is said above, for that line to be commented out, and only run when actual changes are made to your database schema.
1920The queries file exports functions to get and write data. It relies on shared types and data imported from the `/shared` directory.
stevensDemopopulateDemo.ts4 matches
374];
375376// Insert memories into the database
377async function insertDemoMemories() {
378try {
415await insertDemoMemories();
416417console.log("Demo database successfully populated!");
418return "Demo database successfully populated!";
419} catch (error) {
420console.error("Error populating demo database:", error);
421throw error;
422}
stevensDemomemoryUtils.ts1 match
23/**
4* Retrieves all memories from the database
5* @param includeDate Whether to include date-specific memories or not
6* @param startDate Optional start date to filter memories from (ISO format)
stevensDemoindex.ts1 match
6import { Hono } from "npm:hono";
7import { type Memory } from "../shared/types.ts";
8import { createMemory, deleteMemory, getAllMemories, updateMemory } from "./database/queries.ts";
910const app = new Hono();