1// Database query functions for the meal planning application
2
3import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
261}
262
263// Helper function to convert database row to Meal object
264function rowToMeal(row: any): Meal {
265 return {
16```
17โโโ backend/
18โ โโโ database/
19โ โ โโโ migrations.ts # Database schema setup
20โ โ โโโ queries.ts # Database query functions
21โ โโโ routes/
22โ โ โโโ meals.ts # Meal-related API endpoints
51- **Backend**: Hono (TypeScript API framework)
52- **Frontend**: React with TypeScript
53- **Database**: SQLite for user preferences and meal data
54- **Styling**: TailwindCSS
55- **AI**: OpenAI for intelligent meal suggestions
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3import { getWeeklyProgress, getDailyGoals } from "../database/queries.ts";
4
5const app = new Hono();
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3import { upsertActivityData, upsertSleepData, addStressData } from "../database/queries.ts";
4import type { WearableDevice, FitbitActivityData, FitbitSleepData } from "../../shared/types.ts";
5
7 upsertMoodEntry,
8 getMoodByDate
9} from "../database/queries.ts";
10import type { MealEntry, FoodItem, HydrationEntry, MoodEntry, NutritionixFood } from "../../shared/types.ts";
11
121});
122
123// Search food database (Nutritionix integration)
124app.get("/search/:query", async (c) => {
125 try {
10 getSleepDataByDate,
11 getLatestSleepData
12} from "../database/queries.ts";
13import type { ActivityData, ExerciseSession, StressData, SleepData } from "../../shared/types.ts";
14
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2
3// Database schema for the Wellness Tracker App
4// Note: Change table names (add version suffix) when modifying schemas
5
6export async function runMigrations() {
7 console.log("Running database migrations...");
8
9 // Users table
232 await sqlite.execute(`CREATE INDEX IF NOT EXISTS idx_insights_user_date ON wellness_insights_v1 (user_id, date)`);
233
234 console.log("Database migrations completed successfully!");
235}
236
256}
257
258// Food database types (for Nutritionix integration)
259export interface NutritionixFood {
260 food_name: string;
22## Technology Stack
23
24- **Backend**: Hono.js API with SQLite database
25- **Frontend**: React with TypeScript
26- **Styling**: TailwindCSS
32```
33โโโ backend/
34โ โโโ database/
35โ โ โโโ migrations.ts # Database schema
36โ โ โโโ queries.ts # Database operations
37โ โโโ routes/
38โ โ โโโ activity.ts # Activity tracking endpoints
71- `FITBIT_CLIENT_ID` - Fitbit app client ID
72- `FITBIT_CLIENT_SECRET` - Fitbit app client secret
73- `NUTRITIONIX_APP_ID` - Nutritionix API for food database
74- `NUTRITIONIX_API_KEY` - Nutritionix API key
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 jobs from "./routes/jobs.ts";
5import chat from "./routes/chat.ts";
12});
13
14// Initialize database on startup
15await runMigrations();
16