How webpagesbypatel/ditewise works
Project Type and Purpose
• Ditewise is a full-stack, AI-powered web application built on Next.js (using the App Router).
• It provides personalized meal plans, progress tracking, and an AI chatbot, leveraging OpenAI (and potentially TensorFlow.js) for the AI/ML layer.
File Structure
• Top-level:
• next.config.ts, tsconfig.json, tailwind.config.ts → Next.js and styling configuration
• src/app → Next.js App Router pages (chat, community, dashboard, diet-plan, etc.)
• src/components → Reusable UI components and layout (Radix/UI primitives, forms, cards, charts)
• src/ai → Server-side business logic (“flows” for chatbot, diet-plan generator, nutrient analyzer, ingredient swapper)
• src/lib & src/hooks → Shared utilities, constants, actions, and custom React hooks
• README.md → Project description and tech stack (React, Node.js/Express, MongoDB, OpenAI API, TensorFlow.js)
Key Insights from README
• Frontend: React with Next.js (App Router), Tailwind CSS
• Backend: Node.js, Express (though the repo embeds server logic in Next.js)
• AI/ML: OpenAI API (and placeholder for TensorFlow.js)
• Database: MongoDB (not explicitly in code but mentioned for persistence)
Main Components
a. User Clients (Web Browser / Mobile)
b. Next.js Application
• App Router (React UI)
• API Routes or Server Actions invoking AI Flows
c. AI Business-Logic Layer (src/ai):
• ai-chatbot-assistant
• ai-diet-plan-generator
• nutrient-deficiency-analyzer
• smart-ingredient-swapper
d. Data Persistence (MongoDB)
e. External AI Service (OpenAI API, optional TensorFlow.js)
f. Utility Layer (src/lib, src/hooks)
Relationships and Interactions
• User → HTTP(s) → Next.js Frontend (renders pages, components)
• Frontend → Server Actions/API Routes → AI Business-Logic Modules
• AI Modules → HTTP(s) → OpenAI API (and/or TensorFlow.js in-browser)
• AI Module Results → Next.js → UI (meal plans, chatbot responses)
• Frontend & AI Modules → Database (MongoDB) for user profiles, progress logs, preferences
• Utility Layer (src/lib) supports both Frontend and Server logic with shared functions/constants
Architectural Patterns & Design Principles
• Separation of Concerns:
• UI Layer (React components under src/app, src/components)
• Business Logic Layer (AI flows under src/ai)
• Data Layer (MongoDB) abstracted via utility actions (src/lib/actions.ts)
• Serverless or Server-Side Rendering: Next.js App Router can run server actions close to the data layer
• Component-Driven Development: Reusable UI components, hooks, and providers