- 🌳 Overview
- 📁 Directory Structure
- 🎯 Core Components
- 🔧 Configuration Files
- 📦 Package Management
- 🐳 Container Structure
- 🔗 Dependencies
- 📊 Architecture Patterns
- 🎨 Naming Conventions
FlavorSnap is a comprehensive AI-powered food classification application built with a modern microservices architecture. The project follows a modular structure that separates concerns across frontend, backend, machine learning, and blockchain components.
- Separation of Concerns: Each component has a distinct responsibility
- Scalability: Modular design allows independent scaling
- Maintainability: Clear organization makes the codebase approachable
- Testability: Isolated components enable focused testing
- Deployment Flexibility: Containerized services for various environments
flavorsnap/
├── 📁 frontend/ # Next.js web application
│ ├── 📁 pages/ # React pages and API routes
│ │ ├── 📄 index.tsx # Landing page
│ │ ├── 📄 classify.tsx # Classification interface
│ │ └── 📁 api/ # Backend API endpoints
│ ├── 📁 components/ # Reusable React components
│ │ ├── 📁 ui/ # UI component library
│ │ ├── 📁 forms/ # Form components
│ │ └── 📁 layout/ # Layout components
│ ├── 📁 hooks/ # Custom React hooks
│ ├── 📁 lib/ # Utility libraries
│ ├── 📁 public/ # Static assets
│ │ ├── 📁 images/ # Hero images and icons
│ │ └── 📄 favicon.ico
│ ├── 📁 styles/ # Global CSS and Tailwind
│ ├── 📁 __tests__/ # Test files
│ ├── 📄 package.json # Frontend dependencies
│ ├── 📄 tsconfig.json # TypeScript configuration
│ ├── 📄 next.config.ts # Next.js configuration
│ └── 📄 tailwind.config.ts # TailwindCSS configuration
├── 📁 ml-model-api/ # Flask ML inference API
│ ├── 📄 app.py # Main Flask application
│ ├── 📄 requirements.txt # Python dependencies
│ ├── 📄 model_loader.py # Model loading utilities
│ ├── 📄 analytics.py # Analytics and metrics
│ ├── 📄 monitoring.py # Performance monitoring
│ ├── 📄 api_endpoints.py # API route definitions
│ ├── 📄 batch_processor.py # Batch processing logic
│ ├── 📄 model_registry.py # Model version management
│ ├── 📄 xai.py # Explainable AI features
│ └── 📁 logs/ # Application logs
├── 📁 contracts/ # Soroban smart contracts
│ ├── 📁 model-governance/ # Model governance contracts
│ ├── 📁 tokenized-incentive/ # Token incentive system
│ └── 📁 sensory-evaluation/ # Sensory evaluation contracts
├── 📁 flavorsnap-food-registry/ # Rust-based food registry
│ ├── 📁 src/ # Rust source code
│ ├── 📄 Cargo.toml # Rust dependencies
│ └── 📄 README.md # Component documentation
├── 📁 dataset/ # Training and validation data
│ ├── 📁 train/ # Training images by class
│ ├── 📁 test/ # Test images
│ ├── 📁 validation/ # Validation dataset
│ └── 📄 data_split.py # Dataset utilities
├── 📁 models/ # Trained model files
│ ├── 📄 model.pth # Main PyTorch model (44MB)
│ ├── 📄 model_metadata.json # Model information
│ └── 📁 checkpoints/ # Training checkpoints
├── 📁 uploads/ # User uploaded images
│ ├── 📁 classified/ # Organized by prediction
│ └── 📁 temp/ # Temporary uploads
├── 📁 docs/ # Documentation
│ ├── 📄 project_structure.md # This file
│ ├── 📄 development_workflow.md # Development guide
│ ├── 📄 file_purposes.md # File responsibilities
│ ├── 📄 installation.md # Setup instructions
│ ├── 📄 configuration.md # Configuration guide
│ └── 📄 troubleshooting.md # Common issues
├── 📁 scripts/ # Utility scripts
│ ├── 📄 install.py # Automated installation
│ ├── 📄 docker_run.sh # Docker utilities
│ ├── 📄 check_environment.py # Environment validation
│ └── 📄 analyze_structure.py # Structure analysis
├── 📁 config/ # Configuration files
│ ├── 📄 default.yaml # Default settings
│ ├── 📄 development.yaml # Development config
│ └── 📄 production.yaml # Production config
├── 📁 kubernetes/ # K8s deployment manifests
│ ├── 📄 deployment.yaml # Main deployment
│ ├── 📄 service.yaml # Service definitions
│ └── 📄 monitoring.yaml # Monitoring stack
├── 📁 monitoring/ # Monitoring configuration
│ ├── 📁 prometheus/ # Prometheus config
│ ├── 📁 grafana/ # Grafana dashboards
│ └── 📁 alerts/ # Alert rules
├── 📁 src/ # Shared source code
│ ├── 📁 config/ # Configuration utilities
│ └── 📁 core/ # Core business logic
├── 📁 backend/ # Backend services
│ ├── 📁 api/ # API implementations
│ └── 📁 services/ # Business services
├── 📁 pages/ # Additional documentation pages
├── 📁 api-testing/ # API testing utilities
├── 📁 dashboard/ # Analytics dashboard
├── 📄 model.pth # Trained PyTorch model
├── 📄 food_classes.txt # List of food categories
├── 📄 train_model.ipynb # Model training notebook
├── 📄 train_model.py # Model training script
├── 📄 dashboard.py # Panel-based dashboard
├── 📄 Cargo.toml # Rust workspace configuration
├── 📄 config.yaml # Main configuration file
├── 📄 docker-compose.yml # Development containers
├── 📄 docker-compose.prod.yml # Production containers
├── 📄 docker-compose.test.yml # Testing containers
├── 📄 Dockerfile # Production container
├── 📄 Dockerfile.dev # Development container
├── 📄 Dockerfile.frontend.dev # Frontend dev container
├── 📄 .env.example # Environment template
├── 📄 .gitignore # Git ignore rules
├── 📄 .dockerignore # Docker ignore rules
└── 📄 README.md # Project documentation
Purpose: User interface and client-side application logic
Key Files:
pages/index.tsx- Main landing pagepages/classify.tsx- Food classification interfacecomponents/- Reusable UI componentshooks/- Custom React hooks for state managementlib/- Utility functions and helpers
Technologies: Next.js, React, TypeScript, TailwindCSS
Purpose: AI model inference and data processing
Key Files:
app.py- Main Flask application entry pointmodel_loader.py- Model loading and cachingapi_endpoints.py- RESTful API definitionsanalytics.py- Classification analyticsxai.py- Explainable AI features
Technologies: Flask, PyTorch, Pillow, OpenCV
Purpose: Blockchain-based model governance and incentives
Key Directories:
model-governance/- Model version control and validationtokenized-incentive/- Reward system for contributionssensory-evaluation/- Community feedback mechanisms
Technologies: Soroban, Rust, Stellar
Purpose: Decentralized food classification registry
Key Files:
src/- Rust implementationCargo.toml- Dependencies and configuration
Technologies: Rust, Soroban SDK
| File | Purpose | Format |
|---|---|---|
config.yaml |
Main application configuration | YAML |
.env.example |
Environment variables template | Environment |
Cargo.toml |
Rust workspace configuration | TOML |
docker-compose.yml |
Development containers | YAML |
| Component | Config File | Purpose |
|---|---|---|
| Frontend | next.config.ts |
Next.js settings |
| Frontend | tsconfig.json |
TypeScript configuration |
| Frontend | tailwind.config.ts |
TailwindCSS setup |
| ML API | requirements.txt |
Python dependencies |
| ML API | model_registry.py |
Model version management |
Package Manager: npm/yarn/pnpm Key Dependencies:
next- React frameworkreact- UI librarytypescript- Type safetytailwindcss- Stylingaxios- HTTP clientlucide-react- Icons
Package Manager: pip Key Dependencies:
flask- Web frameworktorch- ML frameworkpillow- Image processingopencv-python- Computer visionnumpy- Numerical computing
Package Manager: Cargo Key Dependencies:
soroban-sdk- Blockchain developmentserde- Serializationtokio- Async runtime
- Base Stage: System dependencies
- Build Stage: Application compilation
- Runtime Stage: Minimal runtime environment
| Container | Purpose | Configuration |
|---|---|---|
frontend |
Next.js application | Dockerfile.frontend.dev |
backend |
Flask ML API | Dockerfile.dev |
production |
Optimized deployment | Dockerfile |
- Development:
docker-compose.yml - Production:
docker-compose.prod.yml - Testing:
docker-compose.test.yml
- Database: PostgreSQL (configurable)
- Cache: Redis (optional)
- Storage: Local filesystem (configurable to cloud)
- Monitoring: Prometheus + Grafana
- ML Model: PyTorch ResNet18
- Image Processing: Pillow, OpenCV
- Web Framework: Flask, Next.js
- Blockchain: Stellar/Soroban
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Frontend │ │ Backend │ │ ML API │
│ Next.js │◄──►│ Services │◄──►│ Flask │
└─────────────┘ └─────────────┘ └─────────────┘
│ │ │
└───────────────────┼───────────────────┘
│
┌─────────────┐
│ Blockchain │
│ Contracts │
└─────────────┘
- User Upload → Frontend → ML API
- Classification → ML Model → Database
- Results → Frontend ← Backend Services
- Governance → Blockchain Contracts
- API Gateway: Request routing and validation
- Authentication: JWT tokens (configurable)
- Authorization: Role-based access control
- Data Encryption: TLS for all communications
- Components: PascalCase (
FoodClassifier.tsx) - Utilities: camelCase (
imageProcessor.js) - Configuration: kebab-case (
development.yaml) - Documentation: kebab-case (
project-structure.md)
- Features: kebab-case (
food-classification/) - Components: kebab-case (
ui-components/) - Services: kebab-case (
ml-services/)
- Variables: camelCase (
foodImage) - Functions: camelCase (
classifyFood) - Classes: PascalCase (
FoodClassifier) - Constants: UPPER_SNAKE_CASE (
MAX_FILE_SIZE)
- REST: kebab-case (
/food-classification) - GraphQL: camelCase (
classifyFood) - WebSocket: camelCase (
onClassificationResult)
Last updated: March 2026 Version: 1.0.0