Skip to content
Table of contents

AINewsTracker

AINewsTracker collects financial news, analyses article text and exposes the resulting data through FastAPI. A separate strategy path uses stored information for historical backtests.

Web APIAPIDocker
PythonFastAPIMongoDBRedisPoetryPytest
  • Updated

1. Overview

app/main.py assembles the service, registers the route groups and configures Redis caching. News processing moves through a service, text metrics and the article repository before reaching MongoDB.

The companion article, Following financial news through AINewsTracker, follows that path from an incoming feed to a stored article.

2. Use cases

FastAPI service from AlgoÉTS that collects financial news, scores it with FinBERT and stores it in MongoDB.

Use-case diagram for AINewsTracker: Fetch news from a source; Score article sentiment; Query news by company; Seed companies and news; Serve scored articlesAINewsTrackerFetch news from a sourceScore article sentimentQuery news by companySeed companies and newsServe scored articlesQuant analyst«system»News feeds and APIs«system»Backtesting service
People on the left, external systems on the right; each oval is a use case backed by the files cited below.
Fetch news from a source
Quant analystNews feeds and APIs

The /news routes pull the Financial Modeling Prep 8-K RSS feed, GNews or a named feed with feedparser, download each article's text and save it; limits above 10 run as background tasks.

Score article sentiment
Quant analyst

TextMetrics loads ProsusAI/finbert for sentiment, Jean-Baptiste/roberta-ticker for ticker extraction and distilbart-cnn-12-6 for summaries; GET /articles/{article_id}/score returns the stored score.

Query news by company
Quant analyst

/company stores tickers, and /articles/articles_by_company_id/{company_id} or POST /articles/articles_by_company_ids return the articles linked to one or more companies.

Seed companies and news
Quant analystNews feeds and APIs

POST /seed/seed_companies and /seed/seed_news start CompanySeeder and NewsSeeder in the background; NewsSeeder reads Financial Modeling Prep stock news with FMP_API_KEY and saves the articles to MongoDB.

Serve scored articles
Backtesting service

GET /v1/articles, protected by a Bearer service token (AINEWSTRACKER_SERVICE_TOKEN), returns articles filtered by symbols and time window with sentiment label, probabilities and model name, paged by cursor.

2.1. Scenario: Collect and query Apple news locally

  1. Copy .env.example to .env, set FMP_API_KEY, then run docker-compose up --build to start the API with MongoDB and Redis.
  2. Open http://localhost:8000/api/v1/docs and call POST /seed/seed_companies.
  3. Call POST /seed/seed_news; NewsSeeder reads Financial Modeling Prep stock news in the background and stores the scored articles.
  4. Read the stored articles with GET /articles/ and check one with GET /articles/{article_id}/score.
  5. From a backtesting service, call GET /v1/articles?symbols=AAPL with the Bearer service token.

Files readREADME.mdapp/main.pyapp/routers/news.pyapp/routers/article.pyapp/routers/seed.pyapp/routers/integration.pyapp/core/services/news.pyapp/core/services/metrics.pydocker-compose.ymldocs/tickertools-integration.mdapp/seed/news.py.env.example

3. Getting started

cp .env.example .env
pip install poetry
poetry shell
poetry install
poetry run pytest
poetry run uvicorn app.main:app --reload

FastAPI documentation is available at http://localhost:8000/api/v1/docs according to the project guide. Docker users can start the documented stack with:

docker-compose up --build

4. Repository guide

  • app/main.py creates the application, registers routers and configures caching.
  • app/routers/ defines news, article, company, user, seed and strategy endpoints.
  • app/core/services/ contains news processing and text metrics.
  • app/core/repo/ contains persistence operations grouped by domain.
  • app/models/ defines records accepted and returned by the service.
  • app/seed/ loads company and news data from external sources.
  • app/core/trading/strategy.py handles strategy requests.

5. Features

  • ingest news through RSS, GNews and configured feeds;
  • analyse sentiment, topics and ticker allocation;
  • manage article, company, news and user records;
  • seed company and news data;
  • execute strategy requests for one or more companies;
  • run through Poetry or Docker Compose.

6. Architecture

This view condenses the runtime boundaries verified by GitDiagram. The full interactive diagram expands the model and links components to their source.

flowchart TD
  Client(("API client")) --> App["FastAPI application<br/>app/main.py"]
  App --> Routes["Routers<br/>app/routers/"]
  Routes --> News["News processing<br/>app/core/services/news.py"]
  News --> Metrics["Text metrics<br/>app/core/services/metrics.py"]
  News --> Repos["Repositories<br/>app/core/repo/"]
  Routes --> Repos
  Repos --> Mongo[("MongoDB<br/>app/core/database/db.py")]
  App --> Redis[("Redis cache<br/>app/core/database/db.py")]
  Sources{{"Financial news sources"}} --> Seeders["Seeders<br/>app/seed/"]
  Seeders --> News
  Routes --> Strategy["Trading strategy<br/>app/core/trading/strategy.py"]
BoundaryResponsibilityEvidence
ApplicationFastAPI lifecycle, router registration and cache setupapp/main.py
HTTP interfaceNews, article, company, user, seed and strategy routesapp/routers/
AnalysisFeed processing and text metricsapp/core/services/news.py, app/core/services/metrics.py
Domain dataArticle, company, news and user modelsapp/models/
PersistenceMongoDB operations grouped by domainapp/core/repo/
OperationsData seeding and strategy executionapp/seed/, app/core/trading/strategy.py

7. API contract

AreaDocumented operations
NewsCreate and read news; fetch RSS, GNews and feed entries
ArticlesCreate, list, read and delete articles; read an article score
CompaniesCreate companies, list companies and find one by ticker
StrategiesExecute a strategy for one company or a submitted company list

The running FastAPI OpenAPI document is the authority for exact request and response schemas.

8. Deployment

The repository includes a root Dockerfile, a development docker-compose.yml and a separate deploy/ directory. Compose dependency ordering is a startup order, not a readiness guarantee.

9. Code structure

app/
├── main.py
├── core/{database,repo,services,telemetry,trading}/
├── models/
├── routers/
└── seed/
tests/
deploy/
monitoring/

10. Limits

  • Sentiment and topic labels are analytical inputs, not financial advice or proof of causation.
  • Historical backtests do not guarantee future performance.
  • External feeds and market APIs have their own credentials, availability and usage terms.
  • Endpoint details can change; current source and OpenAPI take precedence.

11. Sources

12. CI/CD pipeline

5 GitHub Actions workflows, 5 jobs. Each box is a job; double-bordered boxes publish or deploy, and arrows follow needs.

Mermaid Pipeline flow
flowchart LR
  subgraph wf0["Python application CD"]
    direction LR
    wf0_setup[["setup<br/>ubuntu-latest"]]
  end
  subgraph wf1["Python application CI"]
    direction LR
    wf1_setup["setup<br/>ubuntu-latest"]
  end
  subgraph wf2["CodeQL"]
    direction LR
    wf2_analyze["Analyze<br/>ubuntu-latest"]
  end
  subgraph wf3["Docker CI"]
    direction LR
    wf3_docker[["docker<br/>ubuntu-latest"]]
  end
  subgraph wf4["AINewsTracker Docs"]
    direction LR
    wf4_build_and_deploy[["build_and_deploy<br/>ubuntu-latest"]]
  end
  t0(["release"])
  t1(["pull request · push"])
  t2(["push · pull request · schedule"])
  t3(["push"])
  t4(["push · pull request · manual run"])
  d0[("Container registry")]
  d1[("GitHub Pages")]
  t0 --> wf0_setup
  wf0_setup -.-> d0
  t1 --> wf1_setup
  t2 --> wf2_analyze
  t3 --> wf3_docker
  wf3_docker -.-> d0
  t4 --> wf4_build_and_deploy
  wf4_build_and_deploy -.-> d1
Workflows, triggers, jobs and targets
WorkflowTriggersJobsPublishes to
Python application CD
.github/workflows/cd.yml
release
  • setup ubuntu-latest
    Checkout (GitHub) · Set up Python · Jimver/cuda-toolkit · Cache Python dependencies · Run poetry · Install dependencies
Container registry
Python application CI
.github/workflows/ci.yml
pull request, push
  • setup ubuntu-latest
    Checkout (GitHub) · Install system packages · Set up Python · Cache Python dependencies · Run poetry · Install CUDA
—
CodeQL
.github/workflows/codeql.yml
push, pull request, schedule
  • Analyze ubuntu-latest
    Checkout repository · Set up Python · Cache Python dependencies · Run image · Initialize CodeQL · Autobuild
—
Docker CI
.github/workflows/docker.yml
push
  • docker ubuntu-latest
    Set up QEMU · Set up Docker Buildx · Login to Docker Hub · Build and push
Container registry
AINewsTracker Docs
.github/workflows/docs.yml
push, pull request, manual run
  • build_and_deploy ubuntu-latest
    actions/checkout · Set up Python · Cache Python dependencies · Run poetry · Install project dependencies · Build mkdocs
GitHub Pages

Generated from the source at commit 74a8366.

13. Deployment diagram

Mermaid Deployment diagram
flowchart LR
  repo[("GitHub repository")]
  ci[["GitHub Actions<br/>5 workflows"]]
  image["Docker image<br/>FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10"]
  pub_Container_registry[("Container registry")]
  pub_GitHub_Pages[("GitHub Pages")]
  host_Vercel("Vercel<br/>vercel.json")
  host_MkDocs_site("Documentation site (MkDocs)<br/>mkdocs.yml")
  subgraph compose["Docker Compose"]
    svc_redis["redis"]
    svc_mongo["mongo"]
    svc_web["web"]
    svc_prometheus["prometheus"]
  end
  repo -->|"push or pull request"| ci
  ci -->|"docker build"| image
  image -->|"publishes"| pub_Container_registry
  ci -->|"publishes"| pub_GitHub_Pages
  ci -.->|"configured"| host_Vercel
  ci -.->|"configured"| host_MkDocs_site
  image -->|"docker compose up"| compose

14. External dependencies

127 declared packages (127 runtime, 0 development) in pyproject.toml, requirements.txt.

Package table 80 / 127
External dependencies
PackageVersionScopePurposeRegistry
fastapi^0.81.0runtimeWeb frameworkpypi.org
pydantic^1.10.8runtimeData validationpypi.org
python-multipart^0.0.6runtimeA streaming multipart parser for Pythonpypi.org
pymongo^4.3.3runtimeDatabase accesspypi.org
python-dotenv^0.19.2runtimeConfigurationpypi.org
uvicorn—runtimeApplication serverpypi.org
anyio^3.7.0runtimeHigh-level concurrency and networking framework on top of asyncio or Triopypi.org
aioredis^2.0.0runtimeDatabase accesspypi.org
configparser^5.3.0runtimeConfigurationpypi.org
contractions^0.1.73runtimeFixes contractions such as you're to you arepypi.org
fastapi_cache2^0.2.1runtimeCache for FastAPIpypi.org
fastapi_health^0.4.0runtimeHeath check on FastAPI applications.pypi.org
matplotlib^3.5.1runtimeChartspypi.org
openpyxl^3.1.1runtimeData analysispypi.org
pandas^1.5.3runtimeData analysispypi.org
pandas-ta^0.3.14bruntimeData analysispypi.org
prometheus-fastapi-instrumentator^5.9.1runtimeLogging and observabilitypypi.org
redis^4.5.1runtimeDatabase accesspypi.org
rich*runtimeCommand linepypi.org
structlog^23.1.0runtimeLogging and observabilitypypi.org
prometheus-client^0.17.0runtimeLogging and observabilitypypi.org
aiofiles^23.1.0runtimeFile support for asyncio.pypi.org
types-aiofiles^23.1.0.4runtimeType checkingpypi.org
slowapi^0.1.8runtimeA rate limiting extension for Starlette and Fastapipypi.org
asyncio^3.4.3runtimeDeprecated backport of asyncio; use the stdlib package insteadpypi.org
jose^1.0.0runtimeAuthentication and securitypypi.org
pyjwt^2.7.0runtimeAuthentication and securitypypi.org
python-jose^3.3.0runtimeJOSE implementation in Pythonpypi.org
passlib^1.7.4runtimecomprehensive password hashing framework supporting over 30 schemespypi.org
transformers^4.30.1runtimeMachine learning and AIpypi.org
torch^2.0.1runtimeMachine learning and AIpypi.org
motor^3.1.2runtimeDatabase accesspypi.org
requests^2.31.0runtimeHTTP clientpypi.org
beautifulsoup4^4.12.2runtimeScraping and parsingpypi.org
feedparser^6.0.10runtimeScraping and parsingpypi.org
types-redis^4.5.5.2runtimeType checkingpypi.org
spacy^3.5.3runtimeMachine learning and AIpypi.org
finnhub-python^2.4.18runtimeFinnhub APIpypi.org
aiohttp==3.8.4runtimeHTTP clientpypi.org
aiosignal==1.3.1runtimeaiosignal: a list of registered asynchronous callbackspypi.org
anyascii==0.3.2runtimeUnicode to ASCII transliterationpypi.org
async-timeout==4.0.2runtimeTimeout context manager for asyncio programspypi.org
attrs==23.1.0runtimeData validationpypi.org
blis==0.7.9runtimeThe Blis BLAS-like linear algebra library, as a self-contained C-extension.pypi.org
catalogue==2.0.8runtimeSuper lightweight function registries for your librarypypi.org
certifi==2023.5.7runtimePython package for providing Mozilla's CA Bundle.pypi.org
cffi==1.15.1runtimeForeign Function Interface for Python calling C code.pypi.org
charset-normalizer==3.1.0runtimeThe Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet.pypi.org
click==8.1.3runtimeCommand linepypi.org
colorama==0.4.6runtimeCommand linepypi.org
confection==0.0.4runtimeThe sweetest config system for Pythonpypi.org
contourpy==1.1.0runtimePython library for calculating contours of 2D quadrilateral gridspypi.org
cryptography==41.0.1runtimeAuthentication and securitypypi.org
cycler==0.11.0runtimeComposable style cyclespypi.org
cymem==2.0.7runtimeManage calls to calloc/free through Cythonpypi.org
deprecated==1.2.14runtimePython @deprecated decorator to deprecate old python classes, functions or methods.pypi.org
dnspython==2.3.0runtimeDNS toolkitpypi.org
ecdsa==0.18.0runtimeECDSA cryptographic signature library (pure python)pypi.org
et-xmlfile==1.1.0runtimeAn implementation of lxml.xmlfile for the standard librarypypi.org
exceptiongroup==1.1.1runtimeBackport of PEP 654 (exception groups)pypi.org
fastapi-cache2==0.2.1runtime—pypi.org
fastapi-health==0.4.0runtime—pypi.org
filelock==3.12.2runtimeA platform independent file lock.pypi.org
fonttools==4.40.0runtimeTools to manipulate font filespypi.org
frozenlist==1.3.3runtimeA list-like structure which implements collections.abc.MutableSequencepypi.org
fsspec==2023.6.0runtimeFile-system specificationpypi.org
h11==0.14.0runtimeA pure-Python, bring-your-own-I/O implementation of HTTP/1.1pypi.org
huggingface-hub==0.15.1runtimeMachine learning and AIpypi.org
idna==3.4runtimeInternationalized Domain Names in Applications (IDNA)pypi.org
importlib-resources==5.12.0runtimeRead resources from Python packagespypi.org
jinja2==3.1.2runtimeTemplatespypi.org
kiwisolver==1.4.4runtimeA fast implementation of the Cassowary constraint solverpypi.org
langcodes==3.3.0runtimeTools for labeling human languages with IETF language tagspypi.org
limits==3.5.0runtimeRate limiting utilitiespypi.org
markdown-it-py==3.0.0runtimePython port of markdown-it. Markdown parsing, done right!pypi.org
markupsafe==2.1.3runtimeSafely add untrusted strings to HTML/XML markup.pypi.org
mdurl==0.1.2runtimeMarkdown URL utilitiespypi.org
mpmath==1.3.0runtimePython library for arbitrary-precision floating-point arithmeticpypi.org
multidict==6.0.4runtime—pypi.org
murmurhash==1.0.9runtimeCython bindings for MurmurHashpypi.org

47 more packages are listed in the manifests.

15. Glossary

Repository

The versioned source files, configuration, and history of a project.

README

The repository’s entry document, usually covering its purpose and initial setup.

Dependency

A library, tool, or service that another component needs to build or run.

API

An interface through which software components exchange requests and results. An API does not have to use HTTP.

HTTP

A request-and-response protocol used by browsers and web services. A method, path, headers, and optional body describe a request.

Session

State kept across related requests, often to track a signed-in user. Authentication and permission checks remain separate concerns.

Container

An isolated process environment created from an image. Persistent data needs storage outside the container’s disposable filesystem.

Docker Compose

A configuration format and tool for starting related containers, networks, and volumes. Startup order alone does not guarantee service readiness.

Published port

A host port mapped to a service’s container port. Publishing a port can expose that service beyond its container network.

CLI

A text interface in which commands and arguments select operations. Exit codes let scripts detect success or failure.

Build

The steps that turn source files and dependencies into a runnable program or distributable artifact.

Mermaid

A text-based diagram language. Nodes and connections describe a model; the diagram itself does not execute the project.

Backend

An implementation behind a shared interface. Depending on context, it can mean a server-side service or a graphics, input, or storage implementation.

Database

A system for storing and querying structured records. Its schema, access rules, and persistence determine how the application can use that data.

16. References

  1. AlgoETS. (2026, November 5). AINewsTracker. [Software repository] github.com.
  2. Published documentation. (2026, November 5). [Web page] algoets.github.io.
  3. Interactive GitDiagram. (2026, November 5). [Web page] gitdiagram.com.
  4. AlgoETS. (2026, November 5). app/main.py. [Source file or documentation] github.com.
  5. AlgoETS. (2026, November 5). app/routers/news.py. [Source file or documentation] github.com.
  6. AlgoETS. (2026, November 5). app/core/services/news.py. [Source file or documentation] github.com.
  7. AlgoETS. (2026, November 5). app/core/services/metrics.py. [Source file or documentation] github.com.

Sources without a publication date show the date they were last checked, November 5, 2026. File links retain the inspected revision where available.