Phincommerce is a reactive REST API that implements microservice architecture to help people buy products online. It is created for the final project in the Java phase of the Backend Development Training.
- Product Service: localhost:8081/api/v1/docs
- Order Service: localhost:8082/api/v1/docs
- Payment Service: localhost:8083/api/v1/docs
- Add a new order.
- Display list of orders.
- Update order status (created, completed, or failed).
- Update product quantity (deduct or add).
- Add a transaction detail (approved or rejected).
- Update balance amount (debit or credit).
-
Make sure you have Java, PostgreSQL, & Kafka installed on your computer.
-
Connect to the PostgreSQL server by providing a user name & password.
psql -U postgres
Then create databases for product service, order service, & payment service. You can name it as
phincommerce_product
,phincommerce_order
, &phincommerce_payment
.CREATE DATABASE phincommerce_product;
CREATE DATABASE phincommerce_order;
CREATE DATABASE phincommerce_payment;
-
Clone the repo.
git clone https://github.com/nadiannis/phincommerce.git
cd phincommerce
-
Run the zookeeper server & Kafka broker.
cd kafka
./bin/zookeeper-server-start.sh ./config/zookeeper.properties
./bin/kafka-server-start.sh ./config/server.properties
-
Connect each service to its respective database by writing the information about the database you use in the
application.properties
file.# example spring.r2dbc.url=r2dbc:postgresql://localhost:5432/phincommerce_order spring.r2dbc.username=postgres spring.r2dbc.password=pass1234 spring.r2dbc.driver-class-name=org.postgresql.Driver
-
Add Kafka config to
application.properties
in the order-service & orchestrator-service.# Kafka producer spring.kafka.producer.bootstrap-servers=localhost:9092 spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer # Kafka consumer spring.kafka.consumer.bootstrap-servers=localhost:9092 spring.kafka.consumer.group-id=phincommerce spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer spring.kafka.consumer.properties.spring.json.trusted.packages=*
-
Install the common project.
cd ./common
./mvnw clean install
-
Run the orchestrator service first. The Kafka topics needed will be created. The web server will run on port
8080
. -
Then run other services. The product service will run on port
8081
, order service will run on port8082
, & payment service will run on port8083
.