Skip to content

Commit

Permalink
Redesign basket functionality (#141)
Browse files Browse the repository at this point in the history
* renaming basket-api into cart-api

* refactoring files

* Updating OpenAPI spec and adding Updating LineItem functionality

* Fixing minor issues

* cart-api open api spec changes

* Delete line item functionality

* cart functionality

* cart-api: adding item level CRUD

* web-app: removing client side context prior to SSR

* moving kustomize files: basket-api > cart-api

* Cart funcntionality integrated with backend
  • Loading branch information
jurabek authored Jan 26, 2024
1 parent 6635269 commit eead8ab
Show file tree
Hide file tree
Showing 128 changed files with 2,721 additions and 1,967 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@

name: basket-api
name: cart-api

on:
push:
branches:
- develop
paths:
- 'src/backend/services/basket-api/**'
- '.github/workflows/basket-api.yml'
- 'src/backend/services/cart-api/**'
- '.github/workflows/cart-api.yml'

pull_request:
branches:
- develop
paths:
- 'src/backend/services/basket-api/**'
- '.github/workflows/basket-api.yml'
- 'src/backend/services/cart-api/**'
- '.github/workflows/cart-api.yml'


jobs:
build-release:
uses: ./.github/workflows/build-release.yml
with:
service-name: basket-api
service-name: cart-api
secrets: inherit

deploy:
Expand All @@ -30,6 +30,6 @@ jobs:
- build-release
uses: ./.github/workflows/deploy.yml
with:
service-name: basket-api
service-name: cart-api
version: ${{ needs.build-release.outputs.new-version }}

2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- if: matrix.language == 'go'
name: Build Go
run: |
bash ./src/backend/services/basket-api/build.sh
bash ./src/backend/services/cart-api/build.sh
- if: matrix.language == 'csharp'
name: Build C#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: basket-api
name: cart-api
spec:
replicas: 1
selector:
matchLabels:
app: basket-api
app: cart-api
template:
metadata:
labels:
app: basket-api
app: cart-api
spec:
containers:
- image: basket-api # must much from ./kustomization.yaml -> images[0].name
- image: cart-api # must much from ./kustomization.yaml -> images[0].name
imagePullPolicy: IfNotPresent
name: basket-api
name: cart-api
ports:
- containerPort: 5200
envFrom:
- configMapKeyRef:
name: basket-api
name: cart-api
resources:
requests:
memory: "32Mi"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
name: basket-api
name: cart-api
spec:
parentRefs:
- kind: Gateway
Expand All @@ -13,5 +13,5 @@ spec:
type: PathPrefix
value: /basket
backendRefs:
- name: basket-api
- name: cart-api
port: 80
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ resources:
configMapGenerator:
- envs:
- config.env
name: basket-api
name: cart-api

images:
- name: basket-api
newName: ghcr.io/chayxana/basket-api
- name: cart-api
newName: ghcr.io/chayxana/cart-api
newTag: 0.0.27
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: basket-api
name: cart-api
spec:
type: ClusterIP
ports:
- port: 80
name: http
targetPort: 5200
selector:
app: basket-api
app: cart-api
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ configMapGenerator:
- behavior: merge
envs:
- config.env
name: basket-api
name: cart-api
resources:
- ../base
2 changes: 1 addition & 1 deletion k8s-kustomize/services/order-api/base/config.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
basket.url=http://basket-api
basket.url=http://cart-api
datasource.url=jdbc:postgresql://order-pgsql-database:5432/orderdb
env.var=prod
4 changes: 2 additions & 2 deletions src/backend/backend.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"path": "./services/payment-api"
},
{
"name": "basket-api",
"path": "./services/basket-api"
"name": "cart-api",
"path": "./services/cart-api"
},
{
"name": "identity-api",
Expand Down
4 changes: 2 additions & 2 deletions src/backend/docker/docker-compose.elk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ services:
fluentd-address: localhost:24224
tag: order-api

basket-api:
cart-api:
links:
- fluentd
logging:
driver: "fluentd"
options:
fluentd-address: localhost:24224
tag: basket-api
tag: cart-api

catlog-api:
links:
Expand Down
2 changes: 1 addition & 1 deletion src/backend/docker/docker-compose.kafka.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
version: "3.7"
services:
basket-api:
cart-api:
depends_on:
kafka:
condition: service_healthy
Expand Down
8 changes: 4 additions & 4 deletions src/backend/docker/docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ services:
- QUARKUS_OPENTELEMETRY_TRACER_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
- QUARKUS_OPENTELEMETRY_PROPAGATORS=ottrace

basket-api:
cart-api:
environment:
- REDIS_HOST=redis:6379
- KAFKA_BROKER=kafka:29092
- CHECKOUT_TOPIC=checkout
- IDENTITY_URL=http://identity-api
- AUTH_URL=http://localhost:8080/identity
- BASE_PATH=/basket
- BASE_PATH=/shoppingcart
- OTEL_EXPORTER_OTLP_ENDPOINT=otel-collector:4317

payment-api:
Expand All @@ -32,7 +32,7 @@ services:
environment:
- PORT=30001
- HOST=0.0.0.0
- CART_URL=basket-api:8081
- CART_URL=cart-api:8081
- PAYMENT_API_URL=payment-api:8080
- KAFKA_BROKER=kafka:29092
- CHECKOUT_TOPIC=checkout
Expand Down Expand Up @@ -69,7 +69,7 @@ services:
- IDENTITY_URL_PUB=http://localhost:8080/identity

# connect:
# pgcli 'postgresql://admin:Passw0rd!@localhost:5435/identity_database'
# pgcli 'postgresql://admin:Passw0rd!@localhost:5433/orderdb'
order-db:
environment:
- POSTGRES_PASSWORD=Passw0rd!
Expand Down
4 changes: 2 additions & 2 deletions src/backend/docker/docker-compose.traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ services:
- "traefik.http.routers.catalog.rule=PathPrefix(`/catalog/`)"
- "traefik.port=8000"

basket-api:
cart-api:
labels:
- "traefik.enable=true"
- "traefik.http.routers.basket.rule=PathPrefix(`/basket/`)"
- "traefik.http.routers.basket.rule=PathPrefix(`/shoppingcart/`)"
- "traefik.port=5200"

order-api:
Expand Down
11 changes: 6 additions & 5 deletions src/backend/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ services:
- identity-db
ports:
- "5001:80"
restart: always

checkout-api:
image: restaurant/checkout-api
build: ./services/checkout-api
depends_on:
- basket-api
- cart-api
- payment-api
ports:
- 30001:30001
Expand All @@ -29,10 +30,10 @@ services:
- 8000:8000
restart: always

basket-api:
image: restaurant/basket-api
cart-api:
image: restaurant/cart-api
container_name: basket
build: ./services/basket-api
build: ./services/cart-api
depends_on:
- redis

Expand Down Expand Up @@ -96,4 +97,4 @@ services:
image: redis:alpine

volumes:
database-data:
database-data:
6 changes: 3 additions & 3 deletions src/backend/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ upstream identity-api {
server identity-api:80;
}

upstream basket-api {
server basket-api:5200;
upstream cart-api {
server cart-api:5200;
}

upstream order-api {
Expand Down Expand Up @@ -51,7 +51,7 @@ server {
}

location /basket/ {
proxy_pass http://basket-api/;

}

location /order {
Expand Down
2 changes: 1 addition & 1 deletion src/backend/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ build_order_api(){
}

build_basket_api() {
cd ./services/basket.api/
cd ./services/cart-api/
echo "#### Building Basket API"
sh build.sh
cd -
Expand Down
2 changes: 1 addition & 1 deletion src/backend/scripts/qa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ main () {
}

qa_basket_api() {
cd ./services/basket.api
cd ./services/cart-api
sh qa.sh
}

Expand Down
1 change: 0 additions & 1 deletion src/backend/services/basket-api/gen-swagger.sh

This file was deleted.

Loading

0 comments on commit eead8ab

Please sign in to comment.