How ash98ketchum/smartmeal_ai_ works
Project Type and Purpose
• SmartMeal AI is a full-stack web application that connects restaurants (surplus food providers) with NGOs (food recipients).
• Frontend: React + Vite + TypeScript, Tailwind CSS, Framer Motion.
• Backend: Node.js + Express.js monolith with REST API, Prisma ORM (SQLite), and an AI component (Python training script + model.pkl).
File Structure
• Top level: frontend/ and backend/ directories.
• frontend/: Vite project, src/ with pages (public, authentication, restaurant, NGO), layouts, components, assets, configuration files (Tailwind, tsconfig, vite.config).
• backend/: Node/Express entrypoint (server.cjs), data/ folder (JSON files + model.pkl), Python script (train_model.py), Prisma setup (schema.prisma, migrations, dev SQLite DB), standard package.json.
• No microservices—single backend monolith with clear separation of API, data persistence, and ML training.
README for Additional Insights
• RESTful endpoints for servings, events, archive, history.
• JWT-based authentication planned (stubbed).
• AI prediction endpoint triggered via “Recalibration” button.
• Hosting notes: front and back run in same origin or proxied.
• Client-Side Browser (React App)
• Public Pages
• Authentication UI
• Restaurant & NGO Dashboards
• API Server (Node.js + Express)
• Routing Layer (REST controllers)
• Business Logic Layer (services: servings, events, requests, feedback)
• ML Service (invokes train_model.py, loads model.pkl)
• Auth Middleware (JWT stub)
• Data Layer
• Prisma ORM Client
• SQLite Database (dev.db) + JSON data files (seed/dev)
• External/Hosting
• (Optional) Deployment Platforms: Vercel/Netlify for front, Heroku/Docker for back
b. Relationships & Interactions
• Browser → HTTP (Axios) → REST API endpoints
• API Server → Prisma → SQLite (CRUD)
• “Recalibration” HTTP request → ML Service → Python script → updates model.pkl / predictions JSON → served back to client
• Data flows: restaurant uploads → API → DB → client dashboards; NGO requests → API → DB → notifications (future)
c. Architectural Patterns & Design Principles
• Monolithic backend with layered architecture (Router → Service → Data Access)
• Frontend adheres to component-based UI with layout shells, route guards (PrivateRoute), and atomic UI components (Buttons, Cards).
• Separation of concerns: UI, API, persistence, ML.
• RESTful design, future JWT auth.
d. Key Technologies & Frameworks
• Frontend: React, Vite, TypeScript, React Router v6, Tailwind CSS, Framer Motion, Axios
• Backend: Node.js, Express.js, Prisma ORM, SQLite, Python (scikit-learn or similar) for ML model
• Dev tooling: ESLint, PostCSS, tsconfig, Prisma Studio