# yigitcemakbas/yarn architecture

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

- Interactive diagram: https://gitdiagram.com/yigitcemakbas/yarn
- Repository: https://github.com/yigitcemakbas/yarn

## Overview

yarn is an in-house Finnhub-compatible market-data API backed by a database that a separate worker refreshes. The principal flow is a client request to a Finnhub-shaped route, database lookup, and JSON response; unseen tickers can trigger warming. In parallel, scheduled jobs gather SEC, investor-relations, newswire, and GDELT data, transform it into company, earnings, recommendation, and news records, and persist it. The graph preserves README capabilities and indexed modules; some internal links rely on the SOURCE INDEX rather than inspected implementation excerpts.

Main entry points: [`app/jobs/scheduler.py`](https://github.com/yigitcemakbas/yarn/blob/main/app/jobs/scheduler.py) (Refresh scheduler), [`app/pipelines/news.py`](https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/news.py) (News ingestion), [`app/compat/finnhub/routes.py`](https://github.com/yigitcemakbas/yarn/blob/main/app/compat/finnhub/routes.py) (Finnhub routes), [`app/pipelines/earnings_dates.py`](https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/earnings_dates.py) (Date confirmation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API compatibility"]
  node_finnhub_routes["Finnhub routes<br/>[routes.py]"]
  node_auth["API authentication<br/>[auth.py]"]
  node_app_entry["API application<br/>[main.py]"]
end

subgraph group_worker["Refresh orchestration"]
  node_worker_scheduler["Refresh scheduler<br/>[scheduler.py]"]
  node_warmup["On-demand warming<br/>[warmup.py]"]
end

subgraph group_pipelines["Market data pipelines"]
  node_company_pipeline["Company directory<br/>[companies.py]"]
  node_earnings_pipeline["Reported earnings<br/>[earnings.py]"]
  node_earnings_dates["Date confirmation<br/>[earnings_dates.py]"]
  node_news_pipeline["News ingestion<br/>[news.py]"]
  node_press_pipeline["Press releases<br/>[press_release.py]"]
  node_recommendations["Rating trends<br/>[recommendations.py]"]
end

subgraph group_sources["Data sources"]
  node_sec_source["SEC EDGAR<br/>[sec.py]"]
  node_ir_source["IR calendars<br/>[ir_events.py]"]
  node_gdelt_source["GDELT news<br/>[gdelt.py]"]
  node_feeds_source["Newswire feeds<br/>[feeds.py]"]
  node_article_source["Article pages<br/>[news_article.py]"]
  node_scraper["Scraper policy<br/>[base_scraper.py]"]
  node_rate_limiter["Host rate limiter<br/>[rate_limit.py]"]
end

subgraph group_storage["Persistence"]
  node_db_session["Database sessions<br/>[session.py]"]
  node_market_store[("Market data tables<br/>[__init__.py]")]
end

node_loom(("Loom client"))
node_database[("PostgreSQL")]

node_loom -->|"requests"| node_finnhub_routes
node_app_entry -->|"registers"| node_finnhub_routes
node_app_entry -->|"configures"| node_auth
node_finnhub_routes -->|"opens session"| node_db_session
node_finnhub_routes -->|"queries"| node_market_store
node_finnhub_routes -->|"warms ticker"| node_warmup
node_finnhub_routes -->|"loads trends"| node_recommendations
node_db_session -->|"connects"| node_database
node_worker_scheduler -->|"syncs directory"| node_company_pipeline
node_worker_scheduler -->|"refreshes earnings"| node_earnings_pipeline
node_worker_scheduler -->|"refreshes dates"| node_earnings_dates
node_worker_scheduler -.->|"polls news"| node_news_pipeline
node_worker_scheduler -->|"polls filings"| node_sec_source
node_worker_scheduler -->|"rotates company news"| node_gdelt_source
node_worker_scheduler -->|"refreshes calendars"| node_ir_source
node_company_pipeline -->|"reads SEC data"| node_sec_source
node_earnings_pipeline -->|"reads filings"| node_sec_source
node_earnings_pipeline -->|"uses releases"| node_press_pipeline
node_earnings_dates -->|"builds on events"| node_earnings_pipeline
node_earnings_dates -->|"reads calendars"| node_ir_source
node_earnings_dates -->|"checks filings"| node_sec_source
node_news_pipeline -->|"ingests articles"| node_gdelt_source
node_news_pipeline -->|"ingests releases"| node_feeds_source
node_news_pipeline -->|"fetches descriptions"| node_article_source
node_news_pipeline -->|"records announcements"| node_earnings_dates
node_ir_source -->|"uses scraper"| node_scraper
node_article_source -->|"uses scraper"| node_scraper
node_scraper -->|"throttles requests"| node_rate_limiter
node_sec_source -->|"throttles requests"| node_rate_limiter
node_feeds_source -->|"throttles requests"| node_rate_limiter
node_gdelt_source -->|"throttles requests"| node_rate_limiter
node_company_pipeline -->|"updates records"| node_market_store
node_earnings_pipeline -->|"stores events"| node_market_store
node_earnings_dates -->|"updates dates"| node_market_store
node_news_pipeline -->|"stores articles"| node_market_store
node_recommendations -->|"reads ratings"| node_market_store

click node_finnhub_routes "https://github.com/yigitcemakbas/yarn/blob/main/app/compat/finnhub/routes.py"
click node_auth "https://github.com/yigitcemakbas/yarn/blob/main/app/compat/finnhub/auth.py"
click node_app_entry "https://github.com/yigitcemakbas/yarn/blob/main/app/main.py"
click node_worker_scheduler "https://github.com/yigitcemakbas/yarn/blob/main/app/jobs/scheduler.py"
click node_warmup "https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/warmup.py"
click node_company_pipeline "https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/companies.py"
click node_earnings_pipeline "https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/earnings.py"
click node_earnings_dates "https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/earnings_dates.py"
click node_news_pipeline "https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/news.py"
click node_press_pipeline "https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/press_release.py"
click node_recommendations "https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/recommendations.py"
click node_sec_source "https://github.com/yigitcemakbas/yarn/blob/main/app/sources/sec.py"
click node_ir_source "https://github.com/yigitcemakbas/yarn/blob/main/app/sources/ir_events.py"
click node_gdelt_source "https://github.com/yigitcemakbas/yarn/blob/main/app/sources/gdelt.py"
click node_feeds_source "https://github.com/yigitcemakbas/yarn/blob/main/app/sources/feeds.py"
click node_article_source "https://github.com/yigitcemakbas/yarn/blob/main/app/sources/news_article.py"
click node_scraper "https://github.com/yigitcemakbas/yarn/blob/main/app/sources/base_scraper.py"
click node_rate_limiter "https://github.com/yigitcemakbas/yarn/blob/main/app/sources/rate_limit.py"
click node_db_session "https://github.com/yigitcemakbas/yarn/blob/main/app/db/session.py"
click node_market_store "https://github.com/yigitcemakbas/yarn/blob/main/app/models/__init__.py"

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_finnhub_routes,node_auth,node_app_entry,node_loom toneBlue
class node_worker_scheduler,node_warmup,node_database toneAmber
class node_company_pipeline,node_earnings_pipeline,node_earnings_dates,node_news_pipeline,node_press_pipeline,node_recommendations toneMint
class node_sec_source,node_ir_source,node_gdelt_source,node_feeds_source,node_article_source,node_scraper,node_rate_limiter toneRose
class node_db_session,node_market_store toneIndigo
```

## Components

### API compatibility

- [Finnhub routes](https://github.com/yigitcemakbas/yarn/blob/main/app/compat/finnhub/routes.py): `app/compat/finnhub/routes.py`
- [API authentication](https://github.com/yigitcemakbas/yarn/blob/main/app/compat/finnhub/auth.py): `app/compat/finnhub/auth.py`
- [API application](https://github.com/yigitcemakbas/yarn/blob/main/app/main.py): `app/main.py`

### Refresh orchestration

- [Refresh scheduler](https://github.com/yigitcemakbas/yarn/blob/main/app/jobs/scheduler.py): `app/jobs/scheduler.py`
- [On-demand warming](https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/warmup.py): `app/pipelines/warmup.py`

### Market data pipelines

- [Company directory](https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/companies.py): `app/pipelines/companies.py`
- [Reported earnings](https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/earnings.py): `app/pipelines/earnings.py`
- [Date confirmation](https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/earnings_dates.py): `app/pipelines/earnings_dates.py`
- [News ingestion](https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/news.py): `app/pipelines/news.py`
- [Press releases](https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/press_release.py): `app/pipelines/press_release.py`
- [Rating trends](https://github.com/yigitcemakbas/yarn/blob/main/app/pipelines/recommendations.py): `app/pipelines/recommendations.py`

### Data sources

- [SEC EDGAR](https://github.com/yigitcemakbas/yarn/blob/main/app/sources/sec.py): `app/sources/sec.py`
- [IR calendars](https://github.com/yigitcemakbas/yarn/blob/main/app/sources/ir_events.py): `app/sources/ir_events.py`
- [GDELT news](https://github.com/yigitcemakbas/yarn/blob/main/app/sources/gdelt.py): `app/sources/gdelt.py`
- [Newswire feeds](https://github.com/yigitcemakbas/yarn/blob/main/app/sources/feeds.py): `app/sources/feeds.py`
- [Article pages](https://github.com/yigitcemakbas/yarn/blob/main/app/sources/news_article.py): `app/sources/news_article.py`
- [Scraper policy](https://github.com/yigitcemakbas/yarn/blob/main/app/sources/base_scraper.py): `app/sources/base_scraper.py`
- [Host rate limiter](https://github.com/yigitcemakbas/yarn/blob/main/app/sources/rate_limit.py): `app/sources/rate_limit.py`

### Persistence

- [Database sessions](https://github.com/yigitcemakbas/yarn/blob/main/app/db/session.py): `app/db/session.py`
- [Market data tables](https://github.com/yigitcemakbas/yarn/blob/main/app/models/__init__.py): `app/models/__init__.py`

### Other components

- **Loom client**
- **PostgreSQL**

## Connections

- Loom client → Finnhub routes: requests (evidence: `README.md`)
- API application → Finnhub routes: registers (evidence: `app/main.py`)
- API application → API authentication: configures (evidence: `app/main.py`)
- Finnhub routes → Database sessions: opens session (evidence: `app/compat/finnhub/routes.py`)
- Finnhub routes → Market data tables: queries (evidence: `app/compat/finnhub/routes.py`)
- Finnhub routes → On-demand warming: warms ticker (evidence: `app/compat/finnhub/routes.py`)
- Finnhub routes → Rating trends: loads trends (evidence: `app/compat/finnhub/routes.py`)
- Database sessions → PostgreSQL: connects (evidence: `app/db/session.py`)
- Refresh scheduler → Company directory: syncs directory (evidence: `app/jobs/scheduler.py`)
- Refresh scheduler → Reported earnings: refreshes earnings (evidence: `app/jobs/scheduler.py`)
- Refresh scheduler → Date confirmation: refreshes dates (evidence: `app/jobs/scheduler.py`)
- Refresh scheduler → News ingestion: polls news (evidence: `app/jobs/scheduler.py`)
- Refresh scheduler → SEC EDGAR: polls filings (evidence: `app/jobs/scheduler.py`)
- Refresh scheduler → GDELT news: rotates company news (evidence: `app/jobs/scheduler.py`)
- Refresh scheduler → IR calendars: refreshes calendars (evidence: `app/jobs/scheduler.py`)
- Company directory → SEC EDGAR: reads SEC data (evidence: `app/pipelines/companies.py`)
- Reported earnings → SEC EDGAR: reads filings (evidence: `app/pipelines/earnings.py`)
- Reported earnings → Press releases: uses releases (evidence: `app/pipelines/earnings.py`)
- Date confirmation → Reported earnings: builds on events (evidence: `app/pipelines/earnings_dates.py`)
- Date confirmation → IR calendars: reads calendars (evidence: `app/pipelines/earnings_dates.py`)
- Date confirmation → SEC EDGAR: checks filings (evidence: `app/pipelines/earnings_dates.py`)
- News ingestion → GDELT news: ingests articles (evidence: `app/pipelines/news.py`)
- News ingestion → Newswire feeds: ingests releases (evidence: `app/pipelines/news.py`)
- News ingestion → Article pages: fetches descriptions (evidence: `app/pipelines/news.py`)
- News ingestion → Date confirmation: records announcements (evidence: `app/pipelines/news.py`)
- IR calendars → Scraper policy: uses scraper (evidence: `app/sources/ir_events.py`)
- Article pages → Scraper policy: uses scraper (evidence: `app/sources/news_article.py`)
- Scraper policy → Host rate limiter: throttles requests (evidence: `app/sources/base_scraper.py`)
- SEC EDGAR → Host rate limiter: throttles requests (evidence: `app/sources/sec.py`)
- Newswire feeds → Host rate limiter: throttles requests (evidence: `app/sources/feeds.py`)
- GDELT news → Host rate limiter: throttles requests (evidence: `app/sources/gdelt.py`)
- Company directory → Market data tables: updates records (evidence: `app/pipelines/companies.py`)
- Reported earnings → Market data tables: stores events (evidence: `app/pipelines/earnings.py`)
- Date confirmation → Market data tables: updates dates (evidence: `app/pipelines/earnings_dates.py`)
- News ingestion → Market data tables: stores articles (evidence: `app/pipelines/news.py`)
- Rating trends → Market data tables: reads ratings (evidence: `app/pipelines/recommendations.py`)
