Prompt Details
Model
(claude-5-5-sonnet)
Token size
3,518
Example input
[APPLICATION_OBJECTIVE_AND_REQUIREMENTS]: Build a web app for managing online orders, customers, products, payments, and order status.
[EXISTING_CODEBASE_OR_APPLICATION]: Existing React frontend + Node.js/Express backend with PostgreSQL.
[FEATURES_USER_FLOWS_AND_BUSINESS_RULES]: Admin can manage products and orders. Customers can place orders, view order history, and track status.
[SECURITY_PERFORMANCE_AND_OPERATIONAL_REQUIREMENTS]: JWT authentication, role-based authorization, input validation, secure payment handling, responsive UI.
[DELIVERY_DEPLOYMENT_AND_TESTING_REQUIREMENTS]: Unit, API, integration, and E2E tests; Docker deployment with CI/CD.
Example output
# π PHASE 1 β APPLICATION REQUIREMENT RECONSTRUCTION
### π― Business Objective
Build a production-oriented e-commerce order management system that allows customers to purchase products while administrators manage products, orders, and order fulfillment.
### π₯ Users
- Customer
- Administrator
### π Primary Workflows
**Customer:**
1. Register/login
2. Browse products
3. Add product to cart
4. Checkout
5. Complete payment
6. View order
7. Track order status
8. View order history
**Administrator:**
1. Login
2. View dashboard
3. Create/update products
4. View orders
5. Update order status
6. Review payment/order information
### β
Functional Requirements
- User authentication
- Product browsing
- Product management
- Shopping cart
- Checkout
- Payment processing
- Order creation
- Order tracking
- Order history
- Admin order management
### βοΈ Non-Functional Requirements
- Secure authentication
- Server-side authorization
- Responsive UI
- Reliable payment handling
- API validation
- Database integrity
- Automated testing
- Production monitoring
### π Assumptions
- REST APIs are retained.
- PostgreSQL remains the primary database.
- Existing React/Node.js architecture is preserved.
- Payment provider supports server-side payment verification.
### β Unresolved Questions
- Which payment gateway is being used?
- Are refunds required?
- Is inventory reservation required during checkout?
- Are multiple currencies required?
- Are guest checkouts supported?
---
# π§© PHASE 2 β CODEBASE & ARCHITECTURE ANALYSIS
Because the sample provides only the technology stack and not actual source files, code-specific conclusions cannot be made.
### ποΈ Known Architecture
```text
React Frontend
β
REST API
β
Node.js / Express
β
PostgreSQL
β
Payment Gateway
```
### π Evidence-Based Findings
- React is responsible for the frontend.
- Express/Node.js provides backend APIs.
- PostgreSQL stores application data.
- Payment processing depends on an external service.
### β οΈ Cannot Yet Confirm
- Actual project structure
- Existing components
- Existing routes
- Authentication implementation
- Database schema
- Dependency versions
- Current technical debt
No files should be invented without inspecting the actual codebase.
---
# π¨ PHASE 3 β FRONTEND ENGINEERING
### π₯οΈ Suggested Page Structure
```text
/
βββ Product Listing
βββ Product Details
βββ Cart
βββ Checkout
βββ Order Confirmation
βββ Order History
βββ Order Details
βββ Login
βββ Register
/admin
βββ Dashboard
βββ Products
βββ Orders
βββ Order Details
```
### π§± Component Areas
- Navigation
- ProductCard
- ProductGrid
- CartSummary
- CheckoutForm
- OrderStatus
- OrderTable
- AdminDashboard
- ErrorMessage
- LoadingState
- EmptyState
### π UI States
Every important operation should support:
- Loading
- Success
- Error
- Empty
- Retry where appropriate
### βΏ Accessibility
- Keyboard navigation
- Semantic HTML
- Form labels
- Accessible error messages
- Adequate focus handling
- Screen-reader-friendly status messages
### π± Responsive Behavior
The interface should work across:
- Mobile
- Tablet
- Desktop
---
# βοΈ PHASE 4 β BACKEND ENGINEERING
### ποΈ Recommended Responsibility Separation
```text
HTTP Route
β
Controller
β
Application Service
β
Domain / Business Rules
β
Repository / Data Access
β
PostgreSQL
```
### π§ Example Responsibilities
**Controller**
- Parse request
- Call service
- Return HTTP response
**Service**
- Execute business workflow
- Validate business conditions
- Coordinate database/payment operations
**Repository**
- Execute database queries
- Handle persistence
### π³ Checkout Example
```text
Checkout Request
β
Validate Customer
β
Validate Cart
β
Validate Product Availability
β
Calculate Order
β
Create Payment Intent
β
Confirm Payment
β
Create/Finalize Order
β
Return Order Result
```
Payment confirmation must not rely solely on frontend claims.
---
# π PHASE 5 β API ARCHITECTURE
### π Authentication
```text
POST /api/auth/register
POST /api/auth/login
POST /api/auth/logout
```
### ποΈ Products
```text
GET /api/products
GET /api/products/:id
POST /api/products
PATCH /api/products/:id
DELETE /api/products/:id
```
### π Cart
```text
GET /api/cart
POST /api/cart/items
PATCH /api/cart/items/:id
DELETE /api/cart/items/:id
```
### π¦ Orders
```text
POST /api/orders
GET /api/orders
GET /api/orders/:id
PATCH /api/orders/:id/status
```
### π Authorization
Example:
```text
Customer
β Read own orders
Admin
β Read/manage orders
Customer
β Cannot modify another customer's order
```
### β οΈ Important
The backend must verify ownership.
A request such as:
```text
GET /api/orders/123
```
must not automatically reveal order `123` merely because the user knows its ID.
---
# ποΈ PHASE 6 β DATABASE & DATA ARCHITECTURE
### π Core Entities
```text
Users
Products
Orders
OrderItems
Payments
```
### π Relationships
```text
User
βββ Orders
βββ OrderItems
βββ Product
Order
βββ Payment
```
### π Important Constraints
- Unique user email
- Positive product price
- Valid order status
- Foreign-key relationships
- Order item must reference a valid product
- Payment must reference the appropriate order
### π Index Considerations
Potential indexes:
- User email
- Order user ID
- Order creation date
- Order status
- Order item order ID
Actual indexes should be confirmed against real query patterns.
### π Migration Safety
Schema changes should follow:
```text
Migration
β Test
β Backup/Recovery Strategy
β Deploy
β Validate
β Rollback Plan
```
---
# π PHASE 7 β AUTHENTICATION & AUTHORIZATION
### π Authentication
Authentication answers:
**"Who are you?"**
Example:
```text
Email + Password
β
Authentication
β
Session / Token
```
### π‘οΈ Authorization
Authorization answers:
**"What are you allowed to do?"**
Example:
| Action | Customer | Admin |
|---|---|---|
| View products | Yes | Yes |
| Buy products | Yes | Yes |
| View own orders | Yes | Yes |
| View all orders | No | Yes |
| Create products | No | Yes |
| Delete products | No | Yes |
| Change order status | No | Yes |
Authorization must be enforced server-side.
---
# π‘οΈ PHASE 8 β APPLICATION SECURITY
| Risk | Evidence | Impact | Recommended Control | Priority |
|---|---|---|---|---|
| Broken access control | Orders contain user-owned data | High | Server-side ownership checks | Critical |
| Injection | API accepts user input | High | Parameterized queries + validation | High |
| XSS | User-controlled data may reach UI | Medium/High | Output encoding + safe rendering | High |
| Credential theft | Authentication exists | High | Secure session/token handling | High |
| Sensitive logging | Payment/auth data involved | High | Redact sensitive information | High |
| CSRF | Depends on auth mechanism | Medium | Appropriate CSRF protection | Medium |
| Dependency vulnerabilities | External packages | Medium/High | Dependency scanning | High |
### π³ Payment Security
Do not store raw card information unless the architecture explicitly requires it and complies with applicable payment-security requirements.
Prefer tokenized/payment-provider-hosted mechanisms.
---
# π PHASE 9 β DEBUGGING & ROOT-CAUSE ANALYSIS
### Example Bug
**Reported Problem:**
Customer sees another customer's order.
### Expected Behavior
```text
Customer A
β Can view Customer A orders only
```
### Actual Behavior
```text
Customer A
β Can access arbitrary order ID
```
### Investigation
```text
Request
β
Authentication
β
Order Endpoint
β
Order ID lookup
β
Missing ownership check
```
### Root Cause
The API identifies the order but does not verify that the authenticated user owns it.
### Fix
Add server-side authorization:
```text
authenticatedUser.id
==
order.userId
```
unless the requester has an authorized administrative role.
### Regression Test
```text
Customer A requests Customer B's order
β HTTP 403 or appropriate not-found response
β No order data returned
```
---
# π§ͺ PHASE 10 β TESTING ARCHITECTURE
### π¬ Unit Tests
Test:
- Price calculations
- Order totals
- Validation
- Permission rules
- Order-status transitions
### π API Tests
Test:
- Authentication
- Product APIs
- Cart APIs
- Order APIs
- Unauthorized requests
- Invalid payloads
### ποΈ Integration Tests
Test:
```text
API
β Service
β Database
```
### π E2E Tests
Example:
```text
Register
β Login
β Browse Product
β Add to Cart
β Checkout
β Payment
β Order Confirmation
β Order History
```
### π Security Tests
Test:
- Unauthorized access
- Cross-user order access
- Admin-only endpoints
- Invalid tokens
- Malformed requests
- Injection attempts
- Rate limiting where applicable
### π Requirement Mapping
```text
Requirement
β
Implementation
β
Test
β
Acceptance Criteria
```
---
# β‘ PHASE 11 β PERFORMANCE & SCALABILITY
### π Potential Bottlenecks
- Product listing queries
- Large order-history queries
- Payment-provider latency
- Unoptimized database queries
- Large frontend bundles
### π Improvements
Use where justified:
- Pagination
- Database indexes
- Response caching
- Lazy loading
- Query optimization
- Connection pooling
- API request batching where useful
### β οΈ Important
No benchmark numbers should be claimed until actual measurements exist.
---
# π PHASE 12 β INTEGRATION & FAILURE ENGINEERING
### π³ Payment Integration
Possible failures:
```text
Payment Success
Payment Failed
Payment Timeout
Payment Status Unknown
```
### β οΈ Unknown Execution Status
If the payment request times out, do not automatically assume:
```text
Payment Failed
```
It could have succeeded remotely.
Use payment-provider verification/webhooks where supported.
### π Retry Strategy
Retries should be:
- bounded
- selective
- preferably exponential backoff
- safe for idempotent operations
Do not blindly retry payment/order creation.
### π Idempotency
Checkout should support an idempotency mechanism where the payment/order provider supports it, preventing duplicate orders from repeated requests.
---
# π PHASE 13 β OBSERVABILITY & RELIABILITY
### π Structured Logs
Useful events:
```text
request_received
authentication_failed
authorization_failed
order_created
payment_failed
payment_status_unknown
order_status_changed
```
### π Metrics
Track:
- API latency
- Error rate
- Checkout failures
- Payment failures
- Order creation rate
- Database latency
### π Request Correlation
```text
Request
β
Request ID
β
Frontend
β
API
β
Backend
β
Database / External API
```
This helps trace production failures.
### β€οΈ Health Checks
Example:
```text
/health
```
Should provide appropriate application health information without exposing secrets.
---
# π PHASE 14 β DEPLOYMENT & PRODUCTION ARCHITECTURE
### π Environments
```text
Development
β
Staging
β
Production
```
### π CI/CD
```text
Git Push
β
Lint
β
Unit Tests
β
Integration Tests
β
Build
β
Security Checks
β
Deploy Staging
β
Validation
β
Production
```
### ποΈ Database Deployment
Avoid deploying destructive schema changes without:
- Migration plan
- Backup/recovery strategy
- Compatibility assessment
- Rollback strategy
### β©οΈ Rollback
Application rollback:
```text
Current Version
β
Previous Stable Version
```
Database rollback requires separate consideration because data migrations may not be safely reversible.
---
# π§ PHASE 15 β IMPLEMENTATION & ENGINEERING ROADMAP
### π Quick Fixes
**TASK-001**
- Component: Authorization
- Objective: Ensure users can access only permitted orders
- Acceptance: Cross-user order access is blocked
- Test: Authorization integration tests
- Priority: Critical
**TASK-002**
- Component: API validation
- Objective: Validate incoming request payloads
- Acceptance: Invalid requests receive consistent validation errors
- Test: API validation tests
- Priority: High
### π Feature Work
**TASK-003**
- Component: Checkout
- Objective: Implement reliable checkout workflow
- Dependencies: Cart + payment integration
- Tests: Integration + E2E
- Priority: High
**TASK-004**
- Component: Admin Orders
- Objective: Allow authorized admins to manage order statuses
- Dependencies: Authorization
- Tests: API + E2E
- Priority: High
### ποΈ Architecture Improvements
**TASK-005**
- Component: Backend service layer
- Objective: Separate business logic from controllers
- Acceptance: Controllers remain thin
- Tests: Existing regression suite remains green
- Priority: Medium
### π‘οΈ Production Hardening
**TASK-006**
- Component: Observability
- Objective: Add structured logging and monitoring
- Tests: Log/metric verification
- Priority: Medium
**TASK-007**
- Component: CI/CD
- Objective: Automate testing and deployment
- Tests: Pipeline validation
- Priority: Medium
---
# π PHASE 16 β FINAL SENIOR WEB ENGINEERING REPORT
## 1. Executive Engineering Summary
The application should use the existing React + Node.js/Express + PostgreSQL architecture rather than introducing unnecessary architectural complexity.
The highest-priority engineering areas are:
- Secure authorization
- Reliable checkout/payment processing
- Database integrity
- API validation
- Automated testing
- Production observability
No full rewrite is justified from the supplied information.
---
## 2. Requirements & User Flow
### Customer
```text
Login
β
Browse
β
Cart
β
Checkout
β
Payment
β
Order
β
Tracking
```
### Admin
```text
Login
β
Dashboard
β
Products / Orders
β
Management
β
Status Updates
```
---
## 3. Architecture Blueprint
```text
βββββββββββββββββββββββ
β React Frontend β
ββββββββββββ¬βββββββββββ
β
βββββββββββββββββββββββ
β REST API β
ββββββββββββ¬βββββββββββ
β
βββββββββββββββββββββββ
β Node.js / Express β
β Controllers β
β Services β
β Business Logic β
ββββββββββββ¬βββββββββββ
β
βββββββββββββββββββββββ
β PostgreSQL β
βββββββββββββββββββββββ
β
β
βββββββββββββββββββββββ
β Payment Provider β
βββββββββββββββββββββββ
```
---
## 4. Frontend Engineering Plan
- Component-based React architecture
- Centralized API communication
- Clear loading/error/empty states
- Responsive layouts
- Accessible forms
- Protected admin routes
- Server-backed authorization
---
## 5. Backend Engineering Plan
- Thin controllers
- Service-layer business logic
- Validated inputs
- Repository/data-access separation where useful
- Consistent error handling
- Transactional order operations
- Secure external integration handling
---
## 6. API Contract
Core API groups:
```text
/auth
/products
/cart
/orders
/payments
/admin
```
Important protected operations must verify:
```text
Authentication
+
Authorization
+
Resource Ownership
```
---
## 7. Database & Data Model
Core model:
```text
User
βββ Orders
β βββ OrderItems
β βββ Product
β
βββ Payments
```
Database constraints and indexes should be designed around actual query patterns and business rules.
---
## 8. Authentication & Authorization
Authentication identifies the user.
Authorization determines whether that user can perform the requested action.
Admin permissions must be enforced on the backend, not merely hidden in the frontend.
---
## 9. Security Assessment
The most important security priority is **broken access control**, particularly cross-user order access.
Other important controls include:
- Input validation
- Secure authentication
- Payment security
- Dependency scanning
- Secret management
- Sensitive-log prevention
- Appropriate CSRF protection
- Rate limiting where appropriate
---
## 10. Testing Strategy
Minimum production-oriented test layers:
```text
Unit
β
Integration
β
API
β
E2E
β
Security
β
Regression
```
Critical workflow:
```text
Login
β Product
β Cart
β Checkout
β Payment
β Order
```
must have automated coverage.
---
## 11. Performance & Scalability Plan
Prioritize evidence-driven optimization:
1. Database query performance
2. API latency
3. Product listing scalability
4. Checkout latency
5. Frontend bundle/rendering performance
Use pagination, indexing, caching, and asynchronous processing only where justified.
---
## 12. Reliability & Integration Strategy
External payment services must be treated as unreliable dependencies.
The system should handle:
- Timeout
- Failure
- Duplicate requests
- Unknown payment status
- Provider rate limits
- Webhook delays
Idempotency should protect against duplicate side effects.
---
## 13. Observability Plan
Production monitoring should cover:
- Request latency
- API errors
- Authentication failures
- Authorization failures
- Payment failures
- Order failures
- Database health
- External-service failures
Sensitive payment credentials and user secrets must not appear in logs.
---
## 14. Deployment Strategy
```text
Development
β
Automated Tests
β
Staging
β
Validation
β
Production
β
Monitoring
```
Database migrations must be coordinated with application deployment and rollback strategy.
---
## 15. Implementation Roadmap
**Priority 1 - Security**
- Authentication
- Authorization
- Resource ownership
- Input validation
**Priority 2 - Core Commerce**
- Products
- Cart
- Checkout
- Orders
- Payments
**Priority 3 - Testing**
- Unit
- API
- Integration
- E2E
- Security
**Priority 4 - Production**
- CI/CD
- Monitoring
- Logging
- Health checks
- Rollback procedures
**Priority 5 - Optimization**
- Database optimization
- Caching
- Frontend optimization
- Scalability improvements
---
# π Final Senior Web Application Engineering Blueprint
### β
Confirmed Facts
- React frontend
- Node.js/Express backend
- PostgreSQL database
- REST API architecture
- E-commerce order workflow
- Customer and administrator roles
- Payment integration requirement
### π Assumptions
- REST architecture should remain.
- PostgreSQL remains the database.
- Payment provider supports secure server-side verification.
- Existing application behavior should be preserved.
### π§ Technical Decisions
- Keep modular monolithic architecture.
- Enforce authorization server-side.
- Use transactional database operations for critical workflows.
- Use idempotency for retryable side effects.
- Add automated regression coverage.
- Use evidence-driven performance optimization.
### β οΈ Risks
- Payment duplication
- Broken access control
- Database inconsistency
- External payment failures
- Insufficient test coverage
- Sensitive data exposure
### β Unresolved Questions
- Which payment provider?
- Exact existing code structure?
- Current authentication mechanism?
- Inventory requirements?
- Refund requirements?
- Guest checkout?
- Expected traffic volume?
### π― Acceptance Criteria
The application is ready for production evaluation when:
- Customers can securely authenticate.
- Customers can only access authorized resources.
- Administrators can perform privileged operations.
- Orders cannot be duplicated through retryable requests.
- Payment status is verified reliably.
- Database relationships remain consistent.
- Critical workflows have automated tests.
- Security controls have been validated.
- Production errors are observable.
- Deployment and rollback procedures are documented and tested.
**Overall Engineering Direction:**
```text
Requirements
β
Validated User Flows
β
Existing Architecture Assessment
β
Secure Frontend
β
Validated APIs
β
Reliable Backend
β
Consistent Database
β
Authentication + Authorization
β
Security Testing
β
Performance Validation
β
Observability
β
CI/CD
β
Production
```
This sample demonstrates the expected senior-engineering behavior: **do not invent missing codebase evidence, separate assumptions from facts, preserve existing architecture, enforce authorization server-side, and connect every major requirement to implementation, testing, and production operation.**
By purchasing this prompt, you agree to our terms of service
CLAUDE-5-5-SONNET
Building a serious web application requires more than generating frontend code. Architecture, APIs, database design, authentication, authorization, validation, security, testing, performance, integrations, deployment, and production reliability all have to work together.
Senior Web Application Engineer acts as a senior-level engineering partner across the complete web-application lifecycleβfrom requirements and architecture to implementation, debugging, testing, optimization, and production rea
...more
Added 1 week ago
