# abhisheksuryawanshi/smartapi architecture

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

- Interactive diagram: https://gitdiagram.com/abhisheksuryawanshi/smartapi
- Repository: https://github.com/abhisheksuryawanshi/smartapi

## Overview

SmartAPI turns JSON samples or OpenAPI schemas into typed Swift API layers, then supplies a runtime for requests, pagination, caching, and optional UI/mutation features. The main journey is sample/spec → generated wrapper and models → configured request → fetched and paginated data → SwiftUI presentation. The runtime and macro internals are only partially sampled, so their links reflect the README and explicit source documentation; uncertain implementation wiring is omitted.

Main entry points: [`Sources/SmartAPI/SmartClient.swift`](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartClient.swift) (HTTP client), [`Sources/SmartAPI/PaginatedLoader.swift`](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/PaginatedLoader.swift) (Paginated loader), [`Sources/smartapi-bundle/SmartAPIBundle.swift`](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/smartapi-bundle/SmartAPIBundle.swift) (smartapi-bundle), [`Sources/SmartAPIMacros/SmartAPIMacro.swift`](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPIMacros/SmartAPIMacro.swift) (@SmartAPI macro)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_generation["Schema generation"]
  node_bundle["smartapi-bundle"]
  node_fixtureprocessor["Fixture processor"]
  node_importer["OpenAPI importer"]
  node_renderer["Wrapper renderer"]
  node_macro["@SmartAPI macro"]
  node_inference["JSON inference"]
  node_generator["Code generator"]
  node_models["Typed models"]
end

subgraph group_runtime["API runtime"]
  node_endpoint["Endpoint catalog"]
  node_query["Request query<br/>[SmartQuery.swift]"]
  node_client["HTTP client<br/>[SmartClient.swift]"]
end

subgraph group_pagination["Pagination and UI"]
  node_loader["Paginated loader"]
  node_strategy["Pagination strategy"]
  node_view["SwiftUI views<br/>[SmartView.swift]"]
end

subgraph group_features["Production features"]
  node_cache[("Response cache<br/>[SmartCache.swift]")]
  node_auth["Authorization provider"]
  node_retry["Retry policy<br/>[RetryPolicy.swift]"]
  node_coalescer["Request coalescer"]
  node_observer["Request observer"]
  node_mutator["Model mutator"]
end

node_developer(("App developer"))
node_json["JSON sample"]
node_openapi["OpenAPI spec"]
node_service(("API service"))

node_developer -->|"provides sample"| node_json
node_developer -->|"provides spec"| node_openapi
node_json -->|"annotates model"| node_macro
node_json -.->|"fixture input"| node_bundle
node_bundle -->|"dispatches fixtures"| node_fixtureprocessor
node_fixtureprocessor -->|"renders wrapper"| node_renderer
node_openapi -.->|"spec input"| node_bundle
node_bundle -->|"dispatches import"| node_importer
node_importer -->|"renders wrappers"| node_renderer
node_renderer -->|"emits annotation"| node_macro
node_macro -->|"infers schema"| node_inference
node_macro -->|"generates declarations"| node_generator
node_inference -->|"supplies type tree"| node_generator
node_generator -->|"emits models"| node_models
node_models -->|"types responses"| node_endpoint
node_developer -->|"configures endpoints"| node_endpoint
node_endpoint -->|"calls endpoint"| node_client
node_developer -->|"configures request"| node_query
node_query -->|"describes request"| node_client
node_client -->|"sends HTTP"| node_service
node_service -->|"returns response"| node_client
node_loader -->|"fetches pages"| node_client
node_loader -->|"advances state"| node_strategy
node_strategy -->|"supplies page rules"| node_loader
node_view -->|"loads items"| node_loader
node_client -->|"gets credentials"| node_auth
node_client -->|"applies retries"| node_retry
node_client -->|"coalesces reads"| node_coalescer
node_loader -->|"uses cache"| node_cache
node_client -->|"reports activity"| node_observer
node_mutator -->|"sends mutations"| node_client

click node_bundle "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/smartapi-bundle/SmartAPIBundle.swift"
click node_fixtureprocessor "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/smartapi-bundle/FixtureProcessor.swift"
click node_importer "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPIImporter/OpenAPIImporter.swift"
click node_renderer "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPIImporter/WrapperRenderer.swift"
click node_macro "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPIMacros/SmartAPIMacro.swift"
click node_inference "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPIMacros/JSONInference.swift"
click node_generator "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPIMacros/CodeGenerator.swift"
click node_models "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPIMacros/CodeGenerator.swift"
click node_endpoint "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartEndpoint.swift"
click node_query "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartQuery.swift"
click node_client "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartClient.swift"
click node_loader "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/PaginatedLoader.swift"
click node_strategy "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/PaginationStrategy.swift"
click node_view "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartView.swift"
click node_cache "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartCache.swift"
click node_auth "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/AuthorizationProvider.swift"
click node_retry "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/RetryPolicy.swift"
click node_coalescer "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/RequestCoalescer.swift"
click node_observer "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartAPIObserver.swift"
click node_mutator "https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartAPIMutator.swift"

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_bundle,node_fixtureprocessor,node_importer,node_renderer,node_macro,node_inference,node_generator,node_models toneBlue
class node_endpoint,node_query,node_client toneAmber
class node_loader,node_strategy,node_view,node_openapi,node_service toneMint
class node_cache,node_auth,node_retry,node_coalescer,node_observer,node_mutator toneRose
class node_developer,node_json toneIndigo
```

## Components

### Schema generation

- [smartapi-bundle](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/smartapi-bundle/SmartAPIBundle.swift): `Sources/smartapi-bundle/SmartAPIBundle.swift`
- [Fixture processor](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/smartapi-bundle/FixtureProcessor.swift): `Sources/smartapi-bundle/FixtureProcessor.swift`
- [OpenAPI importer](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPIImporter/OpenAPIImporter.swift): `Sources/SmartAPIImporter/OpenAPIImporter.swift`
- [Wrapper renderer](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPIImporter/WrapperRenderer.swift): `Sources/SmartAPIImporter/WrapperRenderer.swift`
- [@SmartAPI macro](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPIMacros/SmartAPIMacro.swift): `Sources/SmartAPIMacros/SmartAPIMacro.swift`
- [JSON inference](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPIMacros/JSONInference.swift): `Sources/SmartAPIMacros/JSONInference.swift`
- [Code generator](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPIMacros/CodeGenerator.swift): `Sources/SmartAPIMacros/CodeGenerator.swift`
- [Typed models](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPIMacros/CodeGenerator.swift): `Sources/SmartAPIMacros/CodeGenerator.swift`

### API runtime

- [Endpoint catalog](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartEndpoint.swift): `Sources/SmartAPI/SmartEndpoint.swift`
- [Request query](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartQuery.swift): `Sources/SmartAPI/SmartQuery.swift`
- [HTTP client](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartClient.swift): `Sources/SmartAPI/SmartClient.swift`

### Pagination and UI

- [Paginated loader](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/PaginatedLoader.swift): `Sources/SmartAPI/PaginatedLoader.swift`
- [Pagination strategy](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/PaginationStrategy.swift): `Sources/SmartAPI/PaginationStrategy.swift`
- [SwiftUI views](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartView.swift): `Sources/SmartAPI/SmartView.swift`

### Production features

- [Response cache](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartCache.swift): `Sources/SmartAPI/SmartCache.swift`
- [Authorization provider](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/AuthorizationProvider.swift): `Sources/SmartAPI/AuthorizationProvider.swift`
- [Retry policy](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/RetryPolicy.swift): `Sources/SmartAPI/RetryPolicy.swift`
- [Request coalescer](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/RequestCoalescer.swift): `Sources/SmartAPI/RequestCoalescer.swift`
- [Request observer](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartAPIObserver.swift): `Sources/SmartAPI/SmartAPIObserver.swift`
- [Model mutator](https://github.com/abhisheksuryawanshi/smartapi/blob/main/Sources/SmartAPI/SmartAPIMutator.swift): `Sources/SmartAPI/SmartAPIMutator.swift`

### Other components

- **App developer**
- **JSON sample**
- **OpenAPI spec**
- **API service**

## Connections

- App developer → JSON sample: provides sample
- App developer → OpenAPI spec: provides spec
- JSON sample → @SmartAPI macro: annotates model
- JSON sample → smartapi-bundle: fixture input
- smartapi-bundle → Fixture processor: dispatches fixtures
- Fixture processor → Wrapper renderer: renders wrapper
- OpenAPI spec → smartapi-bundle: spec input
- smartapi-bundle → OpenAPI importer: dispatches import
- OpenAPI importer → Wrapper renderer: renders wrappers
- Wrapper renderer → @SmartAPI macro: emits annotation
- @SmartAPI macro → JSON inference: infers schema
- @SmartAPI macro → Code generator: generates declarations
- JSON inference → Code generator: supplies type tree
- Code generator → Typed models: emits models
- Typed models → Endpoint catalog: types responses
- App developer → Endpoint catalog: configures endpoints
- Endpoint catalog → HTTP client: calls endpoint
- App developer → Request query: configures request
- Request query → HTTP client: describes request
- HTTP client → API service: sends HTTP
- API service → HTTP client: returns response
- Paginated loader → HTTP client: fetches pages
- Paginated loader → Pagination strategy: advances state
- Pagination strategy → Paginated loader: supplies page rules
- SwiftUI views → Paginated loader: loads items
- HTTP client → Authorization provider: gets credentials
- HTTP client → Retry policy: applies retries
- HTTP client → Request coalescer: coalesces reads
- Paginated loader → Response cache: uses cache
- HTTP client → Request observer: reports activity
- Model mutator → HTTP client: sends mutations
