Skip to content

Conversation

vlussenburg
Copy link
Collaborator

@vlussenburg vlussenburg commented Jun 25, 2025

✨ PR Description

Purpose: Add order history functionality to the e-commerce microservice architecture with enhanced frontend UI and Swagger API documentation.

Main changes:

  • Implemented getOrderHistory() endpoint in OrderController.java with H2 database persistence
  • Added getOrderHistory() JavaScript function for client-side order history retrieval
  • Added Swagger documentation with swagger-jsdoc and swagger-ui-express packages
  • Improved frontend UI with responsive design and error handling
  • Added DateTime field to ChargeRequest in BillingController for transaction timestamps

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

Copy link

gitstream-cm bot commented Jun 25, 2025

This PR affects one or more sensitive files and requires review from the security team.

Copy link

gitstream-cm bot commented Jun 25, 2025

🥷 Code experts: amitmohleji, b-sims

amitmohleji, b-sims have most 👩‍💻 activity in the files.
b-sims, amitmohleji have most 🧠 knowledge in the files.

See details

frontend/package.json

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 8 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/app.js

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 33 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/index.html

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 20 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/server.js

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 37 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

services/auth-python/app/auth.py

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:

services/billing-csharp/Controllers/BillingController.cs

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:

services/orders-java/pom.xml

Activity based on git-commit:

amitmohleji b-sims
JUN 54 additions & 0 deletions
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

services/orders-java/src/main/java/com/example/orders/controller/OrderController.java

Activity based on git-commit:

amitmohleji b-sims
JUN 75 additions & 0 deletions
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

services/orders-java/src/test/java/com/example/orders/OrdersApplicationTests.java

Activity based on git-commit:

amitmohleji b-sims
JUN 86 additions & 0 deletions
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

To learn more about /:\ gitStream - Visit our Docs

@gitstream-cm gitstream-cm bot requested review from amitmohleji and b-sims June 25, 2025 03:35
Copy link

@gitstream-cm gitstream-cm bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ PR Review

The PR introduces database persistence, order history functionality, and improved UI. The changes are generally well-structured but contain several significant issues that need attention.

3 issues detected:

🐞 Bug - Concurrent file access without synchronization can corrupt billing data

Details: The file I/O operations for storing billing data are not thread-safe. When multiple concurrent requests access the same user file, it can lead to data corruption or loss of billing records.
File: services/billing-csharp/Controllers/BillingController.cs (56-72)

🔒 Security - Stack traces containing sensitive information are exposed through console output

Details: Database exceptions are printed to console via printStackTrace(), which can expose sensitive information like database connection details, internal system structure, and potentially user data in production environments.
File: services/orders-java/src/main/java/com/example/orders/controller/OrderController.java (75-75)

🧹 Maintainability - Controller handles both HTTP requests and direct database operations

Details: The controller class is handling database operations directly, violating separation of concerns. This makes the code harder to test, maintain, and scale as business logic is tightly coupled with the web layer.
File: services/orders-java/src/main/java/com/example/orders/controller/OrderController.java (65-73)

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

Comment on lines +56 to +72
private async Task QueueForBillingSystemAsync(string username, object payload)
{
Directory.CreateDirectory(StorageDirectory);
var filePath = Path.Combine(StorageDirectory, $"{username}.json");
List<object> payloads = new();

if (System.IO.File.Exists(filePath))
{
try
{
payloads = JsonSerializer.Deserialize<List<object>>(await System.IO.File.ReadAllTextAsync(filePath)) ?? new();
}
catch { }
}

payloads.Add(payload);
await System.IO.File.WriteAllTextAsync(filePath, JsonSerializer.Serialize(payloads, new JsonSerializerOptions { WriteIndented = true }));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐞 Bug - Race Condition: Implement proper locking mechanism using SemaphoreSlim or similar synchronization primitive around the file read/write operations in QueueForBillingSystemAsync method.

Suggested change
private async Task QueueForBillingSystemAsync(string username, object payload)
{
Directory.CreateDirectory(StorageDirectory);
var filePath = Path.Combine(StorageDirectory, $"{username}.json");
List<object> payloads = new();
if (System.IO.File.Exists(filePath))
{
try
{
payloads = JsonSerializer.Deserialize<List<object>>(await System.IO.File.ReadAllTextAsync(filePath)) ?? new();
}
catch { }
}
payloads.Add(payload);
await System.IO.File.WriteAllTextAsync(filePath, JsonSerializer.Serialize(payloads, new JsonSerializerOptions { WriteIndented = true }));
private static readonly SemaphoreSlim _fileSemaphore = new SemaphoreSlim(1, 1);
private async Task QueueForBillingSystemAsync(string username, object payload)
{
Directory.CreateDirectory(StorageDirectory);
var filePath = Path.Combine(StorageDirectory, $"{username}.json");
List<object> payloads = new();
await _fileSemaphore.WaitAsync();
try
{
if (System.IO.File.Exists(filePath))
{
try
{
payloads = JsonSerializer.Deserialize<List<object>>(await System.IO.File.ReadAllTextAsync(filePath)) ?? new();
}
catch { }
}
payloads.Add(payload);
await System.IO.File.WriteAllTextAsync(filePath, JsonSerializer.Serialize(payloads, new JsonSerializerOptions { WriteIndented = true }));
}
finally
{
_fileSemaphore.Release();
}

pstmt.setString(5, timestamp);
pstmt.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security - Information Disclosure: Replace printStackTrace() calls with proper logging that sanitizes sensitive information and use generic error messages for client responses.

Suggested change
e.printStackTrace();
logger.error("Failed to store order", e);

Comment on lines +65 to +73
try (java.sql.Connection conn = dataSource.getConnection();
java.sql.PreparedStatement pstmt = conn.prepareStatement(
"INSERT INTO orders (orderId, username, productId, quantity, timestamp) VALUES (?, ?, ?, ?, ?)")) {
pstmt.setString(1, orderId);
pstmt.setString(2, username);
pstmt.setString(3, request.productId);
pstmt.setInt(4, request.quantity);
pstmt.setString(5, timestamp);
pstmt.executeUpdate();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Maintainability - Mixed Responsibilities: Extract database operations into a separate service or repository class, and inject it into the controller. This will improve testability and maintainability.

Suggested change
try (java.sql.Connection conn = dataSource.getConnection();
java.sql.PreparedStatement pstmt = conn.prepareStatement(
"INSERT INTO orders (orderId, username, productId, quantity, timestamp) VALUES (?, ?, ?, ?, ?)")) {
pstmt.setString(1, orderId);
pstmt.setString(2, username);
pstmt.setString(3, request.productId);
pstmt.setInt(4, request.quantity);
pstmt.setString(5, timestamp);
pstmt.executeUpdate();
Order order = new Order(orderId, username, request.productId, request.quantity, timestamp);
try {
orderService.saveOrder(order);

Copy link

gitstream-cm bot commented Jun 25, 2025

This PR is missing a Jira ticket reference in the title or description.
Please add a Jira ticket reference to the title or description of this PR.

Copy link

gitstream-cm bot commented Jun 25, 2025

Hello vlussenburg 👋 Thanks for making your first PR, and welcome to our project!
Our mentor team has automatically been assigned to review this PR and guide you through the process.
Please reach out to that team if you have questions about the next steps.

Copy link

gitstream-cm bot commented Jun 25, 2025

🥷 Code experts: amitmohleji, b-sims

amitmohleji, b-sims have most 👩‍💻 activity in the files.
b-sims, amitmohleji have most 🧠 knowledge in the files.

See details

frontend/package.json

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 8 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/app.js

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 33 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/index.html

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 20 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/server.js

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 37 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

services/auth-python/app/auth.py

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:

services/billing-csharp/Controllers/BillingController.cs

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:

services/orders-java/pom.xml

Activity based on git-commit:

amitmohleji b-sims
JUN 54 additions & 0 deletions
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

services/orders-java/src/main/java/com/example/orders/controller/OrderController.java

Activity based on git-commit:

amitmohleji b-sims
JUN 75 additions & 0 deletions
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

services/orders-java/src/test/java/com/example/orders/OrdersApplicationTests.java

Activity based on git-commit:

amitmohleji b-sims
JUN 86 additions & 0 deletions
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

To learn more about /:\ gitStream - Visit our Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

None yet

5 participants