An open API service indexing awesome lists of open source software.

https://github.com/cyrus-nodejs/foodpal-api

FoodPal Nodejs Express API
https://github.com/cyrus-nodejs/foodpal-api

Last synced: 3 months ago
JSON representation

FoodPal Nodejs Express API

Awesome Lists containing this project

README

          

# ๐Ÿฒ FoodPal Backend

**FoodPal** is an intelligent cooking companion that blends **AI recipe recommendations**, **community engagement**, and **personalized nutrition** โ€” tailored for the modern African kitchen ๐Ÿ‡ณ๐Ÿ‡ฌ.
This backend powers all API endpoints, authentication, gamification, and real-time cook-along sessions.

---

## ๐Ÿš€ Features

### ๐Ÿ‘ค Authentication & Users
- Email/password + Google OAuth login
- JWT-based authentication
- User profiles with dietary preferences, cooking habits & cultural background

### ๐Ÿง  AI-Powered Recipe Recommendations
- Personalized "For You" feed using OpenAI embeddings
- Smart search & filtering (diet, culture, skill level)

### ๐Ÿง‘๐Ÿพโ€๐Ÿณ Cook-Along (Live)
- WebSocket-powered **live cook-along chat + timer**
- Users can join cooking sessions and message in real time

### ๐Ÿฑ Meal Planning
- AI-generated weekly meal plans
- Smart substitutions for allergies and budget

### ๐ŸŒ Community
- Share recipes, like, comment, and discuss
- Social-style interaction among food lovers

### ๐Ÿฅ• Nutrition
- Ingredient-based nutrition breakdown
- Calorie and macro tracking

### ๐Ÿ… Gamification (New!)
- Cooking streaks tracking
- Achievement badges (`"Budget Chef"`, `"Zero-Waste Pro"`, etc.)
- Weekly cooking challenges (e.g., *โ€œ5 Meals Under โ‚ฆ2000โ€*)

---

## ๐Ÿงฉ Tech Stack

| Category | Tech |
|-----------|------|
| **Runtime** | Node.js (TypeScript) |
| **Framework** | Express.js |
| **Database** | MongoDB + Mongoose |
| **Auth** | JWT + Google OAuth2 |
| **AI Integration** | FastAPI | Transformers
| **Real-Time** | Socket.io |
| **Cache/Scaling (optional)** | Redis |
| **Docs** | Swagger (OpenAPI 3.0) |

---

## ๐Ÿ—‚๏ธ Folder Structure

```
backend/
โ”œโ”€โ”€ controllers/
โ”‚ โ”œโ”€โ”€ authController.ts
โ”‚ โ”œโ”€โ”€ userController.ts
โ”‚ โ”œโ”€โ”€ mealPlanController.ts
โ”‚ โ”œโ”€โ”€ communityController.ts
โ”‚ โ”œโ”€โ”€ cookAlongController.ts
โ”‚ โ”œโ”€โ”€ nutritionController.ts
โ”‚ โ””โ”€โ”€ gamificationController.ts
โ”‚
โ”œโ”€โ”€ models/
โ”‚ โ”œโ”€โ”€ user.ts
โ”‚ โ”œโ”€โ”€ userPreference.ts
โ”‚ โ”œโ”€โ”€ recipe.ts
โ”‚ โ”œโ”€โ”€ communityPost.ts
โ”‚ โ”œโ”€โ”€ mealPlan.ts
โ”‚ โ””โ”€โ”€ gamification/
โ”‚ โ”œโ”€โ”€ streak.ts
โ”‚ โ”œโ”€โ”€ badge.ts
โ”‚ โ””โ”€โ”€ challenge.ts
โ”‚
โ”œโ”€โ”€ routes/
โ”‚ โ”œโ”€โ”€ authRoutes.ts
โ”‚ โ”œโ”€โ”€ userRoutes.ts
โ”‚ โ”œโ”€โ”€ mealPlanRoutes.ts
โ”‚ โ”œโ”€โ”€ communityRoutes.ts
โ”‚ โ”œโ”€โ”€ cookAlongRoutes.ts
โ”‚ โ”œโ”€โ”€ nutritionRoutes.ts
โ”‚ โ””โ”€โ”€ gamificationRoutes.ts
โ”‚
โ”œโ”€โ”€ middleware/
โ”‚ โ””โ”€โ”€ authMiddleware.ts
โ”‚
โ”œโ”€โ”€ utils/
โ”‚ โ”œโ”€โ”€ sendEmail.ts
โ”‚ โ””โ”€โ”€ embedding.ts
โ”‚
โ”œโ”€โ”€ config/
โ”‚ โ””โ”€โ”€ db.ts
โ”‚
โ”œโ”€โ”€ swagger.json
โ”œโ”€โ”€ app.ts
โ””โ”€โ”€ server.ts

```
---

## โš™๏ธ Environment Variables

Create a `.env` file in your project root:

```bash
PORT=5000
MONGO_URI=mongodb+srv://:@cluster.mongodb.net/yourdb
JWT_SECRET=
JWT_EXPIRES=7d
OPENAI_API_KEY=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
REDIS_URL=
FRONTEND_URL=http://localhost:3000

```

# 1๏ธโƒฃ Clone the repo
git clone https://github.com//FoodPal-backend.git
cd FoodPal-backend

# 2๏ธโƒฃ Install dependencies
npm install

# 3๏ธโƒฃ Run development server
npm run dev

# 4๏ธโƒฃ For production
npm run build
npm start

๐Ÿงช API Documentation

Swagger UI is available at:

It includes:

/api/auth โ†’ Login, Register, Google Auth

/api/users โ†’ Profile management

/api/mealplans โ†’ AI meal planner

/api/community โ†’ Posts, likes, comments

/api/cookalong โ†’ Live cooking chat

/api/nutrition โ†’ Nutrition facts

/api/gamification โ†’ Streaks, badges, challenges

๐Ÿงก Credits

Built with love by the FoodPal Team โ€” inspiring creativity and connection through food.
๐Ÿ› โ€œCook smarter, not harder.โ€

๐Ÿ“œ License

This project is licensed under the MIT License.

MIT ยฉ 2025 FoodPal