How mohadtt/chartscanai_autonomous works
Project type and purpose
• ChartScanAI is a specialized full-stack single-page application combining a Streamlit-based frontend with a Python backend that performs deep-learning inference.
• Its purpose is to automate pattern detection (Buy/Sell signals) in financial candlestick charts by loading/generating chart images, running them through a YOLOv8 model, and displaying results in real time.
File structure
Top level:
• app.py – the Streamlit application entry point (UI + controller)
• requirements.txt – Python dependencies (Streamlit, ultralytics, yfinance, mplfinance, etc.)
• packages.txt – auxiliary package listing (possibly for deployment)
• weights/ – directory containing the trained model weights (custom_yolov8.pt)
• images/ – static assets (logo, sample outputs)
• README.md, LICENSE, .gitignore
Architectural hints:
• No separate “frontend” folder: UI and app logic are co-located in app.py.
• Model file under weights indicates a ML inference component.
• Use of yfinance & mplfinance implies an external data-fetching subcomponent.
• Streamlit handles both HTTP serving and UI rendering.
Extract additional insights from README
• Architecture: single monolithic service written in Python.
• Dependencies: YOLOv8 (ultralytics), Streamlit, yfinance, mplfinance.
• Workflow described: data acquisition → chart plotting → model inference → result rendering.
Main components and interactions
a. Components
1) User Interface (Streamlit Frontend)
2) Application Logic / Controller (app.py)
3) Model Inference Engine (YOLOv8 loaded from weights/custom_yolov8.pt)
4) Data Acquisition Module (yfinance)
5) Chart Generation Module (mplfinance)
6) Result Renderer (Streamlit canvas + Matplotlib overlays)
7) External Services (yfinance API)
8) Static Assets (images/, weights/)
9) Deployment Environment (e.g., Streamlit Cloud or Docker host)
b. Relationships & Data Flow
1) User interacts via browser → Streamlit Frontend
2) Frontend calls controller functions in app.py
3) Controller either:
• Fetches data from yfinance → Chart Generation Module → generates image
• Or accepts user-uploaded chart image
5) Controller sends annotated result to Result Renderer → streams back to UI
6) Logging & error-handling spans all stages
c. Architectural patterns & principles
• Layered approach: UI layer (Streamlit components) → Service/Controller layer (app logic) → Model/Inference layer → Data layer (external APIs + local weights)
• Single Responsibility: each module (data fetch, chart gen, inference, rendering) encapsulates one concern
• Scalability: weights and model code separated from UI code; easy to swap in updated models
• Extensibility: new chart-pattern models or data sources can be added with minimal change
d. Key technologies & frameworks
• Streamlit – UI & HTTP server
• Python – core language
• ultralytics YOLOv8 – object detection inference
• yfinance – stock/crypto data API
• mplfinance – candlestick charting
• Roboflow – used offline for annotation (not in runtime)
Diagramming recommendations
• Use rectangles for components (UI, Controller, Inference Engine, Data Module).
– Blue for UI components
– Green for backend services
– Orange for ML/model layers
– Gray for external services/storage
• Related components within containers (e.g., “app.py” container encapsulating Controller + Data Acquisition + Chart Generation + Result Renderer).
Detail
• Weights folder as an artifact the controller loads at startup.
• Environment details (Python, Streamlit Cloud/Docker) if relevant for deployment.