# fern-api/fern architecture

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

- Interactive diagram: https://gitdiagram.com/fern-api/fern
- Repository: https://github.com/fern-api/fern

## Overview

Fern turns API definitions into generated SDKs and other artifacts; its README’s main workflow is to initialize a project with an API specification and run `fern generate`. The repository also contains a Rust CLI generator runtime and documents hosted API documentation and AI Search. The graph separates those product capabilities from the sampled SDK-generation pipeline. Some documented capabilities lack implementation excerpts here, so their internal links are omitted rather than inferred.

Main entry points: [`generators/cli/sdk/src/openapi/app.rs`](https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/openapi/app.rs) (Generated API CLI), [`generators/cli/src/runPipeline.ts`](https://github.com/fern-api/fern/blob/main/generators/cli/src/runPipeline.ts) (SDK pipeline), [`packages/cli/cli-v2/src/sdk/generator/GeneratorPipeline.ts`](https://github.com/fern-api/fern/blob/main/packages/cli/cli-v2/src/sdk/generator/GeneratorPipeline.ts) (Fern CLI), [`generators/cli/sdk/src/openapi/parser.rs`](https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/openapi/parser.rs) (OpenAPI parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Generation workflow"]
  node_api_definition["API definition"]
  node_fern_cli["Fern CLI"]
  node_gen_pipeline["SDK pipeline<br/>[runPipeline.ts]"]
  node_sdk_template["SDK template"]
  node_generated_sdk["Generated SDK"]
  node_post_generation["Post-generation"]
end

subgraph group_generators["Generator engines"]
  node_shared_base["Generator base"]
  node_language_generators["Language SDK generators"]
  node_cli_generator["CLI generator"]
  node_spec_generators["Spec generators"]
end

subgraph group_cli_runtime["Generated CLI runtime"]
  node_generated_cli["Generated API CLI<br/>[app.rs]"]
  node_openapi_parser["OpenAPI parser<br/>[parser.rs]"]
  node_api_model["API model<br/>[discovery.rs]"]
  node_command_builder["Command builder<br/>[commands.rs]"]
  node_request_executor["Request executor<br/>[executor.rs]"]
  node_auth["Authentication<br/>[mod.rs]"]
  node_http["HTTP client<br/>[http.rs]"]
  node_profiles[("Request profiles<br/>[mod.rs]")]
end

subgraph group_platform["Developer platform"]
  node_docs["API documentation"]
  node_ai_search["AI Search"]
end

node_developer(("API developer"))
node_cli_user(("CLI user"))

node_developer -->|"defines API"| node_api_definition
node_developer -->|"runs generation"| node_fern_cli
node_api_definition -->|"provides input"| node_fern_cli
node_fern_cli -.->|"invokes pipeline"| node_gen_pipeline
node_gen_pipeline -->|"copies template"| node_sdk_template
node_gen_pipeline -->|"generates SDK"| node_generated_sdk
node_gen_pipeline -.->|"runs follow-up"| node_post_generation
node_shared_base -.->|"supports generation"| node_language_generators
node_developer -->|"builds docs"| node_docs
node_developer -->|"offers search"| node_ai_search
node_cli_user -.->|"invokes commands"| node_generated_cli
node_generated_cli -.->|"loads spec"| node_openapi_parser
node_openapi_parser -.->|"produces model"| node_api_model
node_generated_cli -.->|"builds commands"| node_command_builder
node_generated_cli -.->|"dispatches request"| node_request_executor
node_generated_cli -.->|"configures auth"| node_auth
node_generated_cli -.->|"configures profiles"| node_profiles
node_request_executor -.->|"sends requests"| node_http
node_developer -->|"exports OpenAPI"| node_spec_generators
node_developer -->|"selects SDK"| node_language_generators

click node_fern_cli "https://github.com/fern-api/fern/blob/main/packages/cli/cli-v2/src/sdk/generator/GeneratorPipeline.ts"
click node_gen_pipeline "https://github.com/fern-api/fern/blob/main/generators/cli/src/runPipeline.ts"
click node_sdk_template "https://github.com/fern-api/fern/tree/main/generators/cli"
click node_post_generation "https://github.com/fern-api/fern/blob/main/packages/generator-cli/src/pipeline/PostGenerationPipeline.ts"
click node_shared_base "https://github.com/fern-api/fern/tree/main/generators/base/src"
click node_language_generators "https://github.com/fern-api/fern/tree/main/generators"
click node_cli_generator "https://github.com/fern-api/fern/tree/main/generators/cli/src"
click node_spec_generators "https://github.com/fern-api/fern/tree/main/generators/openapi"
click node_generated_cli "https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/openapi/app.rs"
click node_openapi_parser "https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/openapi/parser.rs"
click node_api_model "https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/openapi/discovery.rs"
click node_command_builder "https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/openapi/commands.rs"
click node_request_executor "https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/openapi/executor.rs"
click node_auth "https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/auth/mod.rs"
click node_http "https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/http.rs"
click node_profiles "https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/profiles/mod.rs"

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_api_definition,node_fern_cli,node_gen_pipeline,node_sdk_template,node_generated_sdk,node_post_generation,node_cli_user toneBlue
class node_shared_base,node_language_generators,node_cli_generator,node_spec_generators toneAmber
class node_generated_cli,node_openapi_parser,node_api_model,node_command_builder,node_request_executor,node_auth,node_http,node_profiles,node_developer toneMint
class node_docs,node_ai_search toneRose
```

## Components

### Generation workflow

- **API definition**
- [Fern CLI](https://github.com/fern-api/fern/blob/main/packages/cli/cli-v2/src/sdk/generator/GeneratorPipeline.ts): `packages/cli/cli-v2/src/sdk/generator/GeneratorPipeline.ts`
- [SDK pipeline](https://github.com/fern-api/fern/blob/main/generators/cli/src/runPipeline.ts): `generators/cli/src/runPipeline.ts`
- [SDK template](https://github.com/fern-api/fern/tree/main/generators/cli): `generators/cli`
- **Generated SDK**
- [Post-generation](https://github.com/fern-api/fern/blob/main/packages/generator-cli/src/pipeline/PostGenerationPipeline.ts): `packages/generator-cli/src/pipeline/PostGenerationPipeline.ts`

### Generator engines

- [Generator base](https://github.com/fern-api/fern/tree/main/generators/base/src): `generators/base/src`
- [Language SDK generators](https://github.com/fern-api/fern/tree/main/generators): `generators`
- [CLI generator](https://github.com/fern-api/fern/tree/main/generators/cli/src): `generators/cli/src`
- [Spec generators](https://github.com/fern-api/fern/tree/main/generators/openapi): `generators/openapi`

### Generated CLI runtime

- [Generated API CLI](https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/openapi/app.rs): `generators/cli/sdk/src/openapi/app.rs`
- [OpenAPI parser](https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/openapi/parser.rs): `generators/cli/sdk/src/openapi/parser.rs`
- [API model](https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/openapi/discovery.rs): `generators/cli/sdk/src/openapi/discovery.rs`
- [Command builder](https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/openapi/commands.rs): `generators/cli/sdk/src/openapi/commands.rs`
- [Request executor](https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/openapi/executor.rs): `generators/cli/sdk/src/openapi/executor.rs`
- [Authentication](https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/auth/mod.rs): `generators/cli/sdk/src/auth/mod.rs`
- [HTTP client](https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/http.rs): `generators/cli/sdk/src/http.rs`
- [Request profiles](https://github.com/fern-api/fern/blob/main/generators/cli/sdk/src/profiles/mod.rs): `generators/cli/sdk/src/profiles/mod.rs`

### Developer platform

- **API documentation**
- **AI Search**

### Other components

- **API developer**
- **CLI user**

## Connections

- API developer → API definition: defines API (evidence: `README.md`)
- API developer → Fern CLI: runs generation (evidence: `README.md`)
- API definition → Fern CLI: provides input (evidence: `README.md`)
- Fern CLI → SDK pipeline: invokes pipeline
- SDK pipeline → SDK template: copies template (evidence: `generators/cli/src/runPipeline.ts`)
- SDK pipeline → Generated SDK: generates SDK (evidence: `generators/cli/src/runPipeline.ts`)
- SDK pipeline → Post-generation: runs follow-up
- Generator base → Language SDK generators: supports generation
- API developer → API documentation: builds docs (evidence: `README.md`)
- API developer → AI Search: offers search (evidence: `README.md`)
- CLI user → Generated API CLI: invokes commands
- Generated API CLI → OpenAPI parser: loads spec (evidence: `generators/cli/sdk/src/openapi/app.rs`)
- OpenAPI parser → API model: produces model (evidence: `generators/cli/sdk/src/openapi/parser.rs`)
- Generated API CLI → Command builder: builds commands (evidence: `generators/cli/sdk/src/openapi/app.rs`)
- Generated API CLI → Request executor: dispatches request (evidence: `generators/cli/sdk/src/openapi/app.rs`)
- Generated API CLI → Authentication: configures auth (evidence: `generators/cli/sdk/src/openapi/app.rs`)
- Generated API CLI → Request profiles: configures profiles (evidence: `generators/cli/sdk/src/openapi/app.rs`)
- Request executor → HTTP client: sends requests
- API developer → Spec generators: exports OpenAPI (evidence: `README.md`)
- API developer → Language SDK generators: selects SDK (evidence: `README.md`)
