Food that matches your mood.
An intelligent food discovery and collaborative dining web application built with Next.js 16, React 19, Prisma, PostgreSQL, Upstash Redis, Better Auth, and Google Gemini AI.
Have you ever spent 30 minutes scrolling through delivery apps unable to decide what to eat, or argued with friends about what to order on movie night?
Crave Buddy solves decision fatigue around food through two core experiences:
- Mood Boards: An AI-powered craving interpreter that translates natural language prompts ("something spicy for a rainy night", "healthy post-workout meal", "late night comfort food") into personalized restaurant and dish recommendations.
- Mood Rooms: A real-time collaborative decision room where groups of friends join with an invite code, submit their individual cravings, vote on nominated restaurants, assemble a shared basket of dishes, and finalize a group order in real time.
- Express cravings in natural language.
- Filter by vegetarian preferences.
- Pluggable recommender: the built-in Gemini provider or the standalone
crave-buddy-recommendationservice, selected withRECOMMENDER_PROVIDER. - Every recommendation is validated against the catalogue (real restaurants, real dishes, veg filter) before it is saved.
- Rate limited per user / IP.
- Save mood boards to user profiles and share via unique links.
- Room Creation & Joining: Unique 8-character invite codes (
nanoid) with member capacity controls. - Real-Time Group Chat: Fast WebSocket-powered session chat with active user indicators.
- Multi-Phase Decision Engine:
- Lobby: Waiting room for friends to gather.
- Craving Collection: Everyone submits their individual food desires.
- Restaurant Voting: AI synthesizes group cravings into tailored nominees; friends vote in a live poll.
- Item Voting: Collaborative menu browser where friends vote on dishes and adjust quantities in a shared tray.
- Order Summary: Finalized order receipt with 1-click Add to Personal Cart transfer.
- Ephemeral, cookie-backed shopping cart powered by Upstash Redis (one hash per cart, atomic per-item updates).
- Supports items from multiple restaurants concurrently with individual vendor sub-totals.
- Optimistic UI updates that reconcile with the server quantity and roll back on failure.
- Powered by Better Auth with PostgreSQL adapter.
- Supports Email / Password and Google OAuth with automatic account linking.
- Anonymous-to-user state transition (claim guest-generated mood boards upon signing in).
┌─────────────────────────────┐
│ Client (Browser) │
│ Next.js 16 (React 19) │
│ Tailwind CSS v4 + Zustand │
└──────────────┬──────────────┘
│
┌────────────────────────┴────────────────────────┐
│ HTTP (Port 3000) │ WS (Port 3001)
▼ ▼
┌───────────────────────────────┐ ┌───────────────────────────────┐
│ Next.js App Server │ │ Socket.IO Microservice │
│ • App Router (Next.js 16) │ │ • Socket.IO v4 (node http) │
│ • Better Auth Engine │ │ • Real-time Chat Sync │
│ • Recommender (Gemini / svc) │ │ • Room Phase Orchestration │
└───────┬───────────────┬───────┘ └───────────────┬───────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌───────────────────────────────────────────────────────────────┐
│ Upstash Redis │ │ Supabase PostgreSQL │
│ • Multi-Cart │ │ • Prisma Client 7 (@prisma/adapter-pg) │
│ • Rate limits │ │ • Catalogue (restaurants, menu_items), Users, Mood Boards, │
│ • 7-Day TTL │ │ Rooms, Members, Votes, and Results │
└─────────────────┘ └───────────────────────────────────────────────────────────────┘
crave-buddy/
├── src/
│ ├── app/ # Next.js App Router
│ │ ├── api/ # API Route Handlers (Auth, Rooms, Cart, Mood Board)
│ │ ├── mood-board/ # Mood board creation & display views
│ │ ├── mood-room/ # Mood room create, join, lobby & session views
│ │ ├── restaurant/[id]/ # Restaurant detail & menu views
│ │ ├── cart/ # Multi-vendor shopping cart view
│ │ ├── signin/ & signup/ # Auth pages
│ │ └── page.tsx # Homepage restaurant discovery
│ ├── components/ # React UI Components
│ │ ├── MoodRoom/ # Lobby, member lists, and host controls
│ │ ├── MoodRoomSession/ # ChatBox, phase manager, voting views
│ │ ├── UserMoodBoard/ # Mood board cards, restaurant picks
│ │ ├── CartPage/ # Cart cards and line items
│ │ ├── RestaurantPage/ # Menu list, search, and dish cards
│ │ └── ui/ # Shared UI components (QuantityButton, icons, modals)
│ ├── hooks/ # Shared client hooks (useCartItem)
│ ├── lib/ # Core utilities (Auth, Prisma, Redis, catalogue, cart)
│ │ ├── recommender/ # Recommender interface, Gemini + HTTP service providers, validation
│ │ └── db/ # Modular database query operations
│ ├── socket/ # Standalone Socket.IO server & event contracts
│ ├── stores/ # Zustand state stores (cartStore, locationStore)
│ └── types/ # TypeScript domain types
├── data/ # Catalogue seed sources (restaurants, menus, data/catalogue/*)
├── scripts/seedCatalogue.ts # Idempotent catalogue seeder (npm run seed)
├── prisma/ # Prisma schema & database migration history
└── package.json
| Domain | Technology |
|---|---|
| Frontend Framework | Next.js 16 (App Router, Turbopack, React Compiler) |
| UI Library & Styling | React 19, Tailwind CSS v4, Lucide React |
| State Management | Zustand v5 |
| Database & ORM | PostgreSQL (via Supabase), Prisma v7 |
| In-Memory Cache | Upstash Redis (REST client) |
| Real-Time WebSockets | Socket.IO v4 |
| Authentication | Better Auth v1.6 (Google OAuth + Email/Password) |
| Recommendations | Pluggable: Vercel AI SDK + Google Gemini 2.5 Flash, or the crave-buddy-recommendation FastAPI service |
| Testing | Vitest |
- Node.js:
v20.xor higher - npm or pnpm
- PostgreSQL Database (e.g. Supabase)
- Upstash Redis Account
- Google Generative AI API Key (Gemini), unless you run the recommendation service
-
Configure Environment Variables:
Copy the template and fill in your values:cp .env.example .env
See
.env.examplefor every variable. SetRECOMMENDER_PROVIDER=serviceandRECOMMENDER_URLto use the recommendation service instead of Gemini. -
Install Dependencies & Generate Prisma Client:
npm install npx prisma generate
-
Apply Database Migrations:
npx prisma migrate deploy
Use
migrate deployagainst Supabase.migrate devmay try to reset the database. -
Seed the Catalogue:
npm run seed
Loads restaurants and menus from
data/into therestaurantsandmenu_itemstables. Safe to re-run.
The application runs with two concurrent processes: the Next.js Web App and the Socket Server.
Terminal 1 — Next.js Application:
npm run dev
# Running on http://localhost:3000Terminal 2 — Real-Time Socket Server:
npm run socket
# Running on http://localhost:3001Open http://localhost:3000 in your browser.
Requires Docker with the Compose plugin. Postgres (Supabase) and Redis (Upstash) stay hosted, so .env is all the containers need.
npm run docker:up # builds the image, starts the web app (:3000) and socket server (:3001)
npm run docker:down # stops both- Source is bind-mounted, so code changes hot-reload in both containers.
- Logs from both servers stream in the same terminal; use
npm run docker:up -- -dto run them in the background anddocker compose logs -fto follow logs. - After changing
package.json, just runnpm run docker:upagain: it rebuilds the image and refreshes the containers'node_modules. - Stop any
npm run dev/npm run socketrunning on your machine first, since they use the same ports. - To reach a service on your machine (e.g. the recommendation service), use
http://host.docker.internal:8000instead oflocalhostin.env.
To verify production compilation and TypeScript type safety:
npm run build