Overview
SmartEat AI is built with a modern, production-ready technology stack that prioritizes developer experience, performance, and scalability. This page provides an in-depth look at each technology choice and its role in the system.Frontend Technologies
Core Framework
Next.js 16
React Framework for Production
- App Router architecture for file-based routing
- Server-side rendering (SSR) and static generation (SSG)
- Built-in API routes and middleware
- Automatic code splitting and optimization
- Hot module replacement for fast development
React 19
UI Library
- Component-based architecture
- Virtual DOM for efficient updates
- Hooks for state and side effects
- Context API for global state management
- Concurrent rendering features
Language & Type Safety
- TypeScript
- Zod
TypeScript 5SmartEat AI is fully written in TypeScript for enhanced developer experience and code reliability:Benefits:
- Compile-time error detection
- IntelliSense and autocomplete
- Self-documenting code through types
- Easier refactoring and maintenance
tsconfig.json with strict mode enabledStyling & UI Components
Tailwind CSS 4
Utility-First CSS Framework
- Rapid UI development with utility classes
- Responsive design with mobile-first approach
- Custom design system configuration
- PostCSS integration
- Production CSS optimization (PurgeCSS)
Radix UI
Unstyled UI Primitives
- Accessible components following WAI-ARIA
- Dialog, Slot, and other primitives
- Composable and customizable
- Keyboard navigation support
- Modal dialogs
- Dropdown menus
- Command palettes
UI Component Library
Custom Component System built on top of Radix UI and Tailwind:- Cards: Recipe cards, plan cards, macronutrient cards, progress cards
- Forms: Input fields, select dropdowns, multi-step forms
- Layout: Navbar, sidebar, footer, sections
- Chat: Message bubbles, typing indicators, proposal cards
- Carousels: Image galleries using Embla Carousel
/frontend/components/ui/ and follow consistent design patterns.
Additional Frontend Libraries
| Library | Purpose | Version |
|---|---|---|
| React Hook Form | Form state management and validation | ^7.71.1 |
| Lucide React | Icon library with 1000+ consistent icons | ^0.563.0 |
| React Icons | Additional icon sets (FaIcons, etc.) | ^5.5.0 |
| React Markdown | Render markdown in chat messages | ^10.1.0 |
| clsx / tailwind-merge | Conditional class name utilities | Latest |
| Embla Carousel | Touch-friendly carousels | ^8.6.0 |
Backend Technologies
Core Framework
FastAPI
Modern Python Web FrameworkFastAPI powers the entire backend API with high performance and modern Python features:Key Features Used:
- Async Support: Built on Starlette for async request handling
- Automatic Docs: Swagger UI and ReDoc generated from code
- Type Hints: Leverages Python type annotations for validation
- Dependency Injection: Clean separation of concerns
- WebSocket Support: Real-time communication capabilities
- Path operation decorators (
@app.get,@app.post) - Automatic request validation with Pydantic
- Dependency injection for auth, database sessions
- Background tasks for async operations
Web Server
Uvicorn - Lightning-fast ASGI server:- Production-ready ASGI implementation
- WebSocket support
- Auto-reload in development
- Graceful shutdown handling
Database Technologies
- PostgreSQL
- SQLAlchemy
- Alembic
PostgreSQL 15Primary relational database for all structured data:Schema Overview:Features Used:
- JSONB for flexible metadata storage
- Foreign key constraints for data integrity
- Indexes on frequently queried columns
- Transaction support for complex operations
Authentication & Security
JWT (PyJWT)
JSON Web TokensStateless authentication using signed tokens:Tokens include:
- User ID
- Expiration timestamp
- Token type (access/refresh)
Bcrypt
Password HashingSecure password storage with salted hashing:
Data Validation
Pydantic - Data validation using Python type annotations:- Automatic request validation
- Type coercion and conversion
- Custom validators
- JSON schema generation for OpenAPI
AI & Machine Learning Stack
Large Language Models
Ollama
Local LLM RuntimeOllama provides on-premises LLM inference without external API calls:Models Used:Integration:Documentation →
- Llama 3: 8B parameter model for general chat
- Llama 3.1: Improved version with larger context window
- Nomic-embed-text: Embedding model for semantic search
AI Orchestration
- LangChain
- LangGraph
- ChromaDB
LangChainFramework for building LLM-powered applications:Components Used:
- Prompts: Template-based prompt engineering
- Chains: Sequential LLM calls with data flow
- Output Parsers: Structured output from LLMs
- Memory: Conversation history management
- Tools: Custom tools for database queries
Machine Learning
scikit-learn
Machine Learning LibraryPowers the recipe recommendation engine:Model Details:
- Algorithm: K-Nearest Neighbors (KNN)
- Features: Calories, protein, carbs, fat, diet type, meal type
- Training data: 91,056 recipes
- Metric: Euclidean distance
Data Science Tools
pandas & NumPyData manipulation and numerical computing:Used in the data pipeline (notebooks/) for:
- Exploratory data analysis (EDA)
- Feature engineering
- Model training and evaluation
DevOps & Infrastructure
Containerization
Docker & Docker Compose
Container OrchestrationComplete application stack runs in Docker containers:Benefits:
- Consistent development and production environments
- Easy onboarding for new developers
- Isolated service dependencies
- Simple deployment workflow
Database Administration
Adminer - Web-based database management:- Accessible at
http://localhost:8080 - Full SQL query interface
- Table browsing and editing
- Import/export functionality
Environment Configuration
python-dotenv - Environment variable management:Development Tools
Code Quality
| Tool | Purpose | Configuration |
|---|---|---|
| ESLint | JavaScript/TypeScript linting | eslint.config.mjs |
| TypeScript Compiler | Type checking | tsconfig.json (strict mode) |
| Python Type Hints | Static type checking | Throughout backend code |
API Documentation
Automatic API Docs generated by FastAPI:- Swagger UI: Interactive API testing at
/docs - ReDoc: Clean API reference at
/redoc - OpenAPI Schema: JSON schema at
/openapi.json
Production Deployment
Hosting Platforms
The application is designed for deployment on various platforms:Vercel
Frontend HostingNext.js frontend deployed on Vercel:
- Automatic deployments from Git
- Edge network CDN
- Serverless functions
- Preview deployments
Container Platforms
Backend HostingFastAPI backend deployable to:
- Railway
- Render
- AWS ECS
- Google Cloud Run
- Self-hosted VPS
Database Hosting
PostgreSQL can be hosted on:- Supabase (managed PostgreSQL with REST API)
- Neon (serverless PostgreSQL)
- Railway (container-based PostgreSQL)
- AWS RDS (managed database service)
Technology Selection Rationale
Why Next.js?
- SSR/SSG: Improved SEO and initial load performance
- API Routes: Backend-for-frontend pattern
- File-based Routing: Intuitive project structure
- Built-in Optimization: Image, font, and script optimization
- Large Ecosystem: Rich plugin and component ecosystem
Why FastAPI?
- Performance: Comparable to Node.js and Go
- Modern Python: Async/await, type hints, decorators
- Auto Documentation: Swagger UI without extra work
- Type Safety: Pydantic integration catches errors early
- WebSocket Support: Real-time chat capabilities
Why PostgreSQL?
- ACID Compliance: Data integrity guarantees
- Rich Data Types: JSONB for flexible schemas
- Full-Text Search: Built-in search capabilities
- Proven Reliability: Battle-tested in production
- Strong Ecosystem: ORMs, tools, and extensions
Why Ollama?
- Privacy: No data sent to external APIs
- Cost: No per-token charges
- Low Latency: Local inference eliminates network delays
- Customizable: Full control over models and parameters
- GPU Support: Efficient use of available hardware
Architecture Overview
Learn how these technologies work together
Getting Started
Set up your development environment
