How tphat77923/bank-noti-box works
Project Overview
• This is a Python-based full-stack monitoring application designed to periodically check SePay’s API for new bank transactions.
• It displays the latest transactions on a self-hosted webpage and produces an audible notification when a new incoming (amount_in > 0) transaction is detected.
• The project is simple in structure, with a single Python entry-point (app.py), HTML templates (in the templates folder), and an audio file (ting.mp3) for notifications.
Main Components of the System
a. Backend/Service Layer (app.py)
• This file is the central entry-point of the application.
• It is responsible for:
• Polling the SePay API every 2 seconds to check for new transactions.
• Processing the API responses and filtering for incoming transactions.
• Initiating the sound notification when applicable.
• Passing the transaction data to the web interface.
b. Web Interface (templates/index.html)
• Provides a simple frontend that displays a list of the most recent transactions.
• Likely powered by a Python web framework (e.g., Flask) that renders HTML templates.
c. Notification Service (ting.mp3 combined with external mpv player)
• When a valid transaction is detected (money coming in), the application triggers a sound notification using an external media player (mpv) to play the ting.mp3 file.
d. External Dependencies
• SePay API: The application integrates with this API to fetch transaction data.
• Python libraries as listed in requirements.txt and the externally-installed mpv.
Relationships and Interactions
• The app.py serves as the application’s controller that coordinates between components:
• It periodically initiates API calls to SePay.
• When new transactions are detected, data flows from the API fetch layer into the transaction processing logic.
• If an “incoming” transaction is identified, the notification service (mpv + ting.mp3) is triggered.
• Independently or in parallel, the backend continuously updates the web interface data, which is rendered using the HTML template.
• Users access the web interface by connecting to the local host (e.g., http://localhost:3000).
Architectural Patterns and Design Principles
• The design is a simple monolithic application. Despite its simplicity, it follows a separation of concerns:
• Polling/processing logic versus presentation (web template).
• External service integration (SePay API) is segregated from UI and notification functions.
• The polling mechanism (every 2 seconds) is an example of a recurring task that could be visualized as a loop or scheduler.
• Use of external tools (mpv for audio) suggests a loosely coupled integration pattern for non-Python dependencies.
Final Elements
• Component is clearly labeled (e.g., “Transaction Fetcher”, “Web Interface”, “Audio Notifier”, “SePay API”).
• Data flow from the API to the processor and then to the notifier and web interface.
• Request-response cycle between the Web Browser/Client and the Web Server.
• Backend processing versus frontend elements.
• External dependencies (like the SePay API and mpv) to differentiate them from native Python components.