64 const { blob } = await import("https://esm.town/v/std/blob");
65
66 // Unique key for this val's database tables
67 const KEY = "AI_generated_Pictures";
68 const SCHEMA_VERSION = 1;
1import { serveFile } from "https://esm.town/v/std/utils/index.ts";
2import { generateCode } from "./backend/generate-code.ts";
3import { createTables } from "./database/migrations.ts";
4import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries.ts";
5
6await createTables();
1209 throw new Error("Notion API token not found");
1210 }
1211 const databaseId = "16e2c190bff080fd9ea8d2a8c21548b0";
1212
1213 // Use database query with filter instead of direct page fetch
1214 const response = await fetch(`https://api.notion.com/v1/databases/${databaseId}/query`, {
1215 method: "POST",
1216 headers: {
1247
1248 if (!response.ok) {
1249 throw new Error(`Failed to query Notion database: ${response.statusText}`);
1250 }
1251
379];
380
381// Insert memories into the database
382async function insertDemoMemories() {
383 try {
420 await insertDemoMemories();
421
422 console.log("Demo database successfully populated!");
423 return "Demo database successfully populated!";
424 } catch (error) {
425 console.error("Error populating demo database:", error);
426 throw error;
427 }
9- The **client-side entrypoint** is `/frontend/index.html`, which in turn imports `/frontend/index.tsx`, which in turn imports the React app from `/frontend/components/App.tsx`.
10
11[React Hono Example](https://www.val.town/x/stevekrouse/reactHonoExample) is a fuller featured example project, with a SQLite database table, queries, client-side CSS and a favicon, and some shared code that runs on both client and server.
13## Technical Architecture
14
15**⚠️ 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.**
16
17Stevens 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
48
49## 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.
58
59**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.**
60
61Overall 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.
9- The **client-side entrypoint** is `/frontend/index.html`, which in turn imports `/frontend/index.tsx`, which in turn imports the React app from `/frontend/components/App.tsx`.
10
11[React Hono Example](https://www.val.town/x/stevekrouse/reactHonoExample) is a fuller featured example project, with a SQLite database table, queries, client-side CSS and a favicon, and some shared code that runs on both client and server.
12 I just made a change to it
13
46 }
47
48 // Now it's time to upload things to database and blob storage
49 // First, add to database, and get the ID
50 const id = await sqlite.execute(
51 `INSERT INTO ${TABLE_NAME} (title, data, type, time) VALUES ($title, $data, $type, CURRENT_TIMESTAMP)`,
126 }
127
128 console.log(`Weather forecast updated in the database.`);
129 return summary;
130}
120 }
121
122 console.log(`Calendar events imported into the database.`);
123 return events;
124 } catch (error) {