How apconw/sanic-web works
Main System Components
• Frontend: The “web” directory contains a Vue3 + TypeScript application built on Vite. It comprises components, assets, views, routing, state management, and utilities for interacting with backend APIs.
• Backend Server: The root-level Python files (serv.py, config, controllers, services, common, constants) indicate that the backend is built on Sanic (a high-performance asynchronous framework). Controllers manage different API endpoints (e.g., common_chat_api, db_chat_api, dify_chat_api, ta_assistant_api, user_service_api) while services implement business logic.
• Docker & Middleware: The “docker” directory contains multiple docker-compose files and Dockerfile setups for components such as Dify, MySQL, Minio, Couchbase, Elasticsearch, and other middleware (e.g., tidb, pgvector, nginx, certbot). This demonstrates a containerized environment.
• External Services: Integration points are apparent for large model APIs (via Dify and third-party services), as well as for MinIO (object storage) and MySQL (data storage) with initialization scripts in “initialize_mysql.py” and “init.sh”.
• Components / Libraries: The presence of “common”, “component”, and “config” directories shows shared utilities (date_util, pdf_util, redis_tool, token_decorator, etc.) that are used across the backend.
Relationships & Interactions
• Backend Internal Flow: Within the backend, controllers call services which in turn might use utility functions from “common” and configuration files from the “config” directory. Services include logic for handling chat API endpoints, data processing, and integration with Text2SQL.
• Integration with External Models: The backend interacts with large model providers (Dify, Ollama, DeepSeek) via the configured APIs and docker-compose services. Represent these external services as separate components connected via secure API calls.
• Data Flow: Demonstrate how data flows from incoming client requests from the frontend, processed by controllers, utilizing service logic and storage (MySQL, Minio), and then responses returned to the client. Likewise, show the processing flow for CSV uploads and PDF processing.
Architectural Patterns and Design Principles
• Extensibility: The README emphasizes “易于二次开发” (easy to extend). Indicate extensibility points such as additional controllers or services, as well as integration nodes for adding further large model providers.
Specific Elements to Incorporate
• Optionally, include schematic representations of the workflow for key features (e.g., “数据问答” – data Q&A via Text2SQL and ECharts) to illustrate how a client query is processed end-to-end.