How galsakuri/stock-market-viewer-gui-api works
Project type and purpose
• This is a lightweight desktop GUI application (Tkinter-based) whose sole purpose is:
• To fetch and display a 6-month history chart of a stock’s daily closing price.
• To fetch and display the 5 most recent news headlines for that ticker (clickable to open the browser).
• It relies on two external REST APIs: AlphaVantage (stock data) and NewsAPI (news headlines).
File structure
• At the top level we have just:
• README.md
• Stock Market main.py
• All code lives in a single script; there are no subdirectories for modules or assets.
• No build scripts or config files beyond the API-key placeholders inside the main.py.
README for additional insights
• The README specifies:
• Python 3.9+
• Dependencies: requests, pandas, matplotlib, and tkinter (part of stdlib).
• Rate limits for each API.
• Setup instructions (where to insert API keys), installation, and how to run the script.
a. Main components
1. User Interface (Tkinter)
• Input field for ticker symbol
• “Search” button
• Chart area (matplotlib embedded)
• News list (clickable items)
2. Controller / Orchestrator (in the same script)
• Receives UI events (e.g., Search clicked)
• Calls data-fetching functions
• Updates UI with results
3. Data-Fetch Layer
• StockDataFetcher (requests → AlphaVantage)
• NewsDataFetcher (requests → NewsAPI)
4. Data Processing
• pandas DataFrame transformation for charting
5. Chart Renderer
• matplotlib Figure/Canvas embedded into Tkinter
6. External Services
• AlphaVantage REST API
• NewsAPI REST API
b. Relationships & interactions
• UI “Search” event → Controller
• Controller → StockDataFetcher → AlphaVantage → JSON
• Controller → NewsDataFetcher → NewsAPI → JSON
• Controller → pandas transforms stock JSON → DataFrame
• Controller → matplotlib renders chart from DataFrame
• Controller → UI updates chart and news list
• UI news-item click → open default web browser to news URL
c. Architectural patterns & design principles
• MVC-like separation (View: Tkinter, Controller: event handlers, Model: fetched data)
• Single responsibility per component (fetching stock vs. fetching news vs. rendering chart)
• Synchronous, linear flow (no async/threading)
d. Key technologies
• Python 3.9+
• Tkinter (UI)
• requests (HTTP calls)
• pandas (data processing)
• matplotlib (plotting)
• webbrowser (open URLs)