# tryswiftai/financialanalyst architecture

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

- Interactive diagram: https://gitdiagram.com/tryswiftai/financialanalyst
- Repository: https://github.com/tryswiftai/financialanalyst

## Overview

Financial Analyst is an iOS app for requesting AI-generated financial analysis of public companies. Users choose a company and timeframe, optionally add a question, and start an analysis; the analysis screen builds a prompt, streams a response from Perplexity, decodes the incoming content, and displays financial metrics, growth, highlights, and source links. The graph follows those request and presentation stages and includes the supporting input and response models. Some presentation modules are unsampled; their links are included only where the excerpts or source index show their use.

Main entry points: [`FinancialAnalyst/Views/AnalysisView/AnalysisView.swift`](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/AnalysisView.swift) (Analysis workflow), [`FinancialAnalyst/ContentView.swift`](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/ContentView.swift) (Home screen), [`FinancialAnalyst/Models/InputForm.swift`](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Models/InputForm.swift) (Prompt builder), [`FinancialAnalyst/Views/AnalysisView/MetricsGrid.swift`](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/MetricsGrid.swift) (Metrics grid)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["App experience"]
  node_app["App entry"]
  node_content["Home screen<br/>[ContentView.swift]"]
  node_input_view["Input form"]
end

subgraph group_request["Analysis request"]
  node_input_form["Prompt builder<br/>[InputForm.swift]"]
  node_analysis_view["Analysis workflow<br/>[AnalysisView.swift]"]
  node_perplexity["Perplexity client"]
end

subgraph group_domain["Analysis data"]
  node_company["Company choices<br/>[Company.swift]"]
  node_timeframe["Timeframe choices<br/>[Timeframe.swift]"]
  node_generated["Streamed response model"]
end

subgraph group_results["Results presentation"]
  node_company_header["Company header"]
  node_metrics_grid["Metrics grid<br/>[MetricsGrid.swift]"]
  node_metric["Metric display<br/>[MetricView.swift]"]
  node_growth["Revenue growth"]
  node_highlights["Key highlights"]
  node_search_results["Source results"]
  node_search_row["Source link row"]
end

node_user(("User"))
node_api{{"Perplexity API"}}

node_app -->|"launches"| node_content
node_user -.->|"uses"| node_content
node_content -->|"shows"| node_input_view
node_content -->|"opens"| node_analysis_view
node_input_view -->|"edits"| node_input_form
node_input_form -->|"uses choices"| node_company
node_input_form -->|"uses choices"| node_timeframe
node_analysis_view -->|"builds prompt"| node_input_form
node_analysis_view -->|"requests stream"| node_perplexity
node_perplexity -->|"streams request"| node_api
node_analysis_view -->|"decodes chunks"| node_generated
node_analysis_view -->|"renders"| node_company_header
node_analysis_view -->|"renders"| node_metrics_grid
node_analysis_view -->|"renders"| node_growth
node_analysis_view -->|"renders"| node_highlights
node_analysis_view -->|"renders"| node_search_results
node_metrics_grid -->|"displays metrics"| node_generated
node_metrics_grid -->|"renders"| node_metric
node_search_results -->|"displays sources"| node_generated
node_search_results -->|"renders"| node_search_row

click node_app "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/FinancialAnalystApp.swift"
click node_content "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/ContentView.swift"
click node_input_view "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/InputFormView.swift"
click node_input_form "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Models/InputForm.swift"
click node_company "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Models/Company.swift"
click node_timeframe "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Models/Timeframe.swift"
click node_analysis_view "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/AnalysisView.swift"
click node_perplexity "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/API/PerplexityClient.swift"
click node_generated "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Models/GeneratedFinancialAnalysis.swift"
click node_company_header "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/CompanyHeaderView.swift"
click node_metrics_grid "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/MetricsGrid.swift"
click node_metric "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/MetricView.swift"
click node_growth "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/RevenueGrowthView.swift"
click node_highlights "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/KeyHighlightsView.swift"
click node_search_results "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/SearchResultsView.swift"
click node_search_row "https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/SearchResultRowView.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_app,node_content,node_input_view,node_user toneBlue
class node_input_form,node_analysis_view,node_perplexity toneAmber
class node_company,node_timeframe,node_generated,node_api toneMint
class node_company_header,node_metrics_grid,node_metric,node_growth,node_highlights,node_search_results,node_search_row toneRose
```

## Components

### App experience

- [App entry](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/FinancialAnalystApp.swift): `FinancialAnalyst/FinancialAnalystApp.swift`
- [Home screen](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/ContentView.swift): `FinancialAnalyst/ContentView.swift`
- [Input form](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/InputFormView.swift): `FinancialAnalyst/Views/InputFormView.swift`

### Analysis request

- [Prompt builder](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Models/InputForm.swift): `FinancialAnalyst/Models/InputForm.swift`
- [Analysis workflow](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/AnalysisView.swift): `FinancialAnalyst/Views/AnalysisView/AnalysisView.swift`
- [Perplexity client](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/API/PerplexityClient.swift): `FinancialAnalyst/API/PerplexityClient.swift`

### Analysis data

- [Company choices](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Models/Company.swift): `FinancialAnalyst/Models/Company.swift`
- [Timeframe choices](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Models/Timeframe.swift): `FinancialAnalyst/Models/Timeframe.swift`
- [Streamed response model](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Models/GeneratedFinancialAnalysis.swift): `FinancialAnalyst/Models/GeneratedFinancialAnalysis.swift`

### Results presentation

- [Company header](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/CompanyHeaderView.swift): `FinancialAnalyst/Views/AnalysisView/CompanyHeaderView.swift`
- [Metrics grid](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/MetricsGrid.swift): `FinancialAnalyst/Views/AnalysisView/MetricsGrid.swift`
- [Metric display](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/MetricView.swift): `FinancialAnalyst/Views/AnalysisView/MetricView.swift`
- [Revenue growth](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/RevenueGrowthView.swift): `FinancialAnalyst/Views/AnalysisView/RevenueGrowthView.swift`
- [Key highlights](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/KeyHighlightsView.swift): `FinancialAnalyst/Views/AnalysisView/KeyHighlightsView.swift`
- [Source results](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/SearchResultsView.swift): `FinancialAnalyst/Views/AnalysisView/SearchResultsView.swift`
- [Source link row](https://github.com/tryswiftai/financialanalyst/blob/main/FinancialAnalyst/Views/AnalysisView/SearchResultRowView.swift): `FinancialAnalyst/Views/AnalysisView/SearchResultRowView.swift`

### Other components

- **User**
- **Perplexity API**

## Connections

- App entry → Home screen: launches (evidence: `FinancialAnalyst/FinancialAnalystApp.swift`)
- User → Home screen: uses
- Home screen → Input form: shows (evidence: `FinancialAnalyst/ContentView.swift`)
- Home screen → Analysis workflow: opens (evidence: `FinancialAnalyst/ContentView.swift`)
- Input form → Prompt builder: edits (evidence: `FinancialAnalyst/Views/InputFormView.swift`)
- Prompt builder → Company choices: uses choices (evidence: `FinancialAnalyst/Models/InputForm.swift`)
- Prompt builder → Timeframe choices: uses choices (evidence: `FinancialAnalyst/Models/InputForm.swift`)
- Analysis workflow → Prompt builder: builds prompt (evidence: `FinancialAnalyst/Views/AnalysisView/AnalysisView.swift`)
- Analysis workflow → Perplexity client: requests stream (evidence: `FinancialAnalyst/Views/AnalysisView/AnalysisView.swift`)
- Perplexity client → Perplexity API: streams request (evidence: `FinancialAnalyst/API/PerplexityClient.swift`)
- Analysis workflow → Streamed response model: decodes chunks (evidence: `FinancialAnalyst/Views/AnalysisView/AnalysisView.swift`)
- Analysis workflow → Company header: renders (evidence: `FinancialAnalyst/Views/AnalysisView/AnalysisView.swift`)
- Analysis workflow → Metrics grid: renders (evidence: `FinancialAnalyst/Views/AnalysisView/AnalysisView.swift`)
- Analysis workflow → Revenue growth: renders (evidence: `FinancialAnalyst/Views/AnalysisView/AnalysisView.swift`)
- Analysis workflow → Key highlights: renders (evidence: `FinancialAnalyst/Views/AnalysisView/AnalysisView.swift`)
- Analysis workflow → Source results: renders (evidence: `FinancialAnalyst/Views/AnalysisView/AnalysisView.swift`)
- Metrics grid → Streamed response model: displays metrics (evidence: `FinancialAnalyst/Views/AnalysisView/MetricsGrid.swift`)
- Metrics grid → Metric display: renders (evidence: `FinancialAnalyst/Views/AnalysisView/MetricsGrid.swift`)
- Source results → Streamed response model: displays sources (evidence: `FinancialAnalyst/Views/AnalysisView/SearchResultsView.swift`)
- Source results → Source link row: renders (evidence: `FinancialAnalyst/Views/AnalysisView/SearchResultsView.swift`)
