How doom1817/fridge_guardian works
Fridge Guardian lets users manage food inventory, track expiry, and use AI to generate recipes from selected ingredients. The main flow is authenticated user → inventory management and expiry monitoring → AI recipe generation → saved recipe and feedback; the dashboard also summarizes consumed and wasted food. The README describes caching, alerts, and visualizations; sampled code confirms the food, authentication, and AI flows, but does not expose every subsystem’s wiring, so those links are omitted where uncertain.
Main entry points: AiServiceImpl.java AI Service · FoodApiController.java Food API · AiApiController.java AI API · FoodItemServiceImpl.java Food Service
Components 26
Access and Pages
- Web Pages
src/main/java/com/doom/fg/controller/PageController.java - Food UI
src/main/resources/static/js/food_list.js - Expiry UI
src/main/resources/static/js/expiring_alert.js - AI UI
src/main/resources/static/js/ai_recipe.js - Authentication API
src/main/java/com/doom/fg/controller/AuthController.java - JWT Utilities
src/main/java/com/doom/fg/util/JwtUtil.java - JWT Filter
src/main/java/com/doom/fg/security/JwtFilter.java - Dashboard UI
src/main/resources/static/js/index.js - User Service
src/main/java/com/doom/fg/service/impl/UserServiceImpl.java
Food Inventory
- Food API
src/main/java/com/doom/fg/controller/FoodApiController.java - Food Service
src/main/java/com/doom/fg/service/impl/FoodItemServiceImpl.java - Category Service
src/main/java/com/doom/fg/service/impl/CategoryServiceImpl.java - Expiry Scanner
src/main/java/com/doom/fg/task/ExpiryAlertTask.java
AI Recipes
- AI API
src/main/java/com/doom/fg/controller/AiApiController.java - AI Service
src/main/java/com/doom/fg/service/impl/AiServiceImpl.java - Prompt Builder
src/main/java/com/doom/fg/util/AiPrompts.java - AI Engine
src/main/java/com/doom/fg/util/OpenAiCompatibleEngine.java - Recipe Records
src/main/java/com/doom/fg/service/impl/RecipeRecordServiceImpl.java
Persistence and Cache
- Food Storage
src/main/java/com/doom/fg/mapper/FoodItemMapper.java - Category Storage
src/main/java/com/doom/fg/mapper/CategoryMapper.java - User Storage
src/main/java/com/doom/fg/mapper/UserMapper.java - Recipe Storage
src/main/java/com/doom/fg/mapper/RecipeRecordMapper.java - AI Log Storage
src/main/java/com/doom/fg/mapper/AiApiLogMapper.java - Redis Cache
Other components
- User
- LLM Provider
Connections 29
- User → Web Pages: opens
- User → Authentication API: authenticates
- Authentication API → User Service: checks or saves
- Authentication API → JWT Utilities: issues token
- User → Food UI: manages food
- Food UI → Food API: requests inventory
- Expiry UI → Food API: requests alerts
- Food API → Food Service: queries and updates
- Food API → Category Service: lists categories
- Food Service → Food Storage: reads and writes
- Category Service → Category Storage: reads categories
- Expiry Scanner → Food Service: scans expiry
- User → Dashboard UI: views statistics
- Dashboard UI → Food API: requests statistics
- User → AI UI: selects ingredients
- AI UI → AI API: requests recipe
- AI API → AI Service: generates or chats
- AI API → User Service: saves AI config
- AI API → AI Log Storage: queries usage trends
- AI Service → Food Service: loads ingredients
- AI Service → Prompt Builder: builds prompts
- AI Service → AI Engine: sends prompt and history
- AI Engine → LLM Provider: calls completions API
- AI Service → Recipe Records: saves generated recipe
- Recipe Records → Recipe Storage: reads and writes
- AI Service → AI Log Storage: writes call logs
- AI Service → Redis Cache: reads and writes chat history
- User Service → User Storage: reads and writes
- JWT Filter → JWT Utilities: validates token