How shounak151/smart-fridge-backend works
Smart Fridge Backend is an Express API for managing fridge inventory and helping users reduce food waste. A client requests operations through the server and feature routes; handlers manage users, foods, goals, groceries, and intake, with MongoDB-backed models. Food records support expiry status, nutrition lookups, consumption/waste tracking, and replenishment lists. Separate capabilities provide recipe and macro suggestions, image-based fridge scanning, and expiry alerts by SMS. The tree and sampled files establish the server mounts and several service calls; unsampled feature internals and some route-to-controller wiring are not inferred.
Main entry points: server.js Express server · foodController.js Food operations · alertService.js Alert service · geminiService.js Gemini service
Components 29
API entry
- Express server
server.js - Food routes
routes/foodRoutes.js - Goal routes
routes/goalRoutes.js - Recipe routes
routes/recipeRoutes.js - Grocery routes
routes/groceryRoutes.js - Intake routes
routes/intakeRoute.js - Auth routes
routes/authRoutes.js - Vision routes
routes/visionRoutes.js
Fridge inventory
- Food operations
controllers/foodController.js - Food records
models/Food.js - Grocery operations
controllers/groceryController.js - Grocery lists
models/GroceryList.js - Expiry status
services/expiryService.js - Nutrition lookup
services/nutritionService.js
Food planning
- Goal suggestions
controllers/goalController.js - User goals
models/UserGoal.js - Recipe service
services/recipeService.js - Gemini service
services/geminiService.js - Intake operations
controllers/intakeController.js - Intake records
models/Intake.js
Accounts and tracking
- Authentication
controllers/authController.js - User records
models/User.js
Expiry alerts
- Alert routes
routes/alertRoutes.js - Alert service
services/alertService.js
Other components
- API client
- Nutrition provider
- Google Gemini
- MongoDB
config/db.js - SMS provider
Connections 31
- API client → Express server: requests
- Express server → Food routes: mounts
- Express server → Goal routes: mounts
- Express server → Recipe routes: mounts
- Express server → Grocery routes: mounts
- Express server → Intake routes: mounts
- Express server → Auth routes: mounts
- Express server → Vision routes: mounts
- Express server → Alert routes: mounts
- Express server → MongoDB: connects
- Food operations → Food records: reads/writes
- Food operations → Expiry status: checks status
- Food operations → Nutrition lookup: requests nutrition
- Nutrition lookup → Nutrition provider: fetches data
- Food operations → User records: updates stats
- Food operations → Grocery lists: adds depleted food
- Grocery operations → Grocery lists: reads/writes
- Goal suggestions → User goals: saves goals
- Goal suggestions → Food records: reads inventory
- Goal suggestions → Gemini service: requests macros
- Gemini service → Google Gemini: generates suggestions
- Recipe service → Gemini service: uses AI
- Vision routes → Gemini service: scans image
- Gemini service → Google Gemini: identifies items
- Intake operations → Intake records: reads/writes
- Authentication → User records: reads/writes
- Alert routes → Alert service: triggers alerts
- Alert service → Food records: checks inventory
- Alert service → Expiry status: checks status
- Express server → Alert service: schedules checks
- Alert service → SMS provider: sends SMS