# hazeishere/news-what-taiwan architecture

> Architecture diagram of the GitHub repository hazeishere/news-what-taiwan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hazeishere/news-what-taiwan
- Repository: https://github.com/hazeishere/news-what-taiwan

## Overview

##### Project type and purpose
- This is a full-stack web application built with Flask (Python) on the back end and Bootstrap/Jinja2 templates on the front end.
- It scrapes Yahoo Taiwan News, stores the raw articles, and then uses an AI model (via the g4f library) to generate humorous translations, summaries, sentiment analysis, keyword extraction, and core takeaways.

##### File structure
- Top-level:
- app.py – main Flask application (routes, controllers)
- requirements.txt – Python dependencies
- templates/ – Jinja2 HTML views: index.html, article.html, crawling.html, debug.html, introduction.html, rate_limit.html, settings.html
- images/ – static assets (screenshots)
- No dedicated “static” folder is listed, but Bootstrap/JS likely served via CDN.
- There is an implicit data store (articles.json noted in README) for persisting scraped articles.
- Key patterns: MVC-style separation (app.py = controllers/models; templates = views), service modules for scraping and AI calls.

##### README for insights
- Backend stack: Flask + BeautifulSoup + Requests + g4f
- Frontend stack: HTML/CSS/Bootstrap/JavaScript
- Runtime flow: user triggers “crawl” → scraper fetches articles → stores in JSON → user clicks an article → AI service invoked → results rendered.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["Client Browser"]:::frontend
        Templates["Jinja2 Templates"]:::frontend
        HomeTemplate["Index Page"]:::frontend
        ArticleTemplate["Article Detail Page"]:::frontend
        CrawlingTemplate["Crawling Status Page"]:::frontend
        DebugTemplate["Debug View Page"]:::frontend
        IntroTemplate["Introduction Page"]:::frontend
        RateLimitTemplate["Rate Limit Warning Page"]:::frontend
        SettingsTemplate["Settings Page"]:::frontend
        images["Static Assets (screenshots)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        Controllers["Routing & Controllers"]:::backend
        subgraph "Services"
            ScraperService["Scraping Service"]:::service
            AIAdapter["AI Service Adapter"]:::service
        end
        DataStorage["Data Storage (articles.json)"]:::storage
    end

    %% External Systems
    YahooNews["Yahoo Taiwan News"]:::external
    AIProvider["AI Provider Endpoint"]:::external

    %% Connections
    Browser -->|HTTP GET/POST| Controllers
    Controllers -->|render| Templates
    Templates -->|HTML Response| Browser

    Controllers -->|invoke scrape| ScraperService
    ScraperService -->|GET HTML| YahooNews
    ScraperService -->|write JSON| DataStorage
    Controllers -->|read JSON| DataStorage

    Controllers -->|invoke AI| AIAdapter
    AIAdapter -->|POST prompt/receive response| AIProvider
    AIAdapter -->|read/write JSON| DataStorage

    %% Click Events
    click Controllers "https://github.com/hazeishere/news-what-taiwan/blob/main/app.py"
    click ScraperService "https://github.com/hazeishere/news-what-taiwan/blob/main/app.py"
    click AIAdapter "https://github.com/hazeishere/news-what-taiwan/blob/main/app.py"
    click DataStorage "https://github.com/hazeishere/news-what-taiwan/blob/main/README.md"
    click Templates "https://github.com/hazeishere/news-what-taiwan/tree/main/templates/"
    click HomeTemplate "https://github.com/hazeishere/news-what-taiwan/blob/main/templates/index.html"
    click ArticleTemplate "https://github.com/hazeishere/news-what-taiwan/blob/main/templates/article.html"
    click CrawlingTemplate "https://github.com/hazeishere/news-what-taiwan/blob/main/templates/crawling.html"
    click DebugTemplate "https://github.com/hazeishere/news-what-taiwan/blob/main/templates/debug.html"
    click IntroTemplate "https://github.com/hazeishere/news-what-taiwan/blob/main/templates/introduction.html"
    click RateLimitTemplate "https://github.com/hazeishere/news-what-taiwan/blob/main/templates/rate_limit.html"
    click SettingsTemplate "https://github.com/hazeishere/news-what-taiwan/blob/main/templates/settings.html"
    click images "https://github.com/hazeishere/news-what-taiwan/tree/main/images/"
    click Requirements "https://github.com/hazeishere/news-what-taiwan/blob/main/requirements.txt"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0B60D0,stroke-width:2px
    classDef backend fill:#D6F5D6,stroke:#2E8B57,stroke-width:2px
    classDef service fill:#A8E6A3,stroke:#2E8B57,stroke-width:2px
    classDef storage fill:#FFE5B4,stroke:#D2691E,stroke-width:2px
    classDef external fill:#E0E0E0,stroke:#808080,stroke-width:2px
```
