How arvinlovegood/go-stock works
Project Type and Purpose
• The project is a full-stack desktop application built with a Go backend using Wails to integrate with a modern web-based frontend. The purpose is to provide AI-powered stock analysis for markets such as A-shares, Hong Kong stocks, and US stocks, integrating multiple APIs (e.g., for stock data, AI models, news crawling, etc.) while providing interactive user experiences via NaiveUI / Vue.
• The README stresses integration with various AI models (OpenAI, Ollama, LMStudio, etc.) and emphasizes stock market data and multi-platform support.
File Structure
• Top-Level Indicators:
– The project has a clear separation between frontend and backend directories.
– Several build scripts and platform-specific files (e.g., app_darwin.go, app_linux.go, Windows installer scripts) indicate cross-platform build support.
– Presence of a “wails.json” suggests project configuration for the Wails framework.
• Backend Directory:
– Contains multiple subdirectories such as “data” (for different API integrations like alert, crawler, dingding, stock data, etc.), “db” (for database connectivity or persistence), “logger” (for logging functionality), and “models” (defining the data structures).
– The API implementations (e.g., fund_data_api, tushare_data_api) are distinct and each comes with its own test files.
• Frontend Directory:
– Contains Vue components (App.vue, components like about.vue, fund.vue, settings.vue, stock.vue) and a router configuration which is built using Vite.
– The “wailsjs” folder shows that Wails generates JavaScript and TypeScript bindings for Go code, bridging the frontend with backend methods.
• Shared and Infrastructure Elements:
– The main Go files at the root (app.go, main.go) serve as entry points.
– Build and scripts directories contain platform-specific deployment/build scripts.
Key Architectural Components
• Frontend Layer:
• Vue.js-based user interface built with NaiveUI, with configuration via Vite.
• Routing and components (for displaying stock data, AI analysis results, settings, etc.).
• Interfaces (wailsjs) to invoke Go backend functions.
• Backend Layer:
• Go business logic implemented via multiple packages:
▪ Data Layer: Different API clients (OpenAI, crawler, Tushare, etc.) for fetching or processing stock and financial data.
▪ Models: Data structures and domain models.
▪ Logger: Logging subsystem.
▪ Database: Data persistence or storage abstraction.
• Platform-specific variations (files like app_darwin.go and app_linux.go) to handle OS-specific functionality.
• Integration & Communication:
• Communication between the frontend and backend through the Wails runtime.
• APIs wrapping external services like OpenAI, Dingding, etc.
• CI/CD and Build Processes:
• GitHub workflows (in .github/workflows) for continuous integration.
• Scripts for building on various platforms (macOS arm/intel, Windows, etc.).
a. Main Components:
• “CI/CD Pipeline” to denote GitHub workflows and build scripts.
b. Relationships and Data Flow:
c. Architectural Patterns & Design Principles:
• Separation of concerns (frontend vs. backend).
• The modular design in the backend: separate directories for data access, logging, and models, which suggests an organized architecture similar to MVC or layered architecture.
• The usage of platform-specific entry points for customized builds is also a notable design choice.
d. Relevant Technologies:
• Frontend: Vue, NaiveUI, Vite.
• Backend: Go, Wails framework, and various third-party APIs (OpenAI, Tushare, etc.).
• Build & CI: GitHub Actions, shell scripts for cross-platform builds, and configuration through wails.json.
• Use clear, descriptive labels for each component (e.g., "Frontend (Vue + NaiveUI)", "Backend Data API (Stock/Tushare/OpenAI)", "Logger", "Database", "Wails Runtime Bridge").