Demo backend for a food ordering app.
- Restaurant and menu management.
- Full-text and nearby search.
- User account management.
- Shopping cart.
- Order management.
- JWT based API authorization.
- Swagger API documentation across all microservices.
Run the app with Docker Compose
or in a local Minikube Kubernetes
cluster. Both methods require installation of Docker Desktop. Linux users should also complete these post installation steps.
-
Ensure port 8080 is free.
-
Clone this repository and cd into it.
git clone https://github.com/ebinphilip/eatnow && cd eatnow
- Start the app with Docker Compose. This step will take 10-15 mins in the initial run, but should take less than a minute in subsequent runs.
docker compose up
- If some of the services fail to load in the initial run, then do Ctrl+C and repeat step 3. After all the services have started, the app can be found at:
- Install minikube & kubectl.
- Configure minikube vm to use 6GB RAM. Providing less than 4GB can cause some of the services to go into a crash loop.
minikube config set memory 6144
- Start minikube, increase max virtual memory, enable ingress and store minikube ip into a config map.
minikube start
minikube ssh 'sudo -s sysctl -w vm.max_map_count=262144'
minikube addons enable ingress
kubectl create configmap eatnow-api-host --from-literal=API_HOST=$(minikube ip) --dry-run=client -o yaml | kubectl apply -f -
- Clone this repository and cd into it.
git clone https://github.com/ebinphilip/eatnow && cd eatnow
- Mount the init-db folder from the project directory into the minikube vm. Do this in a separate shell. Leave it running.
minikube mount ./init-db:/init-db
- Start all services.
kubectl apply -f kubernetes/
- Wait for Step 6 to complete. Use the minikube dashboard for monitoring the services. Wait until all deployments become stable. That should take 10 mins.
minikube dashboard
- Get the ip of the cluster. This will be the API url.
minikube ip
-
After all the services have started, the app can found at:
- API url: http://<minikube-ip>
- Swagger UI: http://<minikube-ip>/swagger-ui/index.html or http://<minikube-ip>:32000/swagger-ui/index.html
The swagger UI, in addition to providing API documentation, also happens to be the easiest way to use this app. API definitions across different microservices can be selected from the definition drop-down on the top right.
The following error indicates that the service in question, is not ready yet. The solution is to wait and retry. If that doesn't help, restart the service.
This section describes the expected workflow when using the EatNow app, through the provided APIs.
- Create a user account, with a unique user-id.
- Login with this user-id to get a user token.
- Create an address for the user, using the token. Keep the address coordinates within the town of Kottayam. All the restaurant data populated in the DB is from Kottayam. Right clicking on any location in google maps gives you the coordinates of that point.
- The address index returned in the previous step along with user-id, is used to uniquely identify a user address.
- Search for restaurants or menu items by name.
- All searches take into account the location of the user. In addition to latitude/longitude pairs, the address-index from the previous stage can also be used to provide location details.
- Search results for restaurants contain a restaurant ID. Search results for items, contain both a restaurant ID and an item index. These will be used in subsequent stages.
- Restaurants and menus can be fetched using correspoding restaurant IDs.
- The menu contains an index for each item. The combination of restaurant ID and item-index is used to uniquely identify an item.
- Add items to cart using restaurant ID and item index.
- Updating cart items and their quantities is possible.
- Use the order-request-from-cart API to generate an order request JSON from the shopping cart.
- Post the order request created in the previous step to create an order. The response body will contain a unique order ID.
- Use the order ID to perform payment. This is just a dummy step, no payment details or actual payment is required.
- Login with a restaurant ID to get the token for that restaurant.
- This token can be used to update restaurant and menu details, in addition to order management.
- Use the restaurant token from the previous stage to view and manage orders.
- After payment is complete, the status of an order is set to NEW. This order should then be ACCEPTED by the restaurant and finally marked COMPLETED.
- An order with NEW/ACCEPTED status can be cancelled by the restaurant.