A comprehensive web-based nutrition tracking application built with Node.js, Express, and SQLite. Track your daily food intake, monitor nutritional values, and maintain a healthy lifestyle with ease.
- π Food Logging: Log food items with quantity and unit measurements
- π Daily Summaries: Get comprehensive daily nutrition summaries
- π Open Food Facts Integration: Automatic nutritional data lookup using the completely free Open Food Facts API (no API key required!)
- πΎ SQLite Database: Local database storage for reliability and performance
- π RESTful API: Clean, documented API endpoints
- π Environment Configuration: Secure environment variable management
- βοΈ Cloud Ready: Optimized for Render.com deployment
- π 100% Free: No API keys or paid services required
- Node.js (v14 or higher)
- npm or yarn
- No API key required! - Uses Open Food Facts free API
-
Clone the repository
git clone https://github.com/myProjectsRavi/nutrition-tracker-web.git cd nutrition-tracker-web -
Install dependencies
npm install
-
Start the server (No additional setup needed!)
# Development mode npm run dev # Production mode npm start
-
Test the API
curl http://localhost:3000/health
- GET
/health- Check API status and Open Food Facts connectivity
- POST
/api/food-log- Log a food item - GET
/api/food-log- Retrieve food log entries
- GET
/api/daily-summary- Get daily nutrition summary
curl -X POST http://localhost:3000/api/food-log \
-H "Content-Type: application/json" \
-d '{
"food_name": "banana",
"quantity": 120,
"unit": "g"
}'curl "http://localhost:3000/api/daily-summary"nutrition-tracker-web/
βββ server.js # Main server file with Open Food Facts integration
βββ package.json # Dependencies and scripts
βββ .env.example # Environment variables template (optional)
βββ .gitignore # Git ignore patterns
βββ README.md # Project documentation
βββ nutrition.db # SQLite database (created automatically)
- Backend: Node.js + Express.js
- Database: SQLite3
- External API: Open Food Facts (100% free, no registration required)
- Environment: dotenv (optional)
- CORS: cors middleware
- HTTP Client: axios
All environment variables are optional. The app works out of the box with sensible defaults.
| Variable | Description | Required | Default |
|---|---|---|---|
| PORT | Server port | No | 3000 |
| NODE_ENV | Environment mode | No | development |
| HOST | Server host | No | 0.0.0.0 |
| DATABASE_PATH | SQLite database path | No | ./nutrition.db |
| CORS_ORIGIN | CORS allowed origins | No | * |
- Connect your GitHub repository to Render.com
- No environment variables required! The app works with defaults
- Deploy using the following settings:
- Build Command:
npm install - Start Command:
npm start
- Build Command:
# Set production environment (optional)
export NODE_ENV=production
# Start the server
npm startYou can test the API using curl, Postman, or any HTTP client:
# Health check
curl http://localhost:3000/health
# Log food
curl -X POST http://localhost:3000/api/food-log \
-H "Content-Type: application/json" \
-d '{"food_name":"apple", "quantity":150, "unit":"g"}'
# Get today's summary
curl http://localhost:3000/api/daily-summary
# Get food log entries
curl http://localhost:3000/api/food-lognpm start- Start production servernpm run dev- Start development server with nodemonnpm test- Run tests (to be implemented)
CREATE TABLE food_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER,
food_name TEXT NOT NULL,
quantity REAL NOT NULL,
unit TEXT NOT NULL,
calories REAL,
protein REAL,
carbs REAL,
fat REAL,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
date DATE DEFAULT (DATE('now')),
FOREIGN KEY(user_id) REFERENCES users(id)
);Open Food Facts is a free, open, collaborative database of food products from around the world. It provides:
- β Completely Free: No API keys, registration, or rate limits
- β Comprehensive Data: Millions of food products worldwide
- β Real Nutrition Data: Actual nutrition facts from product labels
- β Community Driven: Crowdsourced and verified by users
- β No Dependencies: Works without any external accounts
Updated from USDA API: This application previously used the USDA FoodData Central API, which required an API key and had rate limits. We've migrated to Open Food Facts API for the following benefits:
- π No API key required
- π« No rate limits
- π Global food database (not just US foods)
- β‘ Faster setup (no registration needed)
- π Better reliability
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Open Food Facts for providing free, comprehensive nutrition data
- Express.js for the web framework
- SQLite for the database
- Render.com for hosting recommendations
If you have any questions or run into issues, please:
- Check the existing issues on GitHub
- Create a new issue with detailed information
- Join our community discussions
Built with β€οΈ by myProjectsRavi
Now with 100% free nutrition data - no API keys required!