How leoulgirma/scrape-exchange-rates works
Main Components
• Data Scraper Module: Components like currency_scraper.py and get-rate.py are responsible for fetching and/or updating exchange rate data.
• Database Layer: The SQLite database (currency_exchange.db), along with db_setup.py, read.py, and write.py, represent the data persistence layer. This layer handles storing, updating, and retrieving the exchange rate data.
• API/Backend: The Flask API application (app.py) serves as the entry point for accessing the statistics derived from the stored data.
• Data Processing/Visualization: Scripts like exchange_rate_plot.py, rate_plotly.py, and possibly CurrencyExchange.py seem designed for processing data or generating visualizations (with tables.html as a possible rendered output).
Relationships & Interactions
• The Data Scraper fetches exchange rate information from external sources and writes these values into the SQLite database.
• The Database Layer is interfaced both by the scraper (writing/updating data) and by the backend API (reading data to expose endpoints with statistics).
• The API layer (Flask in app.py) retrieves data from the SQLite database when endpoints are called, likely processing data or calling visualization scripts to generate statistics.
• Visualization scripts might be invoked internally by the API or as standalone scripts to generate data plots or HTML tables that display trends or statistics.
Architectural Patterns & Design Principles
• Modular Separation: Each major functionality (data scraping, database management, API presentation, and visualization) is separated by individual scripts. This design promotes simplicity and clarity.
• RESTful API Design: The Flask application is set up as an API endpoint that provides access to various statistics about exchange rates.
• Lightweight Data Persistence: Using an SQLite database suits the scale of this project, emphasizing ease of setup and maintenance.
• Reusability: The existence of separate modules (read.py, write.py, db_setup.py) indicates a design choice that favors code reuse rather than monolithic scripts.