# ahmedmohamedezz/quickbite_core_service__java_version architecture

> Architecture diagram of the GitHub repository ahmedmohamedezz/quickbite_core_service__java_version, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmedmohamedezz/quickbite_core_service__java_version
- Repository: https://github.com/ahmedmohamedezz/quickbite_core_service__java_version

## Overview

#### Purpose and runtime
QuickBite is a Spring Boot backend for a Talabat-like food-ordering domain: users authenticate, manage addresses, discover restaurant branches, and manage restaurants/products. The application starts at `src/main/java/com/quickbite/core/CoreApplication.java`; Maven build/dependency/runtime definition is `pom.xml`. Persistence is PostgreSQL-oriented, including PostGIS geospatial queries and Flyway-style SQL migrations.

#### HTTP request and platform boundary
Controllers are the API entry points and delegate to domain services, which use repositories and map entities to response DTOs. Cross-cutting request handling establishes correlation IDs, request logging, JWT authentication, security policy, and standardized failures:
- `src/main/java/com/quickbite/core/common/filter/CorrelationIdFilter.java`
- `src/main/java/com/quickbite/core/common/filter/JwtAuthenticationFilter.java`
- `src/main/java/com/quickbite/core/common/config/SecurityConfig.java`
- `src/main/java/com/quickbite/core/common/exception/GlobalExceptionHandler.java`

Authentication state is derived from JWTs and exposed as a `UserPrincipal`; auth tokens are handled as HTTP-only cookies.

#### Identity, authentication, and authorization
Authentication supports registration/login plus password-reset lifecycle. `AuthService` coordinates user lookup, credential handling, token creation, reset-token persistence, and auth responses; `JwtService` is the token boundary. System roles reside on users, while restaurant-scoped RBAC is modeled separately through roles, permissions, and restaurant memberships.
- `src/main/java/com/quickbite/core/auth/controller/AuthController.java`
- `src/main/java/com/quickbite/core/auth/service/AuthService.java`
- `src/main/java/com/quickbite/core/common/security/JwtService.java`
- `src/main/java/com/quickbite/core/rbac/domain/RestaurantMemberEntity.java`
- `src/main/java/com/quickbite/core/user/domain/UserEntity.java`

#### Restaurant and branch management
Restaurants are owned/managed resources with status and administrative update paths. Branches belong to restaurants and add operational state, address/location, delivery radius, ordering acceptance, and currency. The branch repository contains the spatial discovery boundary: a native PostGIS `ST_DWithin` query returns active branches of active restaurants near a customer coordinate.
- `src/main/java/com/quickbite/core/restaurant/service/RestaurantService.java`
- `src/main/java/com/quickbite/core/restaurant/domain/RestaurantEntity.java`
- `src/main/java/com/quickbite/core/branch/service/BranchService.java`
- `src/main/java/com/quickbite/core/branch/repository/BranchRepository.java`

#### Product catalog and branch-specific availability
The product subsystem models categories and canonical products, with `ProductBranchDetailsEntity` providing the join/override layer for a product at a particular branch. `ProductService` is the orchestration point for catalog CRUD and branch detail projections, separating API DTOs from database entities.
- `src/main/java/com/quickbite/core/product/controller/ProductController.java`
- `src/main/java/com/quickbite/core/product/service/ProductService.java`
- `src/main/java/com/quickbite/core/product/domain/ProductEntity.java`
- `src/main/java/com/quickbite/core/product/domain/ProductBranchDetailsEntity.java`

#### Customer profile data
Customer addresses are independently managed records, typed by address category. This is the customer-location input boundary likely used alongside branch proximity results, but no ordering/cart/payment subsystem is present in the repository.
- `src/main/java/com/quickbite/core/customer_addresses/controller/CustomerAddressesController.java`
- `src/main/java/com/quickbite/core/customer_addresses/service/CustomerAddressesService.java`
- `src/main/java/com/quickbite/core/customer_addresses/domain/CustomerAddressEntity.java`

#### Data and operational infrastructure
Database schema evolution is versioned from users and password resets through restaurant geography, catalog, and RBAC seed data. Typed application configuration centralizes environment, database pool, JWT, cookie, and migration settings. A health endpoint explicitly checks database connectivity for deployment/platform probes.
- `src/main/resources/db/migration/V1__create_users_table.sql`
- `src/main/resources/db/migration/V6__create_restaurant_branches_table.sql`
- `src/main/resources/db/migration/V7__create_products_tables.sql`
- `src/main/java/com/quickbite/core/common/config/AppConfig.java`
- `src/main/java/com/quickbite/core/health/controller/HealthController.java`

Main entry points: [`src/main/java/com/quickbite/core/user/domain/UserEntity.java`](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/user/domain/UserEntity.java) (Domain entities), [`src/main/java/com/quickbite/core/auth/service/AuthService.java`](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/auth/service/AuthService.java) (Auth service), [`src/main/java/com/quickbite/core/branch/service/BranchService.java`](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/branch/service/BranchService.java) (Branch service), [`src/main/java/com/quickbite/core/CoreApplication.java`](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/CoreApplication.java) (Spring Boot app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_auth_api["Auth API<br/>controller"]
  node_product_api["Product API<br/>controller"]
  node_address_api["Address API<br/>controller"]
  node_health_api["Health API<br/>controller"]
end

subgraph group_domain["Domain services"]
  node_auth_service["Auth service<br/>[AuthService.java]"]
  node_jwt_service["JWT service<br/>security service<br/>[JwtService.java]"]
  node_restaurant_service["Restaurant service"]
  node_branch_service["Branch service<br/>[BranchService.java]"]
  node_product_service["Product service"]
  node_address_service["Address service"]
end

subgraph group_data["Persistence"]
  node_branch_repository["Branch repository"]
  node_domain_entities["Domain entities<br/>JPA entities<br/>[UserEntity.java]"]
  node_postgres[("PostgreSQL + PostGIS<br/>database")]
  node_migrations["Schema migrations<br/>SQL migrations"]
end

node_app{{"Spring Boot app<br/>runtime"}}
node_security["Security pipeline"]
node_jwt_filter["JWT filter"]
node_app_config["Application config<br/>configuration<br/>[AppConfig.java]"]

node_app -->|"installs"| node_security
node_app -->|"loads"| node_app_config
node_security -->|"authenticates requests"| node_jwt_filter
node_jwt_filter -->|"validates JWT"| node_jwt_service
node_auth_api -->|"delegates"| node_auth_service
node_product_api -->|"delegates"| node_product_service
node_address_api -->|"delegates"| node_address_service
node_auth_service -->|"issues tokens"| node_jwt_service
node_auth_service -->|"manages users and reset tokens"| node_domain_entities
node_restaurant_service -->|"manages restaurants and memberships"| node_domain_entities
node_branch_service -->|"discovers nearby branches"| node_branch_repository
node_branch_service -->|"manages branches"| node_domain_entities
node_product_service -->|"manages catalog and branch overrides"| node_domain_entities
node_address_service -->|"manages customer addresses"| node_domain_entities
node_branch_repository -->|"PostGIS ST_DWithin"| node_postgres
node_domain_entities -->|"persists"| node_postgres
node_migrations -->|"evolves schema"| node_postgres
node_health_api -->|"checks connectivity"| node_postgres
node_app_config -.->|"configures connection"| node_postgres

click node_app "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/CoreApplication.java"
click node_security "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/common/config/SecurityConfig.java"
click node_jwt_filter "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/common/filter/JwtAuthenticationFilter.java"
click node_auth_api "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/auth/controller/AuthController.java"
click node_product_api "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/product/controller/ProductController.java"
click node_address_api "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/customer_addresses/controller/CustomerAddressesController.java"
click node_health_api "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/health/controller/HealthController.java"
click node_auth_service "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/auth/service/AuthService.java"
click node_jwt_service "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/common/security/JwtService.java"
click node_restaurant_service "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/restaurant/service/RestaurantService.java"
click node_branch_service "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/branch/service/BranchService.java"
click node_product_service "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/product/service/ProductService.java"
click node_address_service "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/customer_addresses/service/CustomerAddressesService.java"
click node_branch_repository "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/branch/repository/BranchRepository.java"
click node_domain_entities "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/user/domain/UserEntity.java"
click node_migrations "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/resources/db/migration/V1__create_users_table.sql"
click node_app_config "https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/common/config/AppConfig.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_auth_api,node_product_api,node_address_api,node_health_api toneBlue
class node_auth_service,node_jwt_service,node_restaurant_service,node_branch_service,node_product_service,node_address_service toneAmber
class node_branch_repository,node_domain_entities,node_postgres,node_migrations toneMint
class node_app,node_security,node_jwt_filter,node_app_config toneNeutral
```

## Components

### HTTP API

- [Auth API](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/auth/controller/AuthController.java): controller · `src/main/java/com/quickbite/core/auth/controller/AuthController.java`
- [Product API](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/product/controller/ProductController.java): controller · `src/main/java/com/quickbite/core/product/controller/ProductController.java`
- [Address API](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/customer_addresses/controller/CustomerAddressesController.java): controller · `src/main/java/com/quickbite/core/customer_addresses/controller/CustomerAddressesController.java`
- [Health API](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/health/controller/HealthController.java): controller · Database connectivity probe. · `src/main/java/com/quickbite/core/health/controller/HealthController.java`

### Domain services

- [Auth service](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/auth/service/AuthService.java): service · Registration, login, and password-reset lifecycle. · `src/main/java/com/quickbite/core/auth/service/AuthService.java`
- [JWT service](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/common/security/JwtService.java): security service · Creates and validates token state. · `src/main/java/com/quickbite/core/common/security/JwtService.java`
- [Restaurant service](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/restaurant/service/RestaurantService.java): service · Restaurant ownership and administration. · `src/main/java/com/quickbite/core/restaurant/service/RestaurantService.java`
- [Branch service](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/branch/service/BranchService.java): service · Branch operations and nearby discovery. · `src/main/java/com/quickbite/core/branch/service/BranchService.java`
- [Product service](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/product/service/ProductService.java): service · Catalog CRUD and branch-detail projections. · `src/main/java/com/quickbite/core/product/service/ProductService.java`
- [Address service](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/customer_addresses/service/CustomerAddressesService.java): service · `src/main/java/com/quickbite/core/customer_addresses/service/CustomerAddressesService.java`

### Persistence

- [Branch repository](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/branch/repository/BranchRepository.java): repository · PostGIS proximity query for active branches. · `src/main/java/com/quickbite/core/branch/repository/BranchRepository.java`
- [Domain entities](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/user/domain/UserEntity.java): JPA entities · Users, memberships, restaurants, products, branch details, and addresses. · `src/main/java/com/quickbite/core/user/domain/UserEntity.java`
- **PostgreSQL + PostGIS**: database
- [Schema migrations](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/resources/db/migration/V1__create_users_table.sql): SQL migrations · Versioned user, branch, catalog, and RBAC schema. · `src/main/resources/db/migration/V1__create_users_table.sql`

### Other components

- [Spring Boot app](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/CoreApplication.java): runtime · Application bootstrap. · `src/main/java/com/quickbite/core/CoreApplication.java`
- [Security pipeline](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/common/config/SecurityConfig.java): security · JWT authentication, policy, correlation, and error handling. · `src/main/java/com/quickbite/core/common/config/SecurityConfig.java`
- [JWT filter](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/common/filter/JwtAuthenticationFilter.java): filter · `src/main/java/com/quickbite/core/common/filter/JwtAuthenticationFilter.java`
- [Application config](https://github.com/ahmedmohamedezz/quickbite_core_service__java_version/blob/main/src/main/java/com/quickbite/core/common/config/AppConfig.java): configuration · Environment, pool, JWT, cookie, and migration settings. · `src/main/java/com/quickbite/core/common/config/AppConfig.java`

## Connections

- Spring Boot app → Security pipeline: installs
- Spring Boot app → Application config: loads
- Security pipeline → JWT filter: authenticates requests
- JWT filter → JWT service: validates JWT
- Auth API → Auth service: delegates
- Product API → Product service: delegates
- Address API → Address service: delegates
- Auth service → JWT service: issues tokens
- Auth service → Domain entities: manages users and reset tokens
- Restaurant service → Domain entities: manages restaurants and memberships
- Branch service → Branch repository: discovers nearby branches
- Branch service → Domain entities: manages branches
- Product service → Domain entities: manages catalog and branch overrides
- Address service → Domain entities: manages customer addresses
- Branch repository → PostgreSQL + PostGIS: PostGIS ST_DWithin
- Domain entities → PostgreSQL + PostGIS: persists
- Schema migrations → PostgreSQL + PostGIS: evolves schema
- Health API → PostgreSQL + PostGIS: checks connectivity
- Application config → PostgreSQL + PostGIS: configures connection
