How kinggiaan/crypto-predictor works
Main Components
• Frontend: Built with React and styled using Tailwind CSS, it contains components (e.g., Navbar, PredictionPanel, PriceChart) and pages (Dashboard, History, Learn). It interacts with the backend via API calls.
• Backend: Based on Flask, the backend exposes API endpoints (e.g., POST /predict, GET /history, POST /explain) and includes utility functions, model training logic, and database initialization.
• Machine Learning Models: Integrated within the backend—models like Random Forest and SVM, which are trained (using scripts like train_models.py) and then serve predictions.
• Database: SQLite serves as the storage for historical prediction data and related information.
• External Data Source: The Binance API is used as the data source for cryptocurrency prices.
• Additional Directories: Files such as .env and configuration files for managing environments, as well as deployment-related artifacts (e.g., package.json in both frontend and backend).
Establish Relationships and Data Flow
• The frontend sends HTTP requests to the Flask-based backend for predictions, historical data, and model explanations.
• The backend processes these requests; it accesses the machine learning models to compute predictions and interacts with the SQLite database to retrieve and store historical data.
• Data is also fetched from the Binance API to get updated crypto prices.
• Once processed, responses are sent back to the frontend, which then updates its interactive charts and displays to the user.
Architectural Patterns and Key Technologies
• Separation of Concerns: Clear division between the presentation layer (frontend) and the business logic/data handling layer (backend).
• API-Driven Design: The backend functions as an API server accepting POST/GET requests, simplifying interaction with separate components.
• MVC-like Pattern on Frontend: Though not strictly MVC, the frontend separates components (views) and pages to organize user interactions.
• Integration of AI/ML: The machine learning models (Random Forest and SVM) are central to the logic for making predictions.
• Data Flow: The use of a central database (SQLite) to persist historical prediction data, along with external API calls, signifies a real-time data processing pipeline.