# roar3691/newsecho architecture

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

- Interactive diagram: https://gitdiagram.com/roar3691/newsecho
- Repository: https://github.com/roar3691/newsecho

## Overview

##### Project Type and Purpose
- It is essentially a full-stack application with a dual interface. The Streamlit app (app.py) provides an interactive frontend, and the FastAPI endpoint (contained within api.py) offers programmatic access to the functionality.
- The core functionality revolves around fetching news articles, summarizing content, performing sentiment analysis (leveraging VADER), comparative analysis, and generating Hindi text-to-speech (via Gemini API) based on a news topic or company.

##### Analyzing the File Structure
- The top-level files include:
- app.py: Likely the entry point for launching the interactive Streamlit UI.
- api.py: A FastAPI endpoint to allow external systems to trigger the application’s functionality.
- utils.py: Contains common helper functions shared by both the UI and API components.
- requirements.txt: Lists the dependencies (such as Streamlit, FastAPI, and external API libraries) required by the project.
- The presence of a LICENSE and .gitignore file indicates this is a public/open-source project ready for community contributions.
- Overall, the structure is simple and flat, with the division between interactive and API layers clearly defined by two separate Python scripts.

##### Key Components
- Frontend Component:
- The Streamlit UI (app.py) that handles user interactions, displays news summaries, sentiment outcomes, and TTS outputs.
- Backend Component:
- The FastAPI endpoint (api.py) for programmatic access and integration with other services or client-side applications.
- Utility Module:
- Shared logic in utils.py to support fetching news (using the Google Custom Search API), summarizing articles, performing sentiment analysis, and integrating with the Gemini API for TTS.
- External Services:
- Google Custom Search API: For retrieving news articles.
- VADER or similar service: For sentiment analysis.
- Gemini API: For generating Hindi TTS.
- Data Flow & Processes:
- The process starts when the user interacts with the UI or the external system sends a request to the API.
- The system then triggers the news fetching process.
- Once the articles are fetched, they are summarized and passed through sentiment analysis.
- Finally, based on the results, the Gemini API is used to generate Hindi TTS output.

- Main Components:
- Data Flow:
- The user interacting with the "Streamlit Frontend".
- The "Streamlit Frontend" calling utility functions for processing tasks.
- Requests from external users hitting the FastAPI endpoint.
- Utility modules communicating with the external APIs.
- Use clear labels for every component.
- Detailed Annotations:

## Diagram (Mermaid)

```mermaid
flowchart TD 
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["User Input"]:::user
        Streamlit["Streamlit Frontend"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        ExtClient["External Client"]:::user
        FastAPI["FastAPI Backend"]:::backend
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        Utility["Utility Processing Module"]:::logic
    end

    %% External Integration Layer
    subgraph "External Integration"
        Google["Google Custom Search API"]:::external
        VADER["VADER Sentiment Analysis"]:::external
        Gemini["Gemini TTS"]:::external
    end

    %% Data Flow - Presentation
    UI -->|"triggers"| Streamlit
    Streamlit -->|"calls processing"| Utility

    %% Data Flow - API
    ExtClient -->|"sendsRequest"| FastAPI
    FastAPI -->|"delegatesTo"| Utility

    %% Business Logic interactions with External Services
    Utility -->|"fetchesNews"| Google
    Utility -->|"analyzesSentiment"| VADER
    Utility -->|"generatesTTS"| Gemini

    %% Response flows back from External Services to Utility
    Google ---|"returnsArticles"| Utility
    VADER ---|"returnsSentiment"| Utility
    Gemini ---|"returnsTTS"| Utility

    %% Utility returns responses to layers
    Utility -->|"sendsResponse"| Streamlit
    Utility -->|"sendsResponse"| FastAPI

    %% Click Events
    click Streamlit "https://github.com/roar3691/newsecho/blob/main/app.py"
    click FastAPI "https://github.com/roar3691/newsecho/blob/main/api.py"
    click Utility "https://github.com/roar3691/newsecho/blob/main/utils.py"

    %% Styles
    classDef user fill:#fce1e4,stroke:#d73a49,stroke-width:2px;
    classDef frontend fill:#fef3c7,stroke:#d69e2e,stroke-width:2px;
    classDef backend fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef logic fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#818182,stroke-width:2px;
```
