Skip to content

Commit

Permalink
Merge pull request #119 from ayeshLK/dev
Browse files Browse the repository at this point in the history
Add online food-ordering system sample
  • Loading branch information
ayeshLK authored Feb 26, 2024
2 parents 2e60670 + f3817ee commit b2dd5fc
Show file tree
Hide file tree
Showing 32 changed files with 1,889 additions and 28 deletions.
59 changes: 31 additions & 28 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Ignore Gradle project-specific cache directory
.gradle
# Compiled class file
*.class

# Build Files
target
build
# Log file
*.log

# Lock file
*.lck

# IDEA Files
.idea/
*.iml
*.ipr
*.iws
# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
!gradle/wrapper/gradle-wrapper.jar
Expand All @@ -21,25 +23,26 @@ build
*.tar.gz
*.rar

# MacOS
*.DS_Store
# System files
.DS_Store

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# IDE-related files
.idea
.code
.project
.settings
.vscode

# Build Files
.gradle
target
build
bin

# Ballerina
velocity.log*
*Ballerina.lock

# VSCode
.vscode
.project
.settings/
ballerina/.project
ballerina/.settings/
build-config/checkstyle/.classpath
build-config/checkstyle/.project
build-config/checkstyle/.settings/
native/.classpath
native/.project
native/.settings/
test-utils/.classpath
test-utils/.project
test-utils/.settings/
examples/**/Dependencies.toml
80 changes: 80 additions & 0 deletions examples/ez-food/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# EzFood: Online Food Ordering Platform

[![Star on Github](https://img.shields.io/badge/-Star%20on%20Github-blue?style=social&logo=github)](https://github.com/ballerina-platform/module-ballerinax-java.jms)

_Authors_: @ayeshLK \
_Reviewers_: @NipunaRanasinghe \
_Created_: 2024/01/26 \
_Updated_: 2024/01/26

## Overview

EzFood is an online food ordering platform designed to simplify the process of placing and processing food orders. The system consists of three main components: Order Service, Order Processor, and Menu Service.

1. **Order Service:**
- Provides REST API capabilities for customers to place orders, view order status, and complete payments.
- Manages the overall order lifecycle, from order placement to completion or cancellation.

2. **Order Processor:**
- Backend service responsible for processing order information.
- Calculates the total price for orders and estimates the time of completion.
- Communicates with the Order Service using JMS queues to exchange order details and confirmations.

3. **Menu Service:**
- Manages the menu of the food items available for ordering.
- Provides API endpoints for retrieving the entire menu and details for specific items.

This application is written using the [Ballerina](https://ballerina.io/) programming language. Ballerina `java.jms` package is used for JMS integration.

### System Architecture

The EzFood system follows a microservices architecture, with distinct components handling specific functionalities. The communication between services is facilitated by Java Message Service (JMS), ensuring a reliable and asynchronous messaging pattern.

| ![system-components.png](./ezfood.png) |
|:--------------------------------------------------------------------------------:|
| *Image 1: System components* |

## Deploying the system

### Starting Menu Service

Go into the `menu-svc` directory and execute the following command:

```sh
bal run
```

### Starting Order Service

Go into the `order-svc` directory and execute the following command:

```sh
bal run
```

### Starting the Order Processor

Go into the `order-processor` directory and execute the following command:

```sh
bal run
```

### Deploying the system in docker

1. Execute `build-docker-images.sh` script.

```sh
sh build-docker-images.sh
```

2. Run the following command.

```sh
docker compose up
```

## Test the system

- Install VSCode [REST client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) plugin.
- Open the `online-food-delivery-request.http` from the VSCode and execute the requests.
18 changes: 18 additions & 0 deletions examples/ez-food/build-docker-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Copyright 2024 WSO2 LLC. (http://wso2.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
( cd menu-svc ; bal clean ; bal build --cloud=docker)
( cd order-processor ; bal clean ; bal build --cloud=docker)
( cd order-svc ; bal clean ; bal build --cloud=docker)
41 changes: 41 additions & 0 deletions examples/ez-food/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '2'

services:
order-svc:
image: 'ballerina/ordersvc:1.0.0'
ports:
- '9091:9091'
depends_on:
order-processor:
condition: service_started
activemq:
condition: service_healthy
network_mode: "host"

order-processor:
image: 'ballerina/orderprocessor:1.0.0'
depends_on:
menu-svc:
condition: service_started
activemq:
condition: service_healthy
network_mode: "host"

menu-svc:
image: 'ballerina/menusvc:1.0.0'
ports:
- '9090:9090'
network_mode: "host"

activemq:
image: 'apache/activemq-classic:6.0.0'
container_name: activemq-test-server
ports:
- '61616:61616'
- '8161:8161'
network_mode: "host"
healthcheck:
test: ["CMD-SHELL", "curl -u admin:admin http://localhost:8161/admin"]
interval: 10s
timeout: 5s
retries: 3
Binary file added examples/ez-food/ezfood.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions examples/ez-food/menu-svc/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
org = "example"
name = "menusvc"
version = "0.1.0"

[build-options]
observabilityIncluded = true
11 changes: 11 additions & 0 deletions examples/ez-food/menu-svc/Cloud.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[container.image]
repository="ballerina"
name="menusvc"
tag="1.0.0"

[[container.copy.files]]
sourceFile="./Config.toml"
target="/home/ballerina/Config.toml"

[[cloud.config.files]]
file="./Config.toml"
Loading

0 comments on commit b2dd5fc

Please sign in to comment.