Skip to content

AINewsTracker

Web APIAPIDocker
PythonFastAPIMongoDBRedisPoetryPytest

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

Source code · Published documentation · Interactive GitDiagram · Français

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.

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

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.

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.

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

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.

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.

Code structure

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

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.

Sources