31748 Programming on the Internet - Autumn 2023 Assignment 1
This Online Grocery Store App stands for quick and reliable online grocery shopping for customers. Simple and highly-user-centered UI design boosts UX during the shopping.
Before you run the project locally, you must meet the prerequisites.
- Install Docker Desktop
- Install Git CLI
- All the secrets (-> Database and SMTP server secrets)
- Prepare .env in Laravel (If you're authorized person, I personally provided you with .env file via restricted-access link. You just download and place the .env file under online-grocerystore-webapp> backend> src directory.)
- In .env, you're required to replace SMTP screats to activate sending email functionality as well as Database secrets to access MySQL server.
- For more information, have a look at How to Use the Gmail SMTP Server to Send Emails for Free
Once you got all requirements, clone the project
git clone https://github.com/saku-1101/Online-GroceryStore-WebApp.git
Go to the project directory
cd Online-GroceryStore-WebApp
Boot up Docker Desktop
Check if port 80, 9000, 3306, and 8000 are not used
sudo lsof -i:<port number>
if it's used, kill it.
sudo kill <PID>
Start up containers (Note: Please check again if you got .env file as it described in Prerequisites)
docker-compose up --build
Install all the required Laravel Libraries
First, checkout to the backend container
docker compose exec backend sh
Then, install the libraries with composer
composer install
Please hold tight until your composer finishes installing all the required Laravel libraries. Once all the libraries are installed successfully, you'll see the outputs, like demonstrated below.
If you can observe the output from docker as shown below,
access to http://localhost:8000 😍
Insert
Screen.Recording.2023-04-26.at.14.53.20.mov
- Search Box
- Online Order Form with email address checker
- Order Confirmation Email
- Category Hierarchy
- Customers can edit the number of each item in the shopping cart
- Shopping cart can be easily moved around using the mouse
🌼Client: React, TypeScript, Vite, Axios, Redux, React Router, TailwindCSS, DaisyUI
🦄Server: Laravel8
🐬Database: MySQL
🐳Infrastructure: Docker, Docker Compose, Nginx
Others: Prettier, ESLint, Postman, Figma
GET /api/product/category
Parameter | Type | Description |
---|---|---|
null |
null |
GET /api/product/category/{category}
Parameter | Type | Description |
---|---|---|
category |
string |
Required. Id of category to fetch |
GET /api/product/category/{category}/sub_category/{sub_category}
Parameter | Type | Description |
---|---|---|
category |
string |
Required. Id of category to fetch |
sub_category |
string |
Required. Id of second category to fetch |
GET /api/product/search
Parameter | Type | Description |
---|---|---|
query |
string |
Required. Keyword to search |
POST /api/order/add
Parameter | Type | Description |
---|---|---|
request |
Request |
Required. POST request must contain order_id, product_id, quantity as parameters |
DELETE /api/order/delete/all
Parameter | Type | Description |
---|---|---|
order_id |
int |
Required. Order ID that you want to delete |
DELETE /api/order/delete/{order_id}/{product_id}
Parameter | Type | Description |
---|---|---|
order_id |
int |
Required. Order ID that you want to delete |
product_id |
int |
Required. Product ID that you want to delete |
POST /api/checkout
Parameter | Type | Description |
---|---|---|
request |
Request |
Required. POST request must contain email, name, orderId as parameters |
- How to develop a full-stack application
- Component Oriented, Atomic Design - They are to be obtained to boost frontend development productivity. It also serves consistency and simplicity of UI/UX.
- How to use Redux - It took a rather long time to grasp the entire lifecycle of Redux.
- Tailwind is just an amazing one.
- The first DB scheme design is very crucial - Well design first with ER Diagram.
- Laravel was not for this application - Too heavy but fewer things to do with it. As I wanted to use React and completely separate frontend and backend, selecting Laravel (and maybe PHP even) was one of the biggest failures.
- Big capture in Laravel
- CORS issues robbed the biggest time from me. - It basically happens when an Origin wants to access the other without an appropriate header. Adding a proper header on app.php and NGINX solved all.
- CSRF issue - Without proper authentication, this problem will explode. Excluding API route from CSRF guard in VerifyCsrfToken.php activated API in public.
- How to design APIs
- If the project is too big, it's difficult to deploy. - Tried to deploy on Azure, as the project size exceeds the free range, couldn't deploy it. Regarding any other platforms, I already used up free range.