NutriScan is a comprehensive nutrition management platform that leverages cutting-edge AI technology to provide personalized dietary insights and recommendations. Built with modern web technologies and powered by Neon's serverless PostgreSQL database, the platform offers scalable, real-time nutrition tracking capabilities for health-conscious individuals and organizations.
- Barcode Scanning: Advanced barcode detection using ZXing library
- Product Database Integration: Real-time data from OpenFoodFacts API
- Nutritional Analysis: Comprehensive macro and micronutrient breakdown
- Conversational Interface: Natural language conversations about nutrition and health goals
- Retrieval-Augmented Generation: Personalized responses based on user history, consumption logs, and preferences
- Context-Aware Responses: AI maintains conversation context and provides relevant nutritional guidance
- Personal Health Insights: AI analyzes user data to provide tailored dietary advice and goal tracking support
- AI-Powered Health Scoring: Comprehensive health assessment of food products (1-100 scale)
- Nutritional Insights: Detailed analysis of positive aspects and health concerns for each product
- Alternative Suggestions: AI-recommended healthier alternatives with availability information
- Personalized Recommendations: Product-specific consumption advice based on user preferences and health goals
- Daily Goal Management: Customizable targets for calories, macros, and micronutrients
- Consumption Logging: Historical tracking of food intake with detailed nutritional breakdown
- Progress Monitoring: Real-time updates on daily nutritional goals and achievements
- User Profiles: Personalized settings and dietary preferences management
- Framework: Next.js 14 with App Router for optimal performance and SEO
- Language: TypeScript for type safety and enhanced developer experience
- Styling: Tailwind CSS with custom component library using Radix UI primitives
- State Management: React Context API with optimized re-rendering patterns
- PWA Features: Next-PWA integration for offline functionality and app-like experience
- Performance: Code splitting, dynamic imports, and image optimization
- Runtime: Node.js with Express.js framework for scalable API development
- Database ORM: Sequelize with advanced query optimization and relationship management
- Authentication: Firebase Admin SDK for secure token validation and user management
- Rate Limiting: Express-based throttling for API protection and performance
- Middleware Stack: Helmet for security, Morgan for logging, Compression for optimization
- Primary Database: Neon PostgreSQL - Serverless, auto-scaling, and branch-based development
- Authentication Store: Firebase Auth for user credentials and session management
- Performance Optimization: Database indexing and query optimization scripts
- Data Integrity: Sequelize migrations and model relationships for consistent data structure
- Language Model: Google Gemini Pro for natural language processing and generation
- RAG Implementation: Custom retrieval system combining user data with nutritional knowledge base
- External APIs: OpenFoodFacts integration for comprehensive product information
- Data Processing: Advanced nutrition calculation algorithms and recommendation engines
- Node.js 18+ and npm/yarn package manager
- Neon PostgreSQL database instance
- Firebase project with Authentication enabled
- Google Gemini AI API access
git clone https://github.com/aamrindersingh/NutriScan-backend.git
cd NutriScan-backendcd backend
npm install
# Configure environment variables
cp .env.example .env
# Edit .env with your configuration values
# Initialize database
npm run init-db
# Start development server
npm run devcd frontend
npm install
# Configure environment variables
cp .env.local.example .env.local
# Edit .env.local with your configuration values
# Start development server
npm run dev# Database Configuration
DATABASE_URL=postgresql://user:[email protected]/nutriscan
# Firebase Configuration
FIREBASE_SERVICE_ACCOUNT_KEY=path/to/your/firebase-service-account.json
# AI Configuration
GEMINI_API_KEY=your_google_gemini_api_key
# Server Configuration
PORT=3001
NODE_ENV=development
# Security
JWT_SECRET=your_jwt_secret_key
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:3001
# Firebase Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
# PWA Configuration
NEXT_PUBLIC_APP_NAME=NutriScan
NEXT_PUBLIC_APP_DESCRIPTION=Intelligent Nutrition Management PlatformThe application uses Sequelize ORM with the following core entities:
- Users: Authentication and basic user information
- Profiles: Extended user profiles with preferences and settings
- DailyGoals: Customizable nutritional targets and objectives
- FoodItems: Comprehensive food database with nutritional information
- ConsumptionLogs: Historical tracking of user food consumption
cd backend
npm run migrate
npm run seed # Optional: populate with sample databackend/
βββ config/ # Database and service configurations
βββ controllers/ # Business logic and request handlers
βββ middlewares/ # Authentication and validation middleware
βββ models/ # Sequelize database models
βββ routes/ # API route definitions
βββ services/ # External service integrations
βββ utils/ # Helper functions and utilities
frontend/
βββ src/app/ # Next.js app router pages
βββ src/components/ # Reusable React components
βββ src/contexts/ # React context providers
βββ src/hooks/ # Custom React hooks
βββ src/lib/ # Utility libraries and configurations
βββ src/types/ # TypeScript type definitions
# Backend
npm run dev # Start development server with hot reload
npm run build # Build for production
npm run start # Start production server
npm run migrate # Run database migrations
npm run test # Run test suite
# Frontend
npm run dev # Start development server
npm run build # Build optimized production bundle
npm run start # Start production server
npm run lint # Run ESLint code quality checks
npm run type-check # Run TypeScript type checking- Neon Database Features: Serverless PostgreSQL with automatic scaling and branching
- Connection Pooling: Optimized database connections for high-concurrency scenarios
- Query Optimization: Indexed searches and optimized JOIN operations
- Data Archiving: Automated cleanup and archival of historical consumption data
- Bundle Optimization: Code splitting and tree shaking for minimal bundle sizes
- Image Optimization: Next.js automatic image optimization and lazy loading
- Caching Strategy: Intelligent caching of API responses and static assets
- Progressive Loading: Skeleton screens and progressive enhancement
Powered by Neon Database
Serverless PostgreSQL β’ Auto-scaling β’ Developer-first
Built for the Modern Web