# nabilalsaidaly/pharma architecture

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

- Interactive diagram: https://gitdiagram.com/nabilalsaidaly/pharma
- Repository: https://github.com/nabilalsaidaly/pharma

## Overview

Sumaya Pharma is a Laravel modular-monolith backend. A customer-facing API serves public catalog reads and customer sessions, then supports personal collections and preliminary checkout; Google OAuth supplies customer identity. The README also documents catalog filtering, pagination, image metadata, and session/CSRF protections. The graph preserves those product areas while omitting management and purchasing capabilities documented as deferred. Some application and persistence implementations were not sampled, so unverified internal calls are left out.

Main entry points: [`routes/api.php`](https://github.com/nabilalsaidaly/pharma/blob/main/routes/api.php) (API routes), [`app/Domains/Catalog/Interfaces/Http/Controllers/PublicCatalogController.php`](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Catalog/Interfaces/Http/Controllers/PublicCatalogController.php) (Catalog API), [`app/Domains/Identity/Interfaces/Http/Controllers/GoogleAuthenticationController.php`](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Identity/Interfaces/Http/Controllers/GoogleAuthenticationController.php) (Google sign-in), [`app/Domains/Cart/Interfaces/Http/Controllers/CartController.php`](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Cart/Interfaces/Http/Controllers/CartController.php) (Cart API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Customer identity"]
  node_google_controller["Google sign-in"]
  node_oauth_adapter["OAuth adapter"]
  node_auth_action["Customer authentication"]
  node_identity_repository["Customer identity store"]
  node_customer_model[("Customer records<br/>[Customer.php]")]
end

subgraph group_catalog["Public catalog"]
  node_catalog_controller["Catalog API"]
  node_catalog_reader["Public catalog reader"]
  node_catalog_records[("Catalog records<br/>[Product.php]")]
  node_product_resource["Product response"]
end

subgraph group_collections["Personal collections"]
  node_cart_controller["Cart API<br/>[CartController.php]"]
  node_cart_operations["Cart operations<br/>[CartOperations.php]"]
  node_cart_snapshot["Cart snapshot<br/>[CartSnapshot.php]"]
  node_cart_records[("Cart records<br/>[Cart.php]")]
  node_favorites_controller["Favorites API"]
  node_favorite_operations["Favorite operations"]
end

subgraph group_checkout["Preliminary checkout"]
  node_checkout_eval_controller["Checkout evaluation API"]
  node_checkout_evaluator["Checkout evaluation"]
  node_preliminary_controller["Preliminary request API"]
  node_submit_checkout["Submit preliminary request"]
  node_request_history["Request history"]
  node_checkout_records[("Checkout intent records<br/>[CheckoutIntent.php]")]
end

node_customer(("Customer"))
node_api["API routes<br/>[api.php]"]
node_google["Google OAuth"]

node_customer -->|"requests API"| node_api
node_api -->|"routes to"| node_google_controller
node_api -->|"routes to"| node_catalog_controller
node_api -->|"routes to"| node_cart_controller
node_api -->|"routes to"| node_favorites_controller
node_api -->|"routes to"| node_checkout_eval_controller
node_api -->|"routes to"| node_preliminary_controller
node_google_controller -->|"requests identity"| node_oauth_adapter
node_oauth_adapter -->|"authenticates with"| node_google
node_google_controller -->|"authenticates customer"| node_auth_action
node_api -->|"routes to"| node_catalog_controller
node_catalog_controller -->|"reads catalog"| node_catalog_reader
node_catalog_controller -->|"formats products"| node_product_resource
node_cart_controller -->|"changes cart"| node_cart_operations
node_cart_controller -->|"reads snapshot"| node_cart_snapshot
node_favorites_controller -->|"manages favorites"| node_favorite_operations
node_favorites_controller -->|"formats products"| node_product_resource
node_checkout_eval_controller -->|"evaluates checkout"| node_checkout_evaluator
node_preliminary_controller -->|"submits request"| node_submit_checkout
node_preliminary_controller -->|"reads history"| node_request_history
node_catalog_reader -.->|"queries records"| node_catalog_records
node_cart_operations -.->|"persists cart"| node_cart_records
node_cart_snapshot -.->|"reads cart"| node_cart_records
node_submit_checkout -.->|"persists intent"| node_checkout_records
node_request_history -.->|"reads intents"| node_checkout_records

click node_api "https://github.com/nabilalsaidaly/pharma/blob/main/routes/api.php"
click node_google_controller "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Identity/Interfaces/Http/Controllers/GoogleAuthenticationController.php"
click node_oauth_adapter "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Identity/Infrastructure/ExternalServices/Google/SocialiteGoogleOAuthClient.php"
click node_auth_action "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Identity/Application/Actions/AuthenticateGoogleCustomer.php"
click node_identity_repository "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Identity/Infrastructure/Persistence/EloquentCustomerIdentityRepository.php"
click node_customer_model "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Identity/Infrastructure/Persistence/Models/Customer.php"
click node_catalog_controller "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Catalog/Interfaces/Http/Controllers/PublicCatalogController.php"
click node_catalog_reader "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Catalog/Infrastructure/Persistence/Queries/EloquentPublicCatalogReader.php"
click node_catalog_records "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Catalog/Infrastructure/Persistence/Models/Product.php"
click node_product_resource "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Catalog/Interfaces/Http/Resources/ProductResource.php"
click node_cart_controller "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Cart/Interfaces/Http/Controllers/CartController.php"
click node_cart_operations "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Cart/Application/CartOperations.php"
click node_cart_snapshot "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Cart/Application/CartSnapshot.php"
click node_cart_records "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Cart/Infrastructure/Persistence/Models/Cart.php"
click node_favorites_controller "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Favorites/Interfaces/Http/Controllers/FavoriteController.php"
click node_favorite_operations "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Favorites/Application/FavoriteOperations.php"
click node_checkout_eval_controller "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Orders/Interfaces/Http/Controllers/CheckoutEvaluationController.php"
click node_checkout_evaluator "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Orders/Application/EvaluateCheckout.php"
click node_preliminary_controller "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Orders/Interfaces/Http/Controllers/PreliminaryRequestController.php"
click node_submit_checkout "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Orders/Application/SubmitPreliminaryCheckoutRequest.php"
click node_request_history "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Orders/Application/PreliminaryRequestHistory.php"
click node_checkout_records "https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Orders/Infrastructure/Persistence/Models/CheckoutIntent.php"

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_google_controller,node_oauth_adapter,node_auth_action,node_identity_repository,node_customer_model toneBlue
class node_catalog_controller,node_catalog_reader,node_catalog_records,node_product_resource toneAmber
class node_cart_controller,node_cart_operations,node_cart_snapshot,node_cart_records,node_favorites_controller,node_favorite_operations,node_api toneMint
class node_checkout_eval_controller,node_checkout_evaluator,node_preliminary_controller,node_submit_checkout,node_request_history,node_checkout_records toneRose
class node_customer,node_google toneIndigo
```

## Components

### Customer identity

- [Google sign-in](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Identity/Interfaces/Http/Controllers/GoogleAuthenticationController.php): `app/Domains/Identity/Interfaces/Http/Controllers/GoogleAuthenticationController.php`
- [OAuth adapter](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Identity/Infrastructure/ExternalServices/Google/SocialiteGoogleOAuthClient.php): `app/Domains/Identity/Infrastructure/ExternalServices/Google/SocialiteGoogleOAuthClient.php`
- [Customer authentication](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Identity/Application/Actions/AuthenticateGoogleCustomer.php): `app/Domains/Identity/Application/Actions/AuthenticateGoogleCustomer.php`
- [Customer identity store](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Identity/Infrastructure/Persistence/EloquentCustomerIdentityRepository.php): `app/Domains/Identity/Infrastructure/Persistence/EloquentCustomerIdentityRepository.php`
- [Customer records](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Identity/Infrastructure/Persistence/Models/Customer.php): `app/Domains/Identity/Infrastructure/Persistence/Models/Customer.php`

### Public catalog

- [Catalog API](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Catalog/Interfaces/Http/Controllers/PublicCatalogController.php): `app/Domains/Catalog/Interfaces/Http/Controllers/PublicCatalogController.php`
- [Public catalog reader](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Catalog/Infrastructure/Persistence/Queries/EloquentPublicCatalogReader.php): `app/Domains/Catalog/Infrastructure/Persistence/Queries/EloquentPublicCatalogReader.php`
- [Catalog records](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Catalog/Infrastructure/Persistence/Models/Product.php): `app/Domains/Catalog/Infrastructure/Persistence/Models/Product.php`
- [Product response](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Catalog/Interfaces/Http/Resources/ProductResource.php): `app/Domains/Catalog/Interfaces/Http/Resources/ProductResource.php`

### Personal collections

- [Cart API](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Cart/Interfaces/Http/Controllers/CartController.php): `app/Domains/Cart/Interfaces/Http/Controllers/CartController.php`
- [Cart operations](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Cart/Application/CartOperations.php): `app/Domains/Cart/Application/CartOperations.php`
- [Cart snapshot](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Cart/Application/CartSnapshot.php): `app/Domains/Cart/Application/CartSnapshot.php`
- [Cart records](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Cart/Infrastructure/Persistence/Models/Cart.php): `app/Domains/Cart/Infrastructure/Persistence/Models/Cart.php`
- [Favorites API](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Favorites/Interfaces/Http/Controllers/FavoriteController.php): `app/Domains/Favorites/Interfaces/Http/Controllers/FavoriteController.php`
- [Favorite operations](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Favorites/Application/FavoriteOperations.php): `app/Domains/Favorites/Application/FavoriteOperations.php`

### Preliminary checkout

- [Checkout evaluation API](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Orders/Interfaces/Http/Controllers/CheckoutEvaluationController.php): `app/Domains/Orders/Interfaces/Http/Controllers/CheckoutEvaluationController.php`
- [Checkout evaluation](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Orders/Application/EvaluateCheckout.php): `app/Domains/Orders/Application/EvaluateCheckout.php`
- [Preliminary request API](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Orders/Interfaces/Http/Controllers/PreliminaryRequestController.php): `app/Domains/Orders/Interfaces/Http/Controllers/PreliminaryRequestController.php`
- [Submit preliminary request](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Orders/Application/SubmitPreliminaryCheckoutRequest.php): `app/Domains/Orders/Application/SubmitPreliminaryCheckoutRequest.php`
- [Request history](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Orders/Application/PreliminaryRequestHistory.php): `app/Domains/Orders/Application/PreliminaryRequestHistory.php`
- [Checkout intent records](https://github.com/nabilalsaidaly/pharma/blob/main/app/Domains/Orders/Infrastructure/Persistence/Models/CheckoutIntent.php): `app/Domains/Orders/Infrastructure/Persistence/Models/CheckoutIntent.php`

### Other components

- **Customer**
- [API routes](https://github.com/nabilalsaidaly/pharma/blob/main/routes/api.php): `routes/api.php`
- **Google OAuth**

## Connections

- Customer → API routes: requests API (evidence: `routes/api.php`)
- API routes → Google sign-in: routes to (evidence: `routes/api.php`)
- API routes → Catalog API: routes to (evidence: `routes/api.php`)
- API routes → Cart API: routes to (evidence: `routes/api.php`)
- API routes → Favorites API: routes to (evidence: `routes/api.php`)
- API routes → Checkout evaluation API: routes to (evidence: `routes/api.php`)
- API routes → Preliminary request API: routes to (evidence: `routes/api.php`)
- Google sign-in → OAuth adapter: requests identity (evidence: `app/Domains/Identity/Interfaces/Http/Controllers/GoogleAuthenticationController.php`)
- OAuth adapter → Google OAuth: authenticates with (evidence: `app/Domains/Identity/Infrastructure/ExternalServices/Google/SocialiteGoogleOAuthClient.php`)
- Google sign-in → Customer authentication: authenticates customer (evidence: `app/Domains/Identity/Interfaces/Http/Controllers/GoogleAuthenticationController.php`)
- API routes → Catalog API: routes to (evidence: `routes/api.php`)
- Catalog API → Public catalog reader: reads catalog (evidence: `app/Domains/Catalog/Interfaces/Http/Controllers/PublicCatalogController.php`)
- Catalog API → Product response: formats products (evidence: `app/Domains/Catalog/Interfaces/Http/Controllers/PublicCatalogController.php`)
- Cart API → Cart operations: changes cart (evidence: `app/Domains/Cart/Interfaces/Http/Controllers/CartController.php`)
- Cart API → Cart snapshot: reads snapshot (evidence: `app/Domains/Cart/Interfaces/Http/Controllers/CartController.php`)
- Favorites API → Favorite operations: manages favorites (evidence: `app/Domains/Favorites/Interfaces/Http/Controllers/FavoriteController.php`)
- Favorites API → Product response: formats products (evidence: `app/Domains/Favorites/Interfaces/Http/Controllers/FavoriteController.php`)
- Checkout evaluation API → Checkout evaluation: evaluates checkout (evidence: `app/Domains/Orders/Interfaces/Http/Controllers/CheckoutEvaluationController.php`)
- Preliminary request API → Submit preliminary request: submits request (evidence: `app/Domains/Orders/Interfaces/Http/Controllers/PreliminaryRequestController.php`)
- Preliminary request API → Request history: reads history (evidence: `app/Domains/Orders/Interfaces/Http/Controllers/PreliminaryRequestController.php`)
- Public catalog reader → Catalog records: queries records
- Cart operations → Cart records: persists cart (evidence: `app/Domains/Cart/Application/CartOperations.php`)
- Cart snapshot → Cart records: reads cart
- Submit preliminary request → Checkout intent records: persists intent (evidence: `app/Domains/Orders/Application/SubmitPreliminaryCheckoutRequest.php`)
- Request history → Checkout intent records: reads intents
