How ibaihuo/chanvis works
Project Type and Purpose
• This is a full-stack, data-visualization application tailored to geometric (缠论) trading analysis.
• The front end is a Vue.js SPA that embeds TradingView’s local SDK for interactive K-line charts and custom drawing tools.
• The back end is a Flask-based Python API server exposing endpoints to load raw K-line data and structural analysis results (natural chan theory, “NLChan”).
• MongoDB serves as the time-series and analysis-result datastore.
• ETL scripts in the hetl/ folder ingest raw exchange or JQ data into MongoDB.
Main Components
a. Frontend (ui/)
• Vue.js + TypeScript app (src/)
• TradingView charting library & datafeed JS (public/)
• Custom Vue components (ChanContainer.vue, ChanApp.vue) for drawing tools, indicators, and playback controls
b. Backend API (api/)
• Flask application (chanapi.py)
• Symbol metadata loader (symbol_info.py)
• Configuration (comm/conf.py) for database URIs, API settings
c. Data Store
• MongoDB instance holding:
• Raw K-line collections (nlchan, stock)
• Replay and config collections (config)
d. ETL Layer (hetl/)
• Mongo restore scripts (hmgo/restore_chanvis_mongo.sh)
• Data-fetch and conversion scripts (selcoin/, stock/get_jqdata.py)
e. Utilities (utils/)
• Date helpers (dtlib.py)
• Natural-Chan analysis helpers (nlchan.py)
Interactions and Data Flows
1. ETL scripts pull data from external sources (Binance, JQData), transform it into BSON/JSON, and load to MongoDB.
2. The Flask API reads from MongoDB, applies any NLP/NLChan algorithms via utils/nlchan.py, and returns time-series or analysis results as JSON.
3. The Vue client initializes TradingView, fetches historical bars or indicator data via HTTP calls to Flask endpoints, and renders them.
4. User interactions (drawing, custom indicators) trigger additional API calls or local state updates in the UI.
Architectural Patterns and Principles
• Clear separation of concerns:
• ETL layer —> Data ingestion
• API layer —> Data access + business logic
• UI layer —> Presentation + interaction
• Modular, folder-based structure maps directly to system components.
• Stateless REST API ensures horizontal scalability of the back end.
• Use of external SDK (TradingView) makes the front end lightweight and focused on integration.
Technologies and Frameworks
• Frontend: Vue.js, TypeScript, TradingView Local Charting Library
• Backend: Python, Flask, PyMongo
• Database: MongoDB
• ETL: Python scripts, shell scripts, BSON dumps
• Utilities: Custom Python modules