How hzjanuary/gromind works
Project type and purpose
• GroMind is a full-stack AI-powered intelligent shopping assistant.
• Frontend: A React/Vite single-page application using Tailwind for UI.
• Backend: Node.js/Express REST API with controllers, middleware, and data models.
• AI component: A recommendation engine (via aiController.js and config/gemini.js).
• Persistence: A database (configured in src/config/db.js) storing users, products, categories, orders, recipes.
File structure
• Top-level:
• backend/ – Express API, data seeder, controllers, models, routes
• frontend/ – React code, UI components, context providers, hooks, layouts, build config
• Patterns:
• Backend follows MVC (Models in models/, controllers in controllers/, routes in routes/)
• Frontend uses component hierarchy and Context API for auth, cart, theme
• Config & Scripts:
• backend/seeder.js populates sample data
• backend/src/scripts/claim_orders_by_phone.js is an operational script
• Vite/Tailwind configs in frontend
README for additional insights
• Purpose: deliver personalized product recommendations
• AI: uses machine-learning/recommendation algorithms
• Scope: demo application simulating a smart market environment
a. Main components
1. Frontend SPA
2. Backend REST API
3. AI Recommendation Engine (internal or external service)
4. Database (e.g., MongoDB or SQL)
5. Optional: Data seeder & operational scripts
b. Relationships and data flow
1. User interacts with Frontend → UI components (Pages, Dialogs)
2. Frontend sends HTTP requests to Backend API gateway (server.js)
3. Requests pass through Auth middleware, then hit specific Route → Controller
4. Controller invokes Model layer or AI Controller → may query DB or external AI service
5. DB returns data → Controller formats JSON → Frontend consumes and renders
6. Seeder/script utilities interact directly with DB for batch operations
c. Architectural patterns & design principles
• MVC on the Backend (clear separation between routing, business logic, and data access)
• Context and Hooks on the Frontend for cross-cutting concerns (Auth, Cart, Theme)
• Layered architecture: UI → API → Business Logic → Data Layer → Persistence
d. Key technologies
• Frontend: React, Vite, Tailwind CSS
• Backend: Node.js, Express, JWT auth middleware
• Database: configured in db.js (e.g., MongoDB/Mongoose or SQL)
• AI: Gemini config + aiController.js (invokes ML models or external API)
Essential elements without over-splitting
• Backend controllers by domain (Products, Categories, Orders, Recipes, AI)
• DB as a single node, even if it contains multiple collections or tables