Skip to content

Commit cbae80c

Browse files
committed
release: v2.0.0 - Architectural Overhaul & Refactoring
Complete modular refactoring of FoodAI: - Backend: Decoupled 'server.ts' into services (AI, Bring), database modules (connection, migrations), and shared utilities (units, categories). - Frontend: Implemented custom hooks (useInventory, useCalendar, useRecipes, useSettings) to separate business logic from the view layer. - Components: Broken down massive page components into smaller, reusable pieces (CategorySection, PackageItem). - API: Centralized all backend communication in a type-safe API client. - Stability: Fixed linting errors and added backend error logging to resolve inventory loading issues.
1 parent ff56bdf commit cbae80c

20 files changed

Lines changed: 1855 additions & 1863 deletions

README.md

Lines changed: 33 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
🌍 [English](README.md) | [Deutsch](README_DE.md) | [Français](README_FR.md) | [Español](README_ES.md) | [Italiano](README_IT.md)
2-
3-
<div align="center">
4-
<img src="foodai_banner.png" alt="FoodAI Banner" width="100%" />
5-
</div>
6-
7-
# 🍎 FoodAI
1+
# 🍎 FoodAI v2.0.0
82

93
**Master your inventory. Discover your next meal.**
104

11-
FoodAI is a self-hosted, AI-first kitchen inventory manager. It combines barcode scanning, computer vision, and generative AI to eliminate the friction of kitchen management — turning your pantry into an interactive culinary assistant.
5+
FoodAI is a self-hosted, AI-first kitchen inventory manager. Version 2.0.0 introduces a modern, modular architecture with separated services, custom hooks, and a decoupled backend for improved performance and maintainability.
126

137
[![PayPal](https://img.shields.io/badge/PayPal-Donate-blue?logo=paypal)](https://www.paypal.com/paypalme/germanquestions)
148

@@ -19,58 +13,30 @@ FoodAI has **no built-in authentication**. It is designed for trusted local netw
1913

2014
---
2115

22-
## ✨ Core Pillars
16+
## ✨ Core Pillars (v2.0 Architecture)
2317

2418
### 📸 Zero-Friction Inventory
25-
Forget manual data entry. Use **Vision Scan** to identify products and automatically extract expiry dates (MHD) directly from packaging. Whether it's a barcode lookup or a photo, the AI handles the logging.
19+
Forget manual data entry. Use **Vision Scan** to identify products and automatically extract expiry dates (MHD) directly from packaging. Our refactored **AI Service** handles multi-provider logic (Gemini, OpenAI, Anthropic, Ollama) with robust error handling.
2620

2721
### 👨‍🍳 Generative Culinary Intelligence
28-
FoodAI doesn't just list your food — it understands it. The **Generative Chef** analyzes your current stock and creates custom recipes and weekly meal plans tailored to what you have, prioritizing items nearing expiry.
22+
FoodAI doesn't just list your food — it understands it. The **Generative Chef** analyzes your current stock and creates custom recipes and weekly meal plans. The v2.0 update includes a new **Mathematical Deduction Engine** for precise inventory tracking.
2923

3024
### 📱 Premium Mobile Experience (PWA)
31-
Built for the modern kitchen. Fully installable **Progressive Web App** with smooth animations (Framer Motion) and a mobile-first UI that feels native on any device.
25+
Built for the modern kitchen. Fully installable **Progressive Web App** with smooth animations (Framer Motion) and a mobile-first UI. The frontend has been refactored into modular components and custom hooks (`useInventory`, `useCalendar`) for a snappy user experience.
3226

3327
---
3428

3529
## 🚀 Features
3630

37-
- **Smart Dashboard** — Real-time overview of expiring items, opened packages, and today's planned meals
38-
- **AI Barcode & Image Recognition** — Scan EAN/UPC barcodes or photograph any product for instant identification
39-
- **Per-Package Inventory** — Each physical package tracked individually with open/closed status and fill level
40-
- **Expiry (MHD) Scanning** — OCR via Tesseract.js with AI fallback to read best-before dates
41-
- **AI Recipe Generation** — Single recipes or full weekly meal plans from your inventory
42-
- **Extra Ingredients Toggle** — Optionally allow AI to suggest items you don't have
43-
- **Favorite Recipes** — Save and reuse recipes without adding to calendar
44-
- **Meal Calendar** — Plan meals, mark as cooked, auto-deduct ingredients
45-
- **Smart Deduction** — Opens packages as needed, adjusts remaining amounts
46-
- **Shopping List** — Auto-calculates missing ingredients for planned meals
47-
- **Free Cook Mode** — Photograph ingredients on the counter, AI matches to inventory
48-
- **Bring! Integration** — Send missing ingredients to the Bring! shopping list app
49-
- **Mirror Display** — Dark-themed `/mirror/today` endpoint for smart mirror embedding
50-
- **Multi-Language** — German, English, Spanish (more via community contributions)
51-
- **Multi-AI Provider** — Switch providers in-app, no restart needed
52-
- **Dark/Light/Custom Theme** — Switch between Light, Dark, and Custom themes in Settings. Custom theme supports uploading a CSS file.
53-
- **Per-Item Price Tracking** — Each inventory item can have a price (EUR). Dashboard shows total stock value.
54-
- **Storage Location** — Assign items to Vorratsschrank, Kuehlschrank, Gefrierschrank, Speisekammer, or Keller.
55-
- **Minimum Stock Warnings** — Set a min_stock threshold per item. Dashboard shows low-stock count.
56-
- **RSS Food Inspiration** — Dashboard sidebar shows daily recipe ideas from GuteKueche.de (DE) or BBC Good Food (EN), with TheMealDB fallback.
57-
- **Live AI Model List** — Settings dropdown fetches available models from the provider's API (Gemini, OpenAI, Anthropic, DeepSeek, Moonshot, Ollama).
58-
- **Security Improvements** — Rate limiting on AI endpoints, XSS protection, SSRF validation, masked secrets, non-root Docker container.
59-
60-
---
61-
62-
## 🧠 AI Providers
63-
64-
All configurable in the Settings page — API key, model selection, separate advisor model for cost optimization.
65-
66-
| Provider | Notes |
67-
|----------|-------|
68-
| Google Gemini | Any model (e.g. Gemini 3.1 Pro, 2.5 Flash). Enter model ID in Settings. |
69-
| OpenAI | Any model (e.g. GPT-4.1, o3, o4-mini). Enter model ID in Settings. |
70-
| Anthropic | Any model (e.g. Claude Opus 4.6, Sonnet 4.6). Enter model ID in Settings. |
71-
| DeepSeek | Any model (e.g. deepseek-chat, deepseek-reasoner). Enter model ID in Settings. |
72-
| Moonshot (Kimi) | Any model. Enter model ID in Settings. |
73-
| Ollama (local) | Any locally pulled model (llama3, mistral, llava, etc.) |
31+
- **Smart Dashboard** — Real-time overview of stock value, expiring items, and today's planned meals
32+
- **Automatic Bring! Sync** — One-way background synchronization to your Bring! list
33+
- **Bulk Management** — Move or delete multiple inventory items at once
34+
- **AI Barcode & Image Recognition** — Scan EAN/UPC barcodes or photograph any product
35+
- **Per-Package Inventory** — Each physical package tracked individually
36+
- **AI Recipe Generation** — Single recipes or full weekly meal plans with custom portions per day
37+
- **Storage Location Tracking** — Organize items by Fridge, Freezer, Pantry, etc.
38+
- **Minimum Stock Warnings** — Automatic shopping list additions for staples
39+
- **RSS Food Inspiration** — Daily recipe ideas from top food blogs
7440

7541
---
7642

@@ -79,13 +45,11 @@ All configurable in the Settings page — API key, model selection, separate adv
7945
| Layer | Technology |
8046
|-------|-----------|
8147
| Frontend | React 19, TypeScript, Tailwind CSS v4, Framer Motion |
82-
| Backend | Node.js, Express, TypeScript (tsx) |
83-
| Database | SQLite via better-sqlite3 |
84-
| Scanning | html5-qrcode, Tesseract.js |
48+
| State | Custom React Hooks + Centralized API Client |
49+
| Backend | Node.js, Express, Modular Service Architecture |
50+
| Database | SQLite via better-sqlite3 with Automated Migrations |
8551
| AI SDKs | @google/genai, openai, @anthropic-ai/sdk |
86-
| Build | Vite 6, vite-plugin-pwa |
87-
| i18n | react-i18next |
88-
| Deployment | Docker (multi-arch: amd64 + arm64) |
52+
| CI/CD | GitHub Actions (Auto-building multi-arch Docker images) |
8953

9054
---
9155

@@ -107,19 +71,11 @@ docker compose up -d
10771

10872
Open **https://localhost:3000** and configure your AI provider in Settings.
10973

110-
### Local Development
111-
112-
```bash
113-
npm install
114-
cp .env.example .env.local
115-
npm run dev
116-
```
117-
11874
---
11975

120-
## 🐳 Docker
76+
## 🐳 Docker & CI/CD
12177

122-
Pre-built multi-arch images (amd64 + arm64) are published to GitHub Container Registry on every release.
78+
FoodAI uses **GitHub Actions** to automatically build and push multi-arch Docker images (`amd64` and `arm64`) to the GitHub Container Registry. This ensures a seamless experience on both standard servers and Raspberry Pi devices.
12379

12480
```yaml
12581
services:
@@ -133,77 +89,24 @@ services:
13389
- foodai-data:/app/data
13490
env_file:
13591
- .env
136-
environment:
137-
- DB_DIR=/app/data
138-
- NODE_ENV=production
139-
140-
volumes:
141-
foodai-data:
14292
```
14393
144-
### HTTPS
145-
146-
FoodAI requires HTTPS for camera access on mobile. A self-signed certificate is auto-generated on first start. Accept the browser warning once, or mount your own certificates:
147-
148-
```yaml
149-
volumes:
150-
- ./certs/cert.pem:/app/data/server.cert:ro
151-
- ./certs/key.pem:/app/data/server.key:ro
152-
```
153-
154-
---
155-
156-
## ⚙️ Environment Variables
157-
158-
| Variable | Required | Default | Description |
159-
|----------|----------|---------|-------------|
160-
| `GEMINI_API_KEY` | No | — | Default Gemini API key (can also be set in-app) |
161-
| `DB_DIR` | No | `./` | Directory for SQLite database and SSL certificates |
162-
| `HTTP_PORT` | No | `3001` | Port for plain HTTP server (for iframe embedding) |
163-
| `NODE_ENV` | No | — | Set to `production` to serve pre-built frontend |
164-
165-
---
166-
167-
## 🌍 Contributing Translations
168-
169-
FoodAI uses [react-i18next](https://react.i18next.com/). Translation files are in `src/i18n/locales/`.
170-
171-
To add a new language:
172-
173-
1. Copy `src/i18n/locales/en.json` to `src/i18n/locales/xx.json`
174-
2. Translate all values (keep keys in English)
175-
3. Add the import in `src/i18n/i18n.ts`
176-
4. Add the language option to `src/pages/Settings.tsx`
177-
5. Submit a PR!
178-
17994
---
18095
181-
## 📁 Project Structure
96+
## 📁 Modular Project Structure (v2.0)
18297
18398
```
184-
server.ts Express backend (API, AI, database)
99+
server.ts Express application setup
100+
server/
101+
db/ Database connection & migrations
102+
services/ AI, Bring!, and Prompt management
103+
utils/ Unit conversions & category mapping
185104
src/
186-
i18n/ Internationalization
187-
locales/ de.json, en.json, es.json
188-
pages/ Dashboard, Inventory, Scanner, Recipes, Calendar, FreeCook, Settings, ShoppingList
189-
components/ Navigation, RecipeCard, OpenedItemsModal
190-
Dockerfile Multi-stage Docker build
191-
docker-compose.yml Production deployment
192-
.github/workflows/ CI/CD for multi-arch Docker images
105+
api/ Centralized API client
106+
hooks/ Business logic hooks (useInventory, useCalendar)
107+
components/ Modular UI components (inventory, recipes)
108+
pages/ Dashboard, Inventory, Scanner, etc.
109+
Dockerfile Multi-stage build
110+
.github/workflows/ Automated CI/CD build process
193111
```
194112

195-
---
196-
197-
## 📄 License
198-
199-
Apache-2.0 — see [LICENSE](LICENSE)
200-
201-
---
202-
203-
<div align="center">
204-
205-
**Built with ❤️ and AI by [N3LSON](https://nnelson.de/)**
206-
207-
[![PayPal](https://img.shields.io/badge/Buy_me_a_coffee-PayPal-blue?logo=paypal)](https://www.paypal.com/paypalme/germanquestions)
208-
209-
</div>

0 commit comments

Comments
 (0)