Coding and Implemention
Coding and Implemention
Frontend Implementation
The frontend of the “Foody” application was developed using React.js, a
powerful JavaScript library for building interactive user interfaces. The
project structure is well-organized for scalability and component
reusability.
The src folder is the heart of the React application. It contains the following
major directories and files:
• The FOODY frontend is developed using React.js with Context API for global
state management and Axios for API integration. Below is a breakdown of
major logic implemented in the StoreContext.jsx file:
React's createContext and useState are used to manage food list, cart items, and
user token globally.
Adds item to local cart state and syncs with the backend if the user is authenticated:
Calculates the total price of items in cart by multiplying quantity and price:
On component load, fetch food data from API and update state:
6. Load Cart Items
When the app loads, fetch food list and cart data (if token exists):
8. Context Provider
All context values are bundled and passed to child components using the provider:
Styling
The backend of the FOODY application is built using Node.js with Express.js for handling
HTTP requests, and MongoDB for data storage. The structure follows the MVC pattern
to separate concerns and keep the codebase modular.
🔧 Project Structure
🔸 foodModel.js
userModel.js
The admin panel in the FOODY application is built separately using React.js.
It provides authorized admin users a dashboard to manage food items,
view orders, and maintain overall control of the platform. This panel is
separate from the main user-facing app and focuses on CRUD (Create,
Read, Update, Delete) functionalities.
• components/
o Navbar/ – Top navigation bar for admin
o Sidebar/ – Sidebar with links to pages like Add, List, Orders
• pages/
o Add/ – Form to add new food items to the menu (name, price,
image, category)
o List/ – Displays all existing food items with delete/edit
options
o Orders/ – Displays orders placed by users with order status
and timestamps
• App.jsx – Main component that manages routes and layout
• main.jsx – React app entry point
• index.css – Styling for the dashboard UI