How antonbas/sushi-shop works
Purpose and Entry Points
Sushi Shop is a Docker-deployable full-stack monolith for catalog browsing, checkout, Stripe payment, and role-based order delivery tracking. The React SPA starts at frontend/src/main.tsx and composes routes in frontend/src/App.tsx. The Java 21 Spring Boot API starts at backend/src/main/java/com/sushishop/BackendApplication.java. Deployment topology is defined by compose.yaml, with monitoring configuration in prometheus.yml.
Frontend Application and Client Boundaries
The React/TypeScript client separates storefront, profile, and administrative workflows, including cart state and protected routes. Authentication, cart, and notification state are application contexts in frontend/src/context/AuthContext.tsx, frontend/src/context/CartContext.tsx, and frontend/src/context/NotificationContext.tsx. REST calls are centralized under frontend/src/api/client.ts and domain API modules such as frontend/src/api/orders.ts; real-time order updates are consumed through frontend/src/hooks/features/useWebSocket.ts.
API, Security, and Identity
Feature controllers expose the server API; services enforce domain workflows; repositories persist JPA entities; DTOs/mappers bound external payloads to the domain. Spring Security applies JWT authentication and role access control through backend/src/main/java/com/sushishop/shared/config/SecurityConfig.java and backend/src/main/java/com/sushishop/shared/security/jwt/JwtAuthenticationFilter.java. Auth supports registration/login, verification and reset tokens, plus Google OAuth2 via backend/src/main/java/com/sushishop/auth/AuthService.java, backend/src/main/java/com/sushishop/token/TokenService.java, and backend/src/main/java/com/sushishop/shared/security/oauth2/OAuth2AuthenticationSuccessHandler.java.
Catalog, Promotions, and Reviews
Products are the storefront’s core read/write aggregate, with separate query, mutation, enrichment, and image-management responsibilities: backend/src/main/java/com/sushishop/product/ProductService.java, backend/src/main/java/com/sushishop/product/ProductQueryService.java, and backend/src/main/java/com/sushishop/product/ProductImageService.java. Specifications support filtered catalog queries, while enrichment supplies display-facing details. Promotions are independently managed and validated to avoid conflicting active product assignments in backend/src/main/java/com/sushishop/promotion/PromotionService.java and backend/src/main/java/com/sushishop/promotion/PromotionValidator.java. Reviews and replies attach customer feedback to products through backend/src/main/java/com/sushishop/review/ReviewService.java.
Order-to-Payment Lifecycle
Checkout sends cart/address/order-item data to the order boundary. backend/src/main/java/com/sushishop/order/OrderCreationService.java creates orders and items; backend/src/main/java/com/sushishop/order/OrderService.java manages status transitions; backend/src/main/java/com/sushishop/order/OrderQueryService.java supplies role-appropriate retrieval. Payments are persisted separately and delegated to Stripe through backend/src/main/java/com/sushishop/payment/PaymentService.java and backend/src/main/java/com/sushishop/payment/StripeService.java. backend/src/main/java/com/sushishop/payment/PaymentConfirmedEvent.java is the internal event boundary for confirmed-payment follow-on behavior.
Real-Time and Cross-Cutting Controls
Order status changes are broadcast using Spring WebSocket/STOMP configured in backend/src/main/java/com/sushishop/shared/config/WebSocketConfig.java, reaching the SPA’s WebSocket hook. Audit logging is AOP-driven rather than embedded in each domain workflow: backend/src/main/java/com/sushishop/audit/AuditAspect.java records annotated actions into the audit domain. Rate limiting is likewise aspect/service based in backend/src/main/java/com/sushishop/shared/ratelimit/RateLimitAspect.java and backend/src/main/java/com/sushishop/shared/ratelimit/RateLimitService.java; scheduled cleanup maintains expired tokens and rate-limit state.
Persistence and External Infrastructure
PostgreSQL is the authoritative relational store, versioned with Flyway migrations rooted at backend/src/main/resources/db/migration/V1__init_schema.sql. Redis is configured as shared cache/state infrastructure in backend/src/main/java/com/sushishop/shared/config/RedisConfig.java. Other external boundaries are Stripe, Google OAuth2, SMTP mail (backend/src/main/java/com/sushishop/mail/MailService.java), file storage (backend/src/main/java/com/sushishop/file/FileStorageService.java), and Prometheus/Grafana monitoring. Runtime profiles and service integration settings live in backend/src/main/resources/application.yaml and backend/src/main/resources/application-docker.yml.
Main entry points: BackendApplication.java Spring Boot API · V1__init_schema.sql PostgreSQL · OrderService.java Order lifecycle · AuthService.java Auth & token workflows
Components 21
React SPA
- SPA entry & routes
frontend/src/main.tsx - Auth, cart & notifications
frontend/src/context/AuthContext.tsx - REST API client
frontend/src/api/client.ts - Order update hook
frontend/src/hooks/features/useWebSocket.ts
Spring Boot API
- Spring Boot API
backend/src/main/java/com/sushishop/BackendApplication.java - JWT & role security
backend/src/main/java/com/sushishop/shared/config/SecurityConfig.java - Auth & token workflows · Registration, login, verification, reset, and OAuth identity flows.
backend/src/main/java/com/sushishop/auth/AuthService.java - Catalog & product media · Queries, mutations, enrichment, and image management.
backend/src/main/java/com/sushishop/product/ProductService.java - Promotions & reviews
backend/src/main/java/com/sushishop/promotion/PromotionService.java - Order lifecycle · Creates orders, transitions status, and provides role-scoped queries.
backend/src/main/java/com/sushishop/order/OrderService.java - Payment orchestration · Persists payments and handles confirmed-payment events.
backend/src/main/java/com/sushishop/payment/PaymentService.java - STOMP order broadcasts
backend/src/main/java/com/sushishop/shared/config/WebSocketConfig.java - Audit & rate limiting · Cross-cutting aspects record actions and limit requests.
backend/src/main/java/com/sushishop/audit/AuditAspect.java
Data & infrastructure
- PostgreSQL · Authoritative JPA store, initialized by Flyway.
backend/src/main/resources/db/migration/V1__init_schema.sql - Redis
backend/src/main/java/com/sushishop/shared/config/RedisConfig.java - Docker Compose
compose.yaml
External services
- Stripe
- Google OAuth2
- SMTP mail
backend/src/main/java/com/sushishop/mail/MailService.java - File storage
backend/src/main/java/com/sushishop/file/FileStorageService.java - Prometheus & Grafana
prometheus.yml
Connections 29
- SPA entry & routes → Auth, cart & notifications: uses
- SPA entry & routes → REST API client: calls through
- SPA entry & routes → Order update hook: subscribes
- REST API client → Spring Boot API: REST
- Order update hook → STOMP order broadcasts: STOMP
- Spring Boot API → JWT & role security: secured by
- JWT & role security → Auth & token workflows: authenticates via
- Spring Boot API → Catalog & product media: catalog API
- Spring Boot API → Promotions & reviews: promotion and review API
- Spring Boot API → Order lifecycle: checkout and order API
- Order lifecycle → Payment orchestration: initiates payment
- Payment orchestration → Stripe: charges via
- Payment orchestration → Order lifecycle: payment confirmed
- Order lifecycle → STOMP order broadcasts: status changes
- Auth & token workflows → Google OAuth2: OAuth2
- Auth & token workflows → SMTP mail: sends verification/reset
- Catalog & product media → File storage: stores images
- Auth & token workflows → PostgreSQL: persists
- Catalog & product media → PostgreSQL: persists
- Promotions & reviews → PostgreSQL: persists
- Order lifecycle → PostgreSQL: persists orders
- Payment orchestration → PostgreSQL: persists payments
- Spring Boot API → Redis: cache and shared state
- Audit & rate limiting → PostgreSQL: writes audit data
- Spring Boot API → Audit & rate limiting: cross-cutting controls
- Docker Compose → Spring Boot API: deploys
- Docker Compose → PostgreSQL: runs
- Docker Compose → Redis: runs
- Prometheus & Grafana → Spring Boot API: scrapes metrics