How iamamanrajput/neomart works
Main Components
• Frontend Application
• Built with React, Vite, and Tailwind CSS.
• Consists of pages (e.g., Home, Login, Signup, Product, Checkout), components (UI, custom components), state management via Redux, and routing (React Router).
• Includes admin-specific layouts and dashboards.
• Backend Application
• Built using Node.js and Express.js.
• Organized into a structured MVC-like pattern:
◦ Config: Configuration files for database and Cloudinary.
◦ Controllers: Business logic for authentication, orders, payments, reviews, products, pincode checking, etc.
◦ Models: Schemas for MongoDB (user, product, order, etc.).
◦ Routes: API endpoints that connect to controllers.
◦ Middlewares: JWT verification for secured routes.
◦ Utils: Helper functions (e.g., constants, image uploading).
• Database
• MongoDB is used as the primary data store for persisting users, products, orders, reviews, etc.
• External Services
• Cloudinary for managing images.
• Payment gateway integration (as indicated in the payment controller and routes).
• Environment Configuration
• Environment variables for both frontend and backend guide the configuration (e.g., API URLs, JWT secrets, Cloudinary credentials).
Relationships & Data Flow
• The frontend communicates with the backend via RESTful API calls (using endpoints defined in the routes).
• The backend, acting as the API server, processes requests through middlewares (for token verification) and controllers, then interacts with the MongoDB database.
• Certain operations (like image uploads) rely on external services (Cloudinary) or payment gateways.
• For administration tasks, separate panels (admin-specific pages in the frontend) call different backend APIs.
Architectural Patterns and Design Principles
• The backend uses a modular structure (controllers, routes, models, middlewares) that aligns with an MVC (Model-View-Controller)-inspired pattern.
• In the frontend, a component-based architecture is evident along with state management using Redux and Context for theming.
• Separation of concerns is maintained: the backend focuses on data processing and API logic while the frontend focuses on UI and user interactions.
• Security is incorporated via JWT authentication.
• Frontend:
• Pages/routes and where admin vs. customer views are handled.
• Backend:
• Subdivide into:
▪ “Config” (database and cloud configurations)
▪ “Controllers” (for auth, product, order, payment, review, pincode, settings)
▪ “Models” (MongoDB schemas for users, orders, products, reviews, etc.)
▪ “Routes” (mapping API endpoints to controllers)
▪ “Middlewares” (JWT verification)
▪ “Utils” (constants, image uploader helper)
• Database:
• MongoDB as a central datastore.
• External Services:
• Cloudinary for image management.
• Payment Gateways if applicable.
• Environment Variables:
• You may include a small section for configuration dependencies that illustrate how the system gets its configuration at runtime.