# aboelresh/gnip architecture

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

- Interactive diagram: https://gitdiagram.com/aboelresh/gnip
- Repository: https://github.com/aboelresh/gnip

## Overview

Global News Intelligence Platform collects RSS news, removes duplicates, analyzes articles, clusters coverage into stories, and creates multilingual briefings for API and web users. The README documents the scheduled pipeline; sampled code confirms article deduplication, AI-provider fallback, and API article analysis. Several pipeline commands and feed components were not sampled, so their documented connections are cited to the README rather than inferred from code.

Main entry points: [`app/Http/Controllers/Api`](https://github.com/aboelresh/gnip/tree/main/app/Http/Controllers/Api) (API controllers), [`app/Services/AI/AIManager.php`](https://github.com/aboelresh/gnip/blob/main/app/Services/AI/AIManager.php) (AI provider manager), [`app/Models/Article.php`](https://github.com/aboelresh/gnip/blob/main/app/Models/Article.php) (Articles), [`app/Services/Analysis/BriefingGeneratorService.php`](https://github.com/aboelresh/gnip/blob/main/app/Services/Analysis/BriefingGeneratorService.php) (Briefing generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["News ingestion"]
  node_fetch["Feed fetching<br/>[FeedFetcher.php]"]
  node_fetchcmd["Fetch command<br/>[FetchFeeds.php]"]
  node_repository["Article repository"]
end

subgraph group_analysis["Content analysis"]
  node_analyzecmd["Analysis command"]
  node_analyzer["Article analysis"]
  node_aimanager["AI provider manager<br/>[AIManager.php]"]
  node_providers["AI providers"]
  node_cluster["Story clustering"]
  node_clustercmd["Clustering command<br/>[ClusterStories.php]"]
  node_briefgen["Briefing generation"]
  node_briefcmd["Briefing command"]
end

subgraph group_delivery["User delivery"]
  node_api["REST API<br/>[api.php]"]
  node_controllers["API controllers"]
  node_websearch["Web search"]
end

subgraph group_state["Domain data"]
  node_articles[("Articles<br/>[Article.php]")]
  node_sources[("News sources<br/>[Source.php]")]
  node_ailogs[("AI usage logs<br/>[AiLog.php]")]
  node_stories[("Stories and evidence<br/>[Story.php]")]
  node_briefings[("Briefings<br/>[Briefing.php]")]
end

node_rss(("RSS sources"))
node_reader(("News reader"))

node_rss -->|"supplies feeds"| node_fetch
node_fetchcmd -.->|"runs fetching"| node_fetch
node_fetch -->|"stores items"| node_repository
node_repository -->|"deduplicates and saves"| node_articles
node_fetch -->|"fetches from"| node_sources
node_analyzecmd -->|"runs analysis"| node_analyzer
node_analyzer -->|"requests AI"| node_aimanager
node_aimanager -->|"tries providers"| node_providers
node_aimanager -->|"records usage"| node_ailogs
node_analyzer -->|"analyzes articles"| node_articles
node_articles -->|"feeds clustering"| node_cluster
node_clustercmd -->|"runs clustering"| node_cluster
node_cluster -->|"forms stories"| node_stories
node_briefcmd -->|"runs generation"| node_briefgen
node_briefgen -->|"requests AI"| node_aimanager
node_briefgen -->|"summarizes stories"| node_stories
node_briefgen -->|"creates briefings"| node_briefings
node_api -->|"routes requests"| node_controllers
node_controllers -->|"serves articles"| node_articles
node_controllers -->|"invokes analysis"| node_aimanager
node_controllers -->|"serves stories"| node_stories
node_controllers -->|"serves briefings"| node_briefings
node_websearch -->|"searches articles"| node_articles
node_websearch -->|"searches stories"| node_stories
node_reader -->|"requests news"| node_api
node_reader -.->|"searches coverage"| node_websearch

click node_fetch "https://github.com/aboelresh/gnip/blob/main/app/Services/Feed/FeedFetcher.php"
click node_fetchcmd "https://github.com/aboelresh/gnip/blob/main/app/Console/Commands/FetchFeeds.php"
click node_repository "https://github.com/aboelresh/gnip/blob/main/app/Repositories/ArticleRepository.php"
click node_articles "https://github.com/aboelresh/gnip/blob/main/app/Models/Article.php"
click node_sources "https://github.com/aboelresh/gnip/blob/main/app/Models/Source.php"
click node_analyzecmd "https://github.com/aboelresh/gnip/blob/main/app/Console/Commands/AnalyzeArticles.php"
click node_analyzer "https://github.com/aboelresh/gnip/blob/main/app/Services/AI/ArticleAnalyzer.php"
click node_aimanager "https://github.com/aboelresh/gnip/blob/main/app/Services/AI/AIManager.php"
click node_providers "https://github.com/aboelresh/gnip/tree/main/app/Services/AI"
click node_ailogs "https://github.com/aboelresh/gnip/blob/main/app/Models/AiLog.php"
click node_cluster "https://github.com/aboelresh/gnip/blob/main/app/Services/Analysis/StoryClusteringService.php"
click node_clustercmd "https://github.com/aboelresh/gnip/blob/main/app/Console/Commands/ClusterStories.php"
click node_stories "https://github.com/aboelresh/gnip/blob/main/app/Models/Story.php"
click node_briefgen "https://github.com/aboelresh/gnip/blob/main/app/Services/Analysis/BriefingGeneratorService.php"
click node_briefcmd "https://github.com/aboelresh/gnip/blob/main/app/Console/Commands/GenerateBriefing.php"
click node_briefings "https://github.com/aboelresh/gnip/blob/main/app/Models/Briefing.php"
click node_api "https://github.com/aboelresh/gnip/blob/main/routes/api.php"
click node_controllers "https://github.com/aboelresh/gnip/tree/main/app/Http/Controllers/Api"
click node_websearch "https://github.com/aboelresh/gnip/blob/main/app/Http/Controllers/Web/SearchController.php"

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_fetch,node_fetchcmd,node_repository toneBlue
class node_analyzecmd,node_analyzer,node_aimanager,node_providers,node_cluster,node_clustercmd,node_briefgen,node_briefcmd toneAmber
class node_api,node_controllers,node_websearch toneMint
class node_articles,node_sources,node_ailogs,node_stories,node_briefings toneRose
class node_rss,node_reader toneIndigo
```

## Components

### News ingestion

- [Feed fetching](https://github.com/aboelresh/gnip/blob/main/app/Services/Feed/FeedFetcher.php): `app/Services/Feed/FeedFetcher.php`
- [Fetch command](https://github.com/aboelresh/gnip/blob/main/app/Console/Commands/FetchFeeds.php): `app/Console/Commands/FetchFeeds.php`
- [Article repository](https://github.com/aboelresh/gnip/blob/main/app/Repositories/ArticleRepository.php): `app/Repositories/ArticleRepository.php`

### Content analysis

- [Analysis command](https://github.com/aboelresh/gnip/blob/main/app/Console/Commands/AnalyzeArticles.php): `app/Console/Commands/AnalyzeArticles.php`
- [Article analysis](https://github.com/aboelresh/gnip/blob/main/app/Services/AI/ArticleAnalyzer.php): `app/Services/AI/ArticleAnalyzer.php`
- [AI provider manager](https://github.com/aboelresh/gnip/blob/main/app/Services/AI/AIManager.php): `app/Services/AI/AIManager.php`
- [AI providers](https://github.com/aboelresh/gnip/tree/main/app/Services/AI): `app/Services/AI`
- [Story clustering](https://github.com/aboelresh/gnip/blob/main/app/Services/Analysis/StoryClusteringService.php): `app/Services/Analysis/StoryClusteringService.php`
- [Clustering command](https://github.com/aboelresh/gnip/blob/main/app/Console/Commands/ClusterStories.php): `app/Console/Commands/ClusterStories.php`
- [Briefing generation](https://github.com/aboelresh/gnip/blob/main/app/Services/Analysis/BriefingGeneratorService.php): `app/Services/Analysis/BriefingGeneratorService.php`
- [Briefing command](https://github.com/aboelresh/gnip/blob/main/app/Console/Commands/GenerateBriefing.php): `app/Console/Commands/GenerateBriefing.php`

### User delivery

- [REST API](https://github.com/aboelresh/gnip/blob/main/routes/api.php): `routes/api.php`
- [API controllers](https://github.com/aboelresh/gnip/tree/main/app/Http/Controllers/Api): `app/Http/Controllers/Api`
- [Web search](https://github.com/aboelresh/gnip/blob/main/app/Http/Controllers/Web/SearchController.php): `app/Http/Controllers/Web/SearchController.php`

### Domain data

- [Articles](https://github.com/aboelresh/gnip/blob/main/app/Models/Article.php): `app/Models/Article.php`
- [News sources](https://github.com/aboelresh/gnip/blob/main/app/Models/Source.php): `app/Models/Source.php`
- [AI usage logs](https://github.com/aboelresh/gnip/blob/main/app/Models/AiLog.php): `app/Models/AiLog.php`
- [Stories and evidence](https://github.com/aboelresh/gnip/blob/main/app/Models/Story.php): `app/Models/Story.php`
- [Briefings](https://github.com/aboelresh/gnip/blob/main/app/Models/Briefing.php): `app/Models/Briefing.php`

### Other components

- **RSS sources**
- **News reader**

## Connections

- RSS sources → Feed fetching: supplies feeds
- Fetch command → Feed fetching: runs fetching
- Feed fetching → Article repository: stores items
- Article repository → Articles: deduplicates and saves (evidence: `app/Repositories/ArticleRepository.php`)
- Feed fetching → News sources: fetches from
- Analysis command → Article analysis: runs analysis (evidence: `app/Console/Commands/AnalyzeArticles.php`)
- Article analysis → AI provider manager: requests AI (evidence: `app/Services/AI/ArticleAnalyzer.php`)
- AI provider manager → AI providers: tries providers (evidence: `app/Services/AI/AIManager.php`)
- AI provider manager → AI usage logs: records usage (evidence: `app/Services/AI/AIManager.php`)
- Article analysis → Articles: analyzes articles (evidence: `app/Services/AI/ArticleAnalyzer.php`)
- Articles → Story clustering: feeds clustering (evidence: `app/Services/Analysis/StoryClusteringService.php`)
- Clustering command → Story clustering: runs clustering
- Story clustering → Stories and evidence: forms stories (evidence: `app/Services/Analysis/StoryClusteringService.php`)
- Briefing command → Briefing generation: runs generation
- Briefing generation → AI provider manager: requests AI (evidence: `app/Services/Analysis/BriefingGeneratorService.php`)
- Briefing generation → Stories and evidence: summarizes stories (evidence: `app/Services/Analysis/BriefingGeneratorService.php`)
- Briefing generation → Briefings: creates briefings (evidence: `app/Services/Analysis/BriefingGeneratorService.php`)
- REST API → API controllers: routes requests (evidence: `routes/api.php`)
- API controllers → Articles: serves articles (evidence: `app/Http/Controllers/Api/ArticleController.php`)
- API controllers → AI provider manager: invokes analysis (evidence: `app/Http/Controllers/Api/ArticleController.php`)
- API controllers → Stories and evidence: serves stories (evidence: `routes/api.php`)
- API controllers → Briefings: serves briefings (evidence: `app/Http/Controllers/Api/BriefingController.php`)
- Web search → Articles: searches articles (evidence: `app/Http/Controllers/Web/SearchController.php`)
- Web search → Stories and evidence: searches stories (evidence: `app/Http/Controllers/Web/SearchController.php`)
- News reader → REST API: requests news
- News reader → Web search: searches coverage
