198```
199โโโ backend/
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
257 ```
258
259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
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();
24 // Get page contents from Notion
25 const page = await notion.pages.retrieve({ page_id: pageId });
26 // Extract the parent database ID from the page
27 let parentId = null;
28 if (page.parent && page.parent.type === "database_id") {
29 parentId = page.parent.database_id;
30 }
31
32 // retrieve the Notion database with the parentId and get the title
33 const db = await notion.databases.retrieve({ database_id: parentId });
34 const dbTitle = db.title[0].plain_text;
35
67 // Get page contents from Notion
68 const page = await notion.pages.retrieve({ page_id: pageId });
69 // Extract the parent database ID from the page
70 let parentId = null;
71 if (page.parent && page.parent.type === "database_id") {
72 parentId = page.parent.database_id;
73 }
74
75 // retrieve the Notion database with the parentId and get the title
76 const db = await notion.databases.retrieve({ database_id: parentId });
77 const dbTitle = db.title[0].plain_text;
78
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();
2import { Favorite } from "../shared/types.ts";
3
4// Database configuration
5const TABLE_NAME = "favorite_cards_v2";
6
7/**
8 * Sets up the database schema and sample data if needed
9 */
10export async function setupDatabase(): Promise<void> {
11 await sqlite.execute(`CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
12 id INTEGER PRIMARY KEY AUTOINCREMENT,
68
69/**
70 * Adds a new favorite to the database
71 */
72export async function addFavorite(favorite: Favorite): Promise<number> {
95
96/**
97 * Updates an existing favorite in the database
98 */
99export async function updateFavorite(favorite: Favorite): Promise<boolean> {
24}
25
26// Database of languages and their vowel systems
27export const languages: Language[] = [
28 {
7- `backend/`: Contains the API for serving language vowel data
8 - `index.ts`: Main entry point for the HTTP API
9 - `data.ts`: Database of languages and their vowel systems
10
11- `frontend/`: Contains the UI for browsing vowels
8- Filter cards by type (Movie, Game, Book, etc.) and tag (Entertainment, Education, Lifestyle)
9- Add new favorites through a dropdown form
10- SQLite database for data storage
11- Responsive card grid layout
12- Hover effects for card details
39- Iconify for icons
40
41## Database Schema
42
43The application uses a SQLite database with the following schema:
44
45```sql
5const app = new Hono();
6
7// Database setup
8const TABLE_NAME = "favorite_cards_v2";
9
25}
26
27async function setupDatabase() {
28 await sqlite.execute(`CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
29 id INTEGER PRIMARY KEY AUTOINCREMENT,
144// Routes
145app.get("/", async (c) => {
146 await setupDatabase();
147
148 const url = new URL(c.req.url);
180 };
181
182 await setupDatabase();
183 await addFavorite(favorite);
184
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();