Skip to content

eahishak/calocount

Repository files navigation

CaloCount Pro

Production-ready calorie tracking application with AI chatbot assistant, built with vanilla JavaScript, demonstrating advanced front-end engineering and algorithmic problem-solving

Technical Stack

Vanilla JavaScript (ES6+), HTML5, CSS3, Python
4,500+ lines of code, 200KB bundle, zero dependencies

Key Features

AI Chatbot Assistant
Intelligent conversational interface with natural language processing, context-aware responses, and comprehensive knowledge base covering app features, nutrition advice, and technical support

Custom Data Visualization
Canvas-based charting system with 14-day trend analysis, macro distribution, weekly progress comparisons, and high-DPI rendering

Machine Learning
Linear regression forecasting with statistical analysis (mean, variance, confidence scoring) for 7-day calorie predictions

Physics Engine
Particle system with gravity simulation, velocity calculations, confetti effects, and 60fps performance

Mobile-First Design
Responsive architecture with touch gestures, pull-to-refresh, swipe navigation, bottom nav bar, and native app-like UI

Profile Management
Real-time profile picture upload with base64 encoding, live name/email updates, and instant UI synchronization

Performance
Sub-200ms FCP, <500ms TTI, 60fps animations, optimized DOM manipulation with event delegation

Architecture

Modular component system with separation of concerns:

  • State management with LocalStorage persistence
  • MediaDevices API for camera integration
  • Intersection Observer for lazy loading
  • RequestAnimationFrame for animations
  • Pattern matching AI for chatbot responses
  • WCAG 2.1 Level AA accessibility compliance

File Structure

index.html                  Application structure (802 lines)
style.css                   Core styling (26KB)
advanced.css                Analytics UI (12KB)
mobile-responsive.css       Responsive design (15KB)
chatbot.css                 AI chatbot styling (15KB)
app.js                      Application logic (27KB)
analytics.js                Data analysis (18KB)
animations.js               Physics engine (19KB)
integration.js              Module orchestration (11KB)
mobile-enhancements.js      Mobile features (14KB)
chatbot.js                  AI assistant (18KB)
demo.js                     Testing utilities (15KB)

Setup

Include CSS:

<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="advanced.css">
<link rel="stylesheet" href="mobile-responsive.css">
<link rel="stylesheet" href="chatbot.css">

Include JavaScript:

<script src="app.js"></script>
<script src="analytics.js"></script>
<script src="animations.js"></script>
<script src="integration.js"></script>
<script src="mobile-enhancements.js"></script>
<script src="chatbot.js"></script>
<script src="demo.js"></script>

Demo

// Load sample data
demo.loadData();

// Full demonstration
demo.comprehensive();

// View performance metrics
demo.stats();

// Open AI chatbot
chatbot.open();

// Send programmatic message
chatbot.send("How do I scan a meal?");

AI Chatbot Features

Knowledge Base

  • All app features and usage instructions
  • Nutrition guidance (macros, weight loss, muscle building)
  • Technical details (architecture, storage, performance)
  • Privacy and security information

Conversation Capabilities

  • Natural language understanding with regex pattern matching
  • Context-aware responses based on user intent
  • Welcome screen with suggested questions
  • Typing indicator for realistic interaction
  • Message history with timestamps
  • Quick reply buttons for common queries

User Experience

  • Floating button (bottom-right, 60px)
  • Smooth animations and transitions
  • Auto-resizing input textarea
  • Mobile-optimized full-screen mode
  • Dark mode support
  • Accessibility features (ARIA labels, keyboard navigation)

Technical Highlights

Algorithm Complexity
O(n) linear regression, O(n) chart rendering, O(n log n) date sorting, O(1) chatbot response lookup

Browser Support
Chrome 90+, Firefox 88+, Safari 14+, Edge 90+

Security
Input validation, XSS prevention, 5MB file upload limits, localStorage-only data persistence

Performance Metrics

  • First Contentful Paint: <200ms
  • Time to Interactive: <500ms
  • Animation frame rate: 60fps
  • Chart rendering: <100ms
  • Chatbot response: <1500ms

Code Quality
ES6+ syntax, modular architecture, comprehensive documentation, DRY principles, event delegation, memory-efficient state management

Features Breakdown

Core Functionality (65+ Features)

  • Real-time calorie tracking with progress bars
  • AI-powered meal scanning via camera/upload
  • Custom nutrition plans with macro targets
  • Profile picture upload (5MB limit, image validation)
  • Live profile updates without page refresh
  • LocalStorage persistence across sessions

Analytics Suite

  • AI-generated insights and recommendations
  • 14-day calorie trend line chart
  • Macro distribution donut chart
  • 8-week progress bar comparison
  • 7-day calorie predictions with confidence scores
  • Achievement system with progress tracking

Mobile Enhancements

  • Touch gesture support (swipe, pull-to-refresh)
  • Bottom navigation bar (70px with safe area)
  • Floating action button for quick camera access
  • Haptic feedback on interactions
  • iOS safe area support for notched devices
  • Landscape mode optimization

AI Chatbot

  • 20+ intelligent response patterns
  • Multi-topic knowledge (features, nutrition, technical)
  • Context-aware fallback responses
  • Welcome screen with quick suggestions
  • Simple calculator functionality
  • Conversation state management

Browser Compatibility

Desktop:
Chrome/Edge 90+, Firefox 88+, Safari 14+

Mobile:
iOS Safari 14+, Chrome Mobile 90+, Samsung Internet 14+

Features Requiring Modern Browsers:

  • MediaDevices API (camera access)
  • Canvas 2D Context (charts)
  • LocalStorage API (data persistence)
  • CSS Grid/Flexbox (layout)
  • ES6+ features (arrow functions, promises, async/await)

Scalability Considerations

Data Management

  • Efficient localStorage usage (<5MB typical)
  • Indexed meal lookup for O(1) access
  • Lazy loading for image-heavy sections
  • Debounced input handlers

Performance Optimization

  • Hardware-accelerated CSS (transform, opacity)
  • RequestAnimationFrame for smooth 60fps
  • Virtual scrolling for large meal lists
  • Image compression for profile pictures

Code Maintainability

  • Modular architecture (12 separate files)
  • Clear separation of concerns
  • Comprehensive inline documentation
  • Consistent naming conventions
  • Reusable utility functions

Project Stats: 4,500+ LOC | 200KB | 65+ Features | 0 Dependencies

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published