How satyaveerjaligama/food-parcel-frontend works
Main System Components
• Frontend Application: This is the user interface part built using Next.js. It includes:
• Pages (under the “app” directory) that provide separate flows for account creation, login, home pages, order management, cart pages, payment success, etc.
• Distinct user flows for Customers, Restaurants, and Delivery Agents, each with their own subdirectories and components.
• UI Components: The “components” folder contains core/reusable UI elements (Header, Layout, Button, Modal, etc.) as well as page-specific components (for cart, home, restaurant-view, etc.).
• Styling & Assets: The “assets” directory (including images) and “styles” folder for CSS and theme configurations (including Tailwind & Material UI customizations).
• State & Data Management: The “store” directory (Redux store and slice files) along with the “thunks” directory (for side-effect management and async API calls) that orchestrate data-fetching and interactions with a backend.
• Utilities & Configurations: Utility functions, constants, routing definitions, validations (in the “utilities” folder) support configuration and business logic across the app.
• Environment & Configuration Files: Configuration files like next.config.mjs, .env files, and additional build tools configuration which play a role in deployment and environment management.
Interactions and Relationships
• Frontend UI (Pages) ↔ Components: Pages import and compose reusable components to build the interactive screens.
• UI ↔ State Management (Redux Store/Slices): UI components send actions (or dispatch thunks) which update the Redux store. This state propagation is crucial for flows like login, order management, and user account updates.
• Thunks and API Integrations: Thunks (under thunks/*) encapsulate the asynchronous actions such as login, registration, fetching orders, adding menu items, etc. They serve as the conduit between UI actions and external API calls to the backend service.
• External Backend Service: Although not part of this repository, the frontend communicates with the separate backend repo (linked in the README) for data persistence, user account management, order processing, and more.
Architectural Patterns and Design Principles
• Next.js File-based Routing: The “app” directory shows an architecture based on pages corresponding to routes in the application.
• Component-Based Design: Reusable components encapsulate common functionality or UI elements.
• Unidirectional Data Flow: With Redux Toolkit managing the state, actions, and thunks, data flows in one direction, ensuring predictable state changes.
• Separation of Concerns: There’s a clear delineation between UI (pages and components), business logic (thunks and validations), and state management (store and slices).
Additional Details
• User journeys: registration, login, order placement (for customer), menu management (for restaurant), and order status updates (for delivery agent).