Skip to content

Commit e0f964d

Browse files
committed
Merge remote-tracking branch 'origin/product_review_fix_328' into product_review_fix_328
2 parents 6e41ae0 + bc3d2d9 commit e0f964d

File tree

122 files changed

+821
-2958
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+821
-2958
lines changed

.github/workflows/dev-branch-pr-build-and-test-pipeline.yaml

+11-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ jobs:
3737
runs-on: ubuntu-latest
3838

3939
steps:
40-
- uses: actions/checkout@v3
40+
- name: Checkout the source code from the Github repository
41+
uses: actions/checkout@v4
4142

4243
- name: Set up JDK 21
4344
uses: actions/setup-java@v3
@@ -56,3 +57,12 @@ jobs:
5657
5758
- name: Run unit tests
5859
run: mvn test -Pdev --file pom.xml
60+
61+
- name: Generate test coverage report
62+
run: mvn jacoco:report --file pom.xml
63+
64+
- name: Upload coverage reports to Codecov
65+
uses: codecov/[email protected]
66+
with:
67+
token: ${{ secrets.CODECOV_TOKEN }}
68+
files: ./target/site/jacoco/jacoco.xml

.github/workflows/dev-branch-pr-deployment-pipeline.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
docker stop ${{ vars.DOCKER_CONTAINER_NAME }} || true
4646
docker rm ${{ vars.DOCKER_CONTAINER_NAME }} || true
4747
docker rmi ${{ vars.DOCKER_HUB_ACCOUNT_NAME }}/${{ vars.DOCKER_IMAGE_NAME }}:latest-version || true
48-
docker pull ${{ vars.DOCKER_HUB_ACCOUNT_NAME }}/${{ vars.DOCKER_IMAGE_NAME }}:latest-version
48+
docker pull ${{ vars.DOCKER_HUB_ACCOUNT_NAME }}/${{ vars.DOCKER_IMAGE_NAME }}:latest-version
4949
docker run -d \
5050
--name ${{ vars.DOCKER_CONTAINER_NAME }} \
5151
--network=${{ vars.DOCKER_NETWORK }} \
@@ -69,7 +69,7 @@ jobs:
6969
-e REDIS_PORT=${{ vars.REDIS_PORT }} \
7070
-e SPRING_AI_OPENAI_API_KEY=${{ secrets.SPRING_AI_OPENAI_API_KEY }} \
7171
-e STRIPE_SECRET_KEY=${{ secrets.STRIPE_SECRET_KEY }} \
72+
-e STRIPE_WEBHOOK_SECRET=${{ secrets.STRIPE_WEBHOOK_SECRET }} \
7273
-v ${{ vars.APP_DATA_PATH_ON_THE_REMOTE_SERVER }}:/usr/app/logs \
7374
-v ${{ vars.APP_DATA_PATH_ON_THE_REMOTE_SERVER }}/products:/usr/app/products \
7475
zufarexplainedit/iced-latte-backend:latest-version
75-

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/danilqa/node-file-router/blob/main/LICENSE)
88
[![GitHub issues](https://img.shields.io/github/issues/Sunagatov/Iced-Latte)](https://github.com/Sunagatov/Iced-Latte/issues)
99
[![Total Lines of Code](https://tokei.rs/b1/github/Sunagatov/Iced-Latte?category=lines)](https://github.com/Sunagatov/Iced-Latte)
10+
[![codecov](https://codecov.io/github/Sunagatov/Iced-Latte/branch/development/graph/badge.svg?token=515f0ca9-2c4d-4458-ba0b-baf1de67635e)](https://app.codecov.io/github/Sunagatov/Iced-Latte)
1011

1112
[![Docker Pulls](https://img.shields.io/docker/pulls/zufarexplainedit/iced-latte-backend.svg)](https://hub.docker.com/r/zufarexplainedit/iced-latte-backend/)
1213
[![GitHub contributors](https://img.shields.io/github/contributors/Sunagatov/Iced-Latte)](https://github.com/Sunagatov/Iced-Latte/graphs/contributors)
1314
[![GitHub stars](https://img.shields.io/github/stars/Sunagatov/Iced-Latte)](https://github.com/Sunagatov/Iced-Latte/stargazers)
15+
[![Fork on GitHub](https://img.shields.io/github/forks/Sunagatov/Iced-Latte.svg?style=social)](https://github.com/Sunagatov/Iced-Latte/network/members)
1416
</div>
1517

1618
## Table of Contents
@@ -101,10 +103,12 @@ Contributions are welcome.
101103

102104
The main point of interaction is the [Issues page](https://github.com/Sunagatov/Iced-Latte/issues).
103105

104-
Here's our contribution guidelines — [CONTRIBUTING.md](CONTRIBUTING.md).
105-
106106
> The official development language at the moment is English, because 100% of our users speak it. We don't want to introduce unnecessary barriers for them. But we are used to writing commits and comments in Russian and we won't mind communicating with you in it.
107107
108+
The bussiness docs are here [Docs](https://drive.google.com/drive/folders/1vvfXy6n4cz01JjNyTgoYG0g6EIRvyHDw?usp=share_link).
109+
110+
Swagger REST APIs contracts described [here](https://iced-latte.uk/backend/api/docs/swagger-ui/index.html).
111+
108112
### 😎 I want to write some code
109113

110114
- Open our [Issues page](https://github.com/Sunagatov/Iced-Latte/issues) to see the most important tickets at top.

START.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ Key variables which are used in the startup of the app. They are pre-configured
2626
- `AWS_PRODUCT_BUCKET` AWS product's bucket name
2727
- `AWS_USER_BUCKET` AWS product's bucket name
2828
- `AWS_DEFAULT_PRODUCT_IMAGES_PATH` Package with product's files
29-
- `STRIPE_SECRET_KEY` Stripe secret key for payment integration
29+
- `STRIPE_SECRET_KEY` Stripe secret key for payment session creation
30+
- `STRIPE_WEBHOOK_SECRET` Stripe secret key for webhook
3031

3132
Refer to [docker-compose.local.yml](./docker-compose.local.yml)
3233

@@ -114,6 +115,15 @@ docker compose -f docker-compose.local.yml up -d --build
114115

115116
AWS is available only in production, therefore there are no real pictures of products, only stubs.
116117

118+
#### Stripe Integration Testing (local)
119+
120+
1. Install [Stripe CLI](https://docs.stripe.com/stripe-cli)
121+
2. Redirect webhook events
122+
```bash
123+
stripe listen --forward-to localhost:80/backend/api/v1/payment/stripe/webhook
124+
```
125+
3. Use [test cards](https://docs.stripe.com/testing): `4242424242424242`
126+
117127
## Database Navigator
118128

119129
> For Ultimate Edition consider using [Database Tools and SQL plugin](https://www.jetbrains.com/help/idea/relational-databases.html)

docker-compose.local.yml

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ services:
4848
GOOGLE_AUTH_CLIENT_SECRET: vbfgngfdndgndgndgndgndgndgndg
4949
GOOGLE_AUTH_REDIRECT_URI: vbfgngfdndgndgndgndgndgndgndg
5050
STRIPE_SECRET_KEY: sk_test_51PJxciHA4AopuQMMeXaJNETc7RUAITeMTKJei07L8iEHrRiWLQalKsr756dnOzmKPUXufkUVNUSaiPyktJG9dGY500x0cM817f
51+
STRIPE_WEBHOOK_SECRET: whsec_81c734081f94172b76e5dede103b67b3fcfc69220fa0747a12d67244c9ddb57d
5152
build:
5253
context: .
5354
dockerfile: Dockerfile.local

docs/ERD.png

-336 KB
Loading

docs/ERD.puml

-18
Original file line numberDiff line numberDiff line change
@@ -113,22 +113,6 @@ entity "shopping_cart_item" {
113113
version : INT
114114
}
115115

116-
enum "RESERVATION_STATUS" {
117-
CREATED
118-
CONFIRMED
119-
CANCELLED
120-
}
121-
122-
entity "reservation" {
123-
*id : SERIAL PK
124-
--
125-
*reservation_id : UUID
126-
*product_id : UUID
127-
*reserved_quantity : INT
128-
*created_at : TIMESTAMP
129-
*status : RESERVATION_STATUS
130-
}
131-
132116
entity "favorite_list" {
133117
*id : UUID PK
134118
--
@@ -186,8 +170,6 @@ entity "user_details" {
186170
"product" ||..o{ "product_reviews_likes" : product_id->id
187171
"user_details" ||..o{ "product_reviews_likes" : user_id->id
188172

189-
RESERVATION_STATUS ||..o{ "reservation"
190-
191173
"user_details" ||..o{ "favorite_list" : user_id->id
192174

193175
"favorite_list" ||..o{ "favorite_item" : favorite_id->id
66.1 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@startuml
2+
'https://plantuml.com/sequence-diagram
3+
4+
autonumber
5+
6+
title Checkout Sequence, Logged-In User
7+
8+
actor "User" as user
9+
participant "Frontend" as fe
10+
participant "Backend" as be
11+
participant "Stripe" as stripe
12+
database "PostgreSQL" as db
13+
14+
user -> fe: Clicks "Go to checkout"
15+
fe -> be: GET /api/v1/payment
16+
be -> stripe: Create session and POST /v1/checkout/sessions
17+
be <-- stripe: Return client_secret
18+
be --> fe: Return client_secret
19+
fe -> stripe: Embed Stripe's payment page using client_secret
20+
fe <-- stripe: Redirect /orders?sessionId={CHECKOUT_SESSION_ID}
21+
fe -> be: GET /stripe/status?sessionId={CHECKOUT_SESSION_ID}
22+
be -> stripe: GET /v1/checkout/sessions/CHECKOUT_SESSION_ID
23+
be <-- stripe: Session status (OPEN / COMPLETE)
24+
fe <-- be: Response with session status and email
25+
26+
be <-- stripe: POST /v1/stripe/webhook
27+
alt <font color=green>"checkout.session.completed"</font>
28+
be -> db: Create Order
29+
be -> db: Delete Cart
30+
user <-- be: Send email (successful order)
31+
else <font color=red>"checkout.session.expired"</font>
32+
be -> db: Update status and description in Payment
33+
end
34+
@enduml

docs/plantuml/payment/checkout-sequence.txt

-27
This file was deleted.
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@startuml
2+
3+
title Order States
4+
5+
[*] --> CREATED : BE receives Stripe Webhook\n"checkout.session.completed"
6+
7+
CREATED: New Order
8+
9+
@enduml

docs/plantuml/payment/order-state.txt

-15
This file was deleted.

src/main/java/com/zufar/icedlatte/IcedLatteApplication.java

-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package com.zufar.icedlatte;
22

3-
import com.zufar.icedlatte.payment.config.StripeConfiguration;
43
import org.springframework.boot.SpringApplication;
54
import org.springframework.boot.autoconfigure.SpringBootApplication;
6-
import org.springframework.boot.context.properties.EnableConfigurationProperties;
75
import org.springframework.cache.annotation.EnableCaching;
86
import org.springframework.scheduling.annotation.EnableScheduling;
97

108
@SpringBootApplication
11-
@EnableConfigurationProperties(StripeConfiguration.class)
129
@EnableScheduling
1310
@EnableCaching
1411
public class IcedLatteApplication {

src/main/java/com/zufar/icedlatte/cart/api/AddItemsToShoppingCartHelper.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ private List<ShoppingCartItem> createItems(Set<NewShoppingCartItemDto> itemsToAd
5858
Map<UUID, Integer> productsWithQuantity = itemsToAdd.stream()
5959
.collect(Collectors.toMap(NewShoppingCartItemDto::getProductId, NewShoppingCartItemDto::getProductQuantity));
6060

61-
Set<UUID> existedProductIds = shoppingCart.getItems().stream()
61+
Set<UUID> existingProductIds = shoppingCart.getItems().stream()
6262
.map(ShoppingCartItem::getProductInfo)
6363
.map(ProductInfo::getProductId)
6464
.collect(Collectors.toSet());
6565

6666
Set<UUID> newProductIds = productsWithQuantity.keySet().stream()
67-
.filter(productId -> !existedProductIds.contains(productId))
67+
.filter(productId -> !existingProductIds.contains(productId))
6868
.collect(Collectors.toSet());
6969

7070
return productInfoRepository.findAllById(newProductIds).stream()

src/main/java/com/zufar/icedlatte/cart/api/CartApi.java

-57
This file was deleted.

src/main/java/com/zufar/icedlatte/cart/api/ShoppingCartManager.java

-51
This file was deleted.

0 commit comments

Comments
 (0)