How vishalk91-4/theta works
Purpose and Entry Points
Chef’s Choice is a meal-kit ordering platform with a React/TypeScript customer UI, a Node/Express API backed by MongoDB, payment integrations, Google OAuth, and a separate Python intent-classification chatbot/ML subsystem. Main runtime entry points are client/src/index.tsx, server/index.js, and Python training/app files train.py, app.py, and chat.py.
Frontend Application
The browser SPA is rooted at client/src/App.tsx and bootstrapped by client/src/index.tsx. It presents marketing, meal browsing, cart, authentication, account, registration, and checkout flows through page-level modules such as:
• client/src/pages/BrowseMeals/BrowseMeals.tsx
• client/src/pages/Cart.tsx
• client/src/pages/Checkout/Checkout.tsx
Reusable meal cards, item popups, header/footer, and checkout components compose these pages under client/src/components.
Client State and Customer Journey
client/src/context/UserContext.tsx is the central user/session-facing React state boundary. Registration is implemented as a multi-step workflow, spanning sign-up/login, preference selection, meal selection, and account setup:
• client/src/pages/Registration.tsx
• client/src/components/Registration/Step2/Step2.tsx
• client/src/components/Registration/ChooseMeals/ChooseMeals.tsx
The account area exposes profile, delivery, dietary, plan, and payment settings through client/src/components/Registration/AccountComponent/.
API and Domain Layer
The Express server starts at server/index.js and organizes HTTP boundaries by resource and integration routes. Core API areas are users, items/meals, categories, orders, checkout, and OAuth:
• server/routes/api/users.js
• server/routes/api/items.js
• server/routes/api/orders.js
• server/routes/api/checkout.js
• server/routes/api/oauth.js
Controllers implement resource behavior in server/controllers/api/, while service modules isolate checkout and user-oriented business/integration behavior in server/services/checkout.js and server/services/users.js.
Persistence, Identity, and Authorization
MongoDB is the system of record, configured through MONGO_URI; its principal domain models are user, menu item, category, and order:
• server/models/user.js
• server/models/item.js
• server/models/order.js
Authentication combines JWT utilities/middleware with Passport-managed OAuth. Protected request flow is route → auth middleware → controller/service → Mongoose model:
• server/configuration/passport.js
• server/utils/authMiddleware.js
• server/utils/jwtUtils.js
Google OAuth requires server-side client credentials and redirects through the OAuth route layer.
Payments and Checkout Boundary
Checkout UI collects delivery/payment data and order summary data before calling the backend:
• client/src/components/Checkout/CheckoutForm.tsx
• client/src/pages/Checkout/DeliveryAddressForm.tsx
• client/src/pages/Checkout/PaymentEntryForm.tsx
The system supports Stripe credentials and PayPal. PayPal client SDK provisioning is encapsulated by client/src/providers/PaypalProvider.tsx; server-side PayPal handling is separated in server/utils/paypalUtils.js. Payment execution/orchestration belongs in server/services/checkout.js, keeping provider secrets server-side.
ML Chatbot and Deployment
The root Python subsystem trains and serves an NLTK/PyTorch-style intent model from intents.json, producing/consuming data.pth:
• train.py
• model.py
• nltk_utils.py
• chat.py
Docker Compose coordinates client and API containers via docker-compose.yml, with independent images at client/Dockerfile and server/Dockerfile. Database seeding is an explicit development data lifecycle managed by server/config/seed.js and server/config/seedDeleter.js.
Main entry points: api/checkout.js Resource and integration routes · App.tsx SPA routes and shell · Checkout.tsx Checkout UI · services/checkout.js Checkout orchestration
Components 22
Customer SPA
React/TypeScript browser application.
- Browser bootstrap
client/src/index.tsx - SPA routes and shell
client/src/App.tsx - User session state
client/src/context/UserContext.tsx - Meal browsing
client/src/pages/BrowseMeals/BrowseMeals.tsx - Cart
client/src/pages/Cart.tsx - Registration workflow · Sign-up, preferences, meal selection, and account setup.
client/src/pages/Registration.tsx - Checkout UI · Collects delivery, payment, and order data.
client/src/pages/Checkout/Checkout.tsx - PayPal client SDK
client/src/providers/PaypalProvider.tsx
API and Domain
Express, identity, payments, and persistence.
- Express server
server/index.js - Resource and integration routes · Users, meals, orders, checkout, and OAuth boundaries.
server/routes/api/checkout.js - JWT and OAuth auth · Protects requests and supports Passport-managed Google OAuth.
server/utils/authMiddleware.js - API controllers
- User services
server/services/users.js - Checkout orchestration · Executes payment and order workflow without exposing provider secrets.
server/services/checkout.js - PayPal server integration
server/utils/paypalUtils.js - Mongoose domain models · User, item, category, and order models.
server/models/user.js - MongoDB · Configured through MONGO_URI.
Intent Chatbot
Python intent training and inference subsystem.
- Intent model training · Builds the trained intent artifact from intents data.
train.py - Intent model artifact · Training output consumed by chatbot inference.
data.pth - Chatbot inference
chat.py
Development Deployment
Container orchestration and development data lifecycle.
- Docker Compose · Coordinates client and API containers.
docker-compose.yml - Database seeding
server/config/seed.js
Connections 27
- Browser bootstrap → SPA routes and shell: mounts
- SPA routes and shell → User session state: uses
- SPA routes and shell → Meal browsing: renders
- SPA routes and shell → Cart: renders
- SPA routes and shell → Registration workflow: renders
- SPA routes and shell → Checkout UI: renders
- Checkout UI → PayPal client SDK: provisions SDK
- User session state → Resource and integration routes: auth and user requests
- Meal browsing → Resource and integration routes: meal requests
- Cart → Resource and integration routes: order requests
- Registration workflow → Resource and integration routes: registration requests
- Checkout UI → Resource and integration routes: checkout request
- Express server → Resource and integration routes: hosts
- Resource and integration routes → JWT and OAuth auth: protects routes
- JWT and OAuth auth → API controllers: authorizes
- Resource and integration routes → API controllers: dispatches
- API controllers → User services: user operations
- API controllers → Checkout orchestration: checkout operations
- User services → Mongoose domain models: reads and writes
- Checkout orchestration → Mongoose domain models: creates orders
- Checkout orchestration → PayPal server integration: executes PayPal
- Mongoose domain models → MongoDB: persists
- Database seeding → MongoDB: populates development data
- Intent model training → Intent model artifact: produces
- Intent model artifact → Chatbot inference: loaded for inference
- Docker Compose → Browser bootstrap: runs client container
- Docker Compose → Express server: runs API container