# xsmorex/loan-quote-service architecture

> Architecture diagram of the GitHub repository xsmorex/loan-quote-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xsmorex/loan-quote-service
- Repository: https://github.com/xsmorex/loan-quote-service

## Overview

Loan Quote Service is a full-stack application: users enter loan details, receive a quote selected from eligible catalogue products, and can persist and review quotes. The backend also supports preview, retrieval, listing, and version-checked updates. The graph follows documented HTTP boundaries and sampled calls; unsampled implementation details are represented only where the README establishes the capability.

Main entry points: [`frontend/src/LoanQuotePage.tsx`](https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/LoanQuotePage.tsx) (Quote page), [`src/application/quote-service.ts`](https://github.com/xsmorex/loan-quote-service/blob/main/src/application/quote-service.ts) (Quote service), [`src/server.ts`](https://github.com/xsmorex/loan-quote-service/blob/main/src/server.ts) (Application composition), [`src/infrastructure/json-product-repository.ts`](https://github.com/xsmorex/loan-quote-service/blob/main/src/infrastructure/json-product-repository.ts) (Product catalogue adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Loan quote interface"]
  node_page["Quote page<br/>[LoanQuotePage.tsx]"]
  node_form["Loan form<br/>[LoanForm.tsx]"]
  node_formutils["Form validation<br/>[loanForm.ts]"]
  node_quoteview["Quote display<br/>[QuoteResult.tsx]"]
  node_details["Product details<br/>[ProductDetails.tsx]"]
  node_history["Saved quotes<br/>[MyQuotes.tsx]"]
  node_format["Display formatting<br/>[format.ts]"]
  node_api_client["Quote API client<br/>[quotes.ts]"]
  node_quotes_hook["Quote list state<br/>[useQuotes.ts]"]
end

subgraph group_api["HTTP and orchestration"]
  node_http["Fastify API<br/>[app.ts]"]
  node_service["Quote service<br/>[quote-service.ts]"]
  node_ports["Repository ports<br/>[ports.ts]"]
  node_server["Application composition<br/>[server.ts]"]
end

subgraph group_decision["Quote decisioning"]
  node_rules["Eligibility and selection<br/>[product-rules.ts]"]
  node_interest["Interest calculation<br/>[interest.ts]"]
  node_models["Quote models<br/>[models.ts]"]
end

subgraph group_storage["Catalogue and persistence"]
  node_catalogue["Product catalogue adapter"]
  node_product_file["Product catalogue<br/>[products.json]"]
  node_quote_repo[("SQLite quote repository")]
end

node_borrower(("Borrower"))

node_borrower -->|"enters loan details"| node_page
node_page -->|"renders"| node_form
node_page -->|"validates and converts"| node_formutils
node_page -->|"requests quote"| node_api_client
node_page -->|"renders result"| node_quoteview
node_page -->|"renders details"| node_details
node_page -->|"renders saved quotes"| node_history
node_page -->|"loads quote list"| node_quotes_hook
node_quotes_hook -->|"fetches quotes"| node_api_client
node_quoteview -->|"formats values"| node_format
node_details -->|"formats values"| node_format
node_history -->|"formats values"| node_format
node_api_client -->|"sends HTTP requests"| node_http
node_server -->|"builds API"| node_http
node_server -->|"configures service"| node_service
node_server -->|"configures catalogue"| node_catalogue
node_server -->|"configures persistence"| node_quote_repo
node_http -->|"dispatches quote operations"| node_service
node_service -->|"selects eligible product"| node_rules
node_service -->|"calculates interest"| node_interest
node_service -->|"loads products"| node_catalogue
node_service -->|"creates and manages quotes"| node_quote_repo
node_catalogue -->|"reads catalogue"| node_product_file
node_service -->|"uses quote data"| node_models
node_catalogue -->|"maps product data"| node_models
node_quote_repo -->|"maps persisted quotes"| node_models
node_service -->|"implements repository contracts"| node_ports

click node_page "https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/LoanQuotePage.tsx"
click node_form "https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/components/LoanForm.tsx"
click node_formutils "https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/utils/loanForm.ts"
click node_quoteview "https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/components/QuoteResult.tsx"
click node_details "https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/components/ProductDetails.tsx"
click node_history "https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/components/MyQuotes.tsx"
click node_format "https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/utils/format.ts"
click node_api_client "https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/api/quotes.ts"
click node_quotes_hook "https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/hooks/useQuotes.ts"
click node_http "https://github.com/xsmorex/loan-quote-service/blob/main/src/http/app.ts"
click node_service "https://github.com/xsmorex/loan-quote-service/blob/main/src/application/quote-service.ts"
click node_ports "https://github.com/xsmorex/loan-quote-service/blob/main/src/application/ports.ts"
click node_rules "https://github.com/xsmorex/loan-quote-service/blob/main/src/domain/product-rules.ts"
click node_interest "https://github.com/xsmorex/loan-quote-service/blob/main/src/domain/interest.ts"
click node_models "https://github.com/xsmorex/loan-quote-service/blob/main/src/domain/models.ts"
click node_server "https://github.com/xsmorex/loan-quote-service/blob/main/src/server.ts"
click node_catalogue "https://github.com/xsmorex/loan-quote-service/blob/main/src/infrastructure/json-product-repository.ts"
click node_product_file "https://github.com/xsmorex/loan-quote-service/blob/main/products.json"
click node_quote_repo "https://github.com/xsmorex/loan-quote-service/blob/main/src/infrastructure/sqlite-quote-repository.ts"

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_page,node_form,node_formutils,node_quoteview,node_details,node_history,node_format,node_api_client,node_quotes_hook toneBlue
class node_http,node_service,node_ports,node_server toneAmber
class node_rules,node_interest,node_models toneMint
class node_catalogue,node_product_file,node_quote_repo toneRose
class node_borrower toneIndigo
```

## Components

### Loan quote interface

- [Quote page](https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/LoanQuotePage.tsx): `frontend/src/LoanQuotePage.tsx`
- [Loan form](https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/components/LoanForm.tsx): `frontend/src/components/LoanForm.tsx`
- [Form validation](https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/utils/loanForm.ts): `frontend/src/utils/loanForm.ts`
- [Quote display](https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/components/QuoteResult.tsx): `frontend/src/components/QuoteResult.tsx`
- [Product details](https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/components/ProductDetails.tsx): `frontend/src/components/ProductDetails.tsx`
- [Saved quotes](https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/components/MyQuotes.tsx): `frontend/src/components/MyQuotes.tsx`
- [Display formatting](https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/utils/format.ts): `frontend/src/utils/format.ts`
- [Quote API client](https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/api/quotes.ts): `frontend/src/api/quotes.ts`
- [Quote list state](https://github.com/xsmorex/loan-quote-service/blob/main/frontend/src/hooks/useQuotes.ts): `frontend/src/hooks/useQuotes.ts`

### HTTP and orchestration

- [Fastify API](https://github.com/xsmorex/loan-quote-service/blob/main/src/http/app.ts): `src/http/app.ts`
- [Quote service](https://github.com/xsmorex/loan-quote-service/blob/main/src/application/quote-service.ts): `src/application/quote-service.ts`
- [Repository ports](https://github.com/xsmorex/loan-quote-service/blob/main/src/application/ports.ts): `src/application/ports.ts`
- [Application composition](https://github.com/xsmorex/loan-quote-service/blob/main/src/server.ts): `src/server.ts`

### Quote decisioning

- [Eligibility and selection](https://github.com/xsmorex/loan-quote-service/blob/main/src/domain/product-rules.ts): `src/domain/product-rules.ts`
- [Interest calculation](https://github.com/xsmorex/loan-quote-service/blob/main/src/domain/interest.ts): `src/domain/interest.ts`
- [Quote models](https://github.com/xsmorex/loan-quote-service/blob/main/src/domain/models.ts): `src/domain/models.ts`

### Catalogue and persistence

- [Product catalogue adapter](https://github.com/xsmorex/loan-quote-service/blob/main/src/infrastructure/json-product-repository.ts): `src/infrastructure/json-product-repository.ts`
- [Product catalogue](https://github.com/xsmorex/loan-quote-service/blob/main/products.json): `products.json`
- [SQLite quote repository](https://github.com/xsmorex/loan-quote-service/blob/main/src/infrastructure/sqlite-quote-repository.ts): `src/infrastructure/sqlite-quote-repository.ts`

### Other components

- **Borrower**

## Connections

- Borrower → Quote page: enters loan details (evidence: `README.md`)
- Quote page → Loan form: renders (evidence: `frontend/src/LoanQuotePage.tsx`)
- Quote page → Form validation: validates and converts (evidence: `frontend/src/LoanQuotePage.tsx`)
- Quote page → Quote API client: requests quote (evidence: `frontend/src/LoanQuotePage.tsx`)
- Quote page → Quote display: renders result (evidence: `frontend/src/LoanQuotePage.tsx`)
- Quote page → Product details: renders details (evidence: `frontend/src/LoanQuotePage.tsx`)
- Quote page → Saved quotes: renders saved quotes (evidence: `frontend/src/LoanQuotePage.tsx`)
- Quote page → Quote list state: loads quote list (evidence: `frontend/src/LoanQuotePage.tsx`)
- Quote list state → Quote API client: fetches quotes (evidence: `frontend/src/hooks/useQuotes.ts`)
- Quote display → Display formatting: formats values (evidence: `frontend/src/components/QuoteResult.tsx`)
- Product details → Display formatting: formats values (evidence: `frontend/src/components/ProductDetails.tsx`)
- Saved quotes → Display formatting: formats values (evidence: `frontend/src/components/MyQuotes.tsx`)
- Quote API client → Fastify API: sends HTTP requests (evidence: `README.md`)
- Application composition → Fastify API: builds API (evidence: `src/server.ts`)
- Application composition → Quote service: configures service (evidence: `src/server.ts`)
- Application composition → Product catalogue adapter: configures catalogue (evidence: `src/server.ts`)
- Application composition → SQLite quote repository: configures persistence (evidence: `src/server.ts`)
- Fastify API → Quote service: dispatches quote operations (evidence: `src/http/app.ts`)
- Quote service → Eligibility and selection: selects eligible product (evidence: `src/application/quote-service.ts`)
- Quote service → Interest calculation: calculates interest (evidence: `src/application/quote-service.ts`)
- Quote service → Product catalogue adapter: loads products (evidence: `src/application/quote-service.ts`)
- Quote service → SQLite quote repository: creates and manages quotes (evidence: `src/application/quote-service.ts`)
- Product catalogue adapter → Product catalogue: reads catalogue (evidence: `README.md`)
- Quote service → Quote models: uses quote data (evidence: `src/application/quote-service.ts`)
- Product catalogue adapter → Quote models: maps product data (evidence: `src/infrastructure/json-product-repository.ts`)
- SQLite quote repository → Quote models: maps persisted quotes (evidence: `src/infrastructure/sqlite-quote-repository.ts`)
- Quote service → Repository ports: implements repository contracts (evidence: `src/application/quote-service.ts`)
