How guadoesdev/kainlab works
KainLab lets users authenticate, log meals by text or food photo, and review nutrition summaries and trends. The browser sends authenticated requests to the Express API; the backend analyzes and validates meal input, then serves meal, profile, chat, and summary data. Supabase provides authentication and persistent PostgreSQL storage, while the in-memory repositories are an alternative backend store. The README documents additional dashboard and account capabilities; unsampled route details are not inferred beyond the shown wiring.
Main entry points: TodayScreen.tsx Today workspace · server.ts Express API · App.tsx App shell · nutritionRepository.ts Nutrition API client
Components 25
Web app
- App shell
src/App.tsx - Sign-in and signup
src/components/AuthFormPanel.tsx - Today workspace
src/components/TodayScreen.tsx - Meal chat
src/components/NutritionChatPanel.tsx - Food camera
src/components/CameraCaptureModal.tsx - Meal history
src/components/MealHistoryList.tsx - Daily summary
src/components/DailySummaryCard.tsx - Calorie trends
src/components/CalorieTrendChart.tsx - Summary dashboards
src/components/SummaryPage.tsx - Profile settings
src/components/ProfilePage.tsx - Nutrition API client
src/lib/nutritionRepository.ts - CSV export
src/lib/csvExport.ts
Identity and profiles
- Supabase browser auth
src/lib/supabaseAuth.ts - Profile service
src/lib/profileService.ts - Supabase Auth
Nutrition API
- Express API
server.ts - JWT verification
server/middleware/auth.ts - Nutrition service
server/services/nutritionService.ts - Gemini analysis
server/ai/geminiNutritionProvider.ts - Gemini API
Nutrition data
- Meal ledger interface
server/repositories/mealRepository.ts - Supabase repository
server/repositories/supabaseNutritionRepository.ts - Memory repository
server/repositories/memoryNutritionStore.ts - Supabase PostgreSQL
supabase/schema.sql
Other components
- User
Connections 30
- User → App shell: uses
src/App.tsx - App shell → Sign-in and signup: renders
src/App.tsx - App shell → Today workspace: renders
src/App.tsx - App shell → Supabase browser auth: subscribes
src/App.tsx - App shell → Profile service: syncs profile
src/App.tsx - Sign-in and signup → Supabase browser auth: authenticates
src/components/AuthFormPanel.tsx - Supabase browser auth → Supabase Auth: authenticates with
README.md - Today workspace → Meal chat: renders
src/components/TodayScreen.tsx - Today workspace → Meal history: renders
src/components/TodayScreen.tsx - Today workspace → Daily summary: renders
src/components/TodayScreen.tsx - Today workspace → Calorie trends: renders
src/components/TodayScreen.tsx - Today workspace → Summary dashboards: renders
src/components/TodayScreen.tsx - Today workspace → Profile settings: renders
src/components/TodayScreen.tsx - Today workspace → Nutrition API client: loads nutrition
src/components/TodayScreen.tsx - Meal chat → Food camera: opens
src/components/NutritionChatPanel.tsx - Meal chat → Nutrition API client: submits meals
src/lib/nutritionRepository.ts - Summary dashboards → Nutrition API client: loads summaries
src/components/SummaryPage.tsx - Summary dashboards → CSV export: exports data
src/components/SummaryPage.tsx - Profile settings → Profile service: updates profile
src/components/ProfilePage.tsx - Profile service → Express API: sends profile requests
src/lib/profileService.ts - Nutrition API client → Express API: sends API requests
src/lib/nutritionRepository.ts - Express API → JWT verification: verifies requests
README.md - Express API → Nutrition service: processes meal input
server.ts - Express API → Gemini analysis: constructs provider
server.ts - Nutrition service → Gemini analysis: analyzes meals
server/services/nutritionService.ts - Gemini analysis → Gemini API: requests analysis
README.md - Express API → Supabase repository: dispatches storage
server.ts - Express API → Memory repository: dispatches storage
server.ts - Supabase repository → Supabase PostgreSQL: reads and writes
server/repositories/supabaseNutritionRepository.ts - Supabase repository → Meal ledger interface: implements interface
server/repositories/supabaseNutritionRepository.ts