How xwasnotdeclared/be_cooking works
1. Overall shape: This is a single Spring Boot monolith organized in the classic Controller → Service → Repository → JPA Entity style. The backend is the system of record for recipes, users, orders, wallets, search indexes, notifications, and AI-related metadata.
2. API surface is split by audience: Controllers are grouped into:
- controller/pub for public/auth/AI/upload endpoints,
- domain controllers for recipes, carts, comments, orders, payments, etc.,
- controller/admin for moderation and admin dashboards.
This separation is a useful boundary for an architecture diagram.
3. Core content domain: The main business domain is a recipe platform built around Recipe, Ingredient, Step, Category, Tag, Collection, Comment, RecipeLike, UserFollow, and related join entities. DTOs and mappers sit between the HTTP layer and persistence layer to keep the API contracts separate from entities.
4. Social and engagement flows: Recipe creation, updates, likes, comments, follows, and tag/category changes emit domain events such as RecipeCreatedEvent, RecipeUpdatedEvent, RecipeCommentedEvent, and UserFollowedEvent. These are handled by listeners that update notifications, indexes, or derived state without coupling the controllers directly to those side effects.
5. Authentication and security boundary: Security is implemented with Spring Security + JWT. The security layer includes a JWT filter, user-details service, refresh-token support, and auth-related DTOs. AuthController and UserController are the public entry points for login, registration, reset password, and profile management.
6. AI / RAG subsystem: The repo has a distinct AI path with AIController, ChatBotController, ChatBotService, ToolService, RecipeEnrichmentService, and chatbot tools under tools_chatbot. The configuration classes and the README indicate integration with Groq LLMs and Pinecone for vector search / RAG. This subsystem answers cooking questions, suggests recipes from ingredients, and supports image-based ingredient understanding.
7. Search and retrieval: Recipe search is not just relational filtering. There is a dedicated search stack with SearchService, MeiliRecipeService, RecipeSearchIndex, and PineconeClientConfig. The architecture suggests a two-path retrieval model: standard DB queries for normal browsing and vector/semantic retrieval for AI-assisted discovery.
8. Commerce and fulfillment: The platform also supports a marketplace-like flow: cart, buy-now, buyer and seller order controllers/services, dish orders, payment orders, wallet transactions, seller wallets, package upgrades, and withdrawals. VNPayConfig shows that external payment processing is part of the order flow, with wallet settlement handled inside the backend.
9. Media and uploads: File handling is centralized through UploadController, UploadFileService, and a LocalFileUploadService implementation. Uploaded assets are stored in the repo’s static_resource area, so media storage is an explicit subsystem rather than being embedded in the recipe domain.
10. Persistence and derived data: Persistence is primarily through Spring Data repositories over MySQL. The repo also includes projection DTOs and stats DTOs for dashboards, recipe analytics, and leaderboards. That indicates read-optimized queries for reporting alongside the transactional entities.
11. Background processing and consistency: There is a scheduler (RecipeSyncScheduler) and an OutBoxEvent model/repository, which together point to asynchronous synchronization patterns. The likely architectural purpose is to keep derived systems such as search indexes and notifications consistent with the main relational data store.
12. Client applications in the repo: The repository contains two separate frontend clients:
- recipe-app: a React + Vite + TypeScript web client,
- recipe: an Expo/React Native client structure.
The README’s frontend notes are older, so the tree is the better source for the current client layout.
13. Operational bootstrap: DataInitializer, AppProperties, JwtProperties, UploadProperties, and OpenApiConfig show that startup wiring is important: seed data, environment-driven configuration, Swagger/OpenAPI docs, and integration credentials are all part of deployment-time architecture.
14. Main external dependencies: The backend materially depends on MySQL, Pinecone, Groq/LLM APIs, VNPay, and email/OTP support. These external services shape the system boundaries more than the UI does, especially for AI, payments, and notification flows.
Main entry points: pub Public API · repository Repositories · controller Domain API · service AI & Search
Components 23
Spring Boot backend
Monolithic backend with API, domain, persistence, security, AI, and async workflows.
- Cooking App · Main backend application bootstrap and wiring.
cooking/src/main/java/com/example/cooking/CookingApplication.java - Public API · Auth, AI, upload, and other public-facing endpoints.
cooking/src/main/java/com/example/cooking/controller/pub - Domain API · Recipe, cart, comments, orders, payments, search, and profile endpoints.
cooking/src/main/java/com/example/cooking/controller - Admin API · Moderation and dashboard endpoints for administrators.
cooking/src/main/java/com/example/cooking/controller/admin - Security · JWT, Spring Security, user details, and request filtering.
cooking/src/main/java/com/example/cooking/security - Core Services · Recipe, user, social, category, tag, ingredient, and collection orchestration.
cooking/src/main/java/com/example/cooking/service - Engagement · Comments, likes, follows, notifications, and derived engagement flows.
cooking/src/main/java/com/example/cooking/service - Commerce · Cart, buyer/seller orders, payments, wallets, withdrawals, and upgrades.
cooking/src/main/java/com/example/cooking/service - AI & Search · Chatbot, tool execution, enrichment, semantic search, and vector data handling.
cooking/src/main/java/com/example/cooking/service - Uploads · Centralized file upload abstraction and local storage implementation.
cooking/src/main/java/com/example/cooking/service/impl - Domain Events · Recipe, category, tag, and follow events emitted by core workflows.
cooking/src/main/java/com/example/cooking/event - Event Listeners · Notification, index, and derived-state handlers for domain events.
cooking/src/main/java/com/example/cooking/listener - Domain Models · Recipe, user, order, wallet, search index, notification, and relationship entities.
cooking/src/main/java/com/example/cooking/model - Repositories · Persistence layer for transactional data, search indexes, and reporting reads.
cooking/src/main/java/com/example/cooking/repository - DTOs & Mappers · Request/response DTOs, projections, and mappers between HTTP and persistence.
cooking/src/main/java/com/example/cooking/dto - Config & Bootstrap · App properties, OpenAPI, data seeding, payment, AI, upload, and web config.
cooking/src/main/java/com/example/cooking/config - Scheduler · Periodic synchronization for derived systems.
cooking/src/main/java/com/example/cooking/cheduler
Client apps
Web and mobile frontends included in the repository.
- Web Client · React web frontend for browsing and creating recipes.
recipe-app - Mobile App · Expo-based mobile client structure.
recipe
External systems
Third-party and infrastructure dependencies shaped by backend integrations.
- MySQL · Primary system of record for backend persistence.
- Groq LLM · Large language model provider used by chatbot and AI features.
- Pinecone · Vector search backend for semantic retrieval and RAG.
- VNPay · External payment processing and transaction confirmation.
Connections 38
- Cooking App → Config & Bootstrap: loads · Bootstraps application settings, seed data, and integrations.
- Cooking App → Security: secures · Applies security configuration to request processing.
- Cooking App → Public API: exposes · Publishes public endpoints.
- Cooking App → Domain API: exposes · Publishes domain endpoints.
- Cooking App → Admin API: exposes · Publishes admin endpoints.
- Public API → DTOs & Mappers: uses · Consumes request and response contracts.
- Domain API → DTOs & Mappers: uses · Maps between HTTP payloads and domain data.
- Admin API → DTOs & Mappers: uses · Uses dashboard DTOs and projections.
- Public API → Core Services: calls · Delegates public recipe and profile actions.
- Domain API → Core Services: calls · Delegates core recipe and catalog operations.
- Domain API → Engagement: calls · Handles comments, likes, follows, and notifications.
- Domain API → Commerce: calls · Handles carts, orders, payments, and wallets.
- Public API → AI & Search: calls · Routes chatbot and AI-assisted retrieval requests.
- Core Services → Domain Models: persists · Reads and writes recipe and catalog entities.
- Engagement → Domain Models: persists · Updates social and notification entities.
- Commerce → Domain Models: persists · Updates order, payment, and wallet entities.
- AI & Search → Domain Models: reads · Uses recipe and search index data for retrieval.
- Core Services → Repositories: uses · Coordinates persistence through repositories.
- Engagement → Repositories: uses · Stores likes, comments, follows, and notifications.
- Commerce → Repositories: uses · Stores commerce and wallet state.
- AI & Search → Repositories: uses · Reads search and content data.
- AI & Search → Groq LLM: integrates · Delegates chatbot reasoning and generation.
- AI & Search → Pinecone: integrates · Performs semantic search and RAG retrieval.
- Commerce → VNPay: integrates · Processes payment and settlement flows.
- Uploads → Public API: served by · Upload endpoints expose file ingestion.
- Uploads → Config & Bootstrap: configured by · Uses upload properties and storage settings.
- Domain Events → Event Listeners: handled by · Event listeners react to published domain events.
- Core Services → Domain Events: emits · Publishes recipe and catalog change events.
- Engagement → Domain Events: emits · Publishes social interaction events.
- Event Listeners → Engagement: updates · Creates notifications and derived engagement state.
- Event Listeners → Repositories: writes · Persists event-driven side effects and indexes.
- Scheduler → Repositories: syncs · Coordinates periodic consistency work.
- Scheduler → AI & Search: refreshes · Supports search/index synchronization jobs.
- Config & Bootstrap → MySQL: connects · Configures primary relational persistence.
- Repositories → MySQL: reads/writes · Implements the system of record.
- Web Client → Public API: consumes · Uses public backend APIs.
- Web Client → Domain API: consumes · Uses recipe and commerce APIs.
- Mobile App → Public API: consumes · Uses public backend APIs.