How cyx-dzy/chinese-traditional-culture works
1. Repository shape
- This is a two-tier web application with a Python backend and a Vue 3 frontend.
- The main architectural boundary is between the presentation layer in frontend/ and the API/data layer in backend/.
2. User-facing application flow
- Users enter through the Vue SPA, which provides a home page, category browsing, building detail pages, an about page, and an AI assistant page.
- Frontend pages pull their content from backend APIs rather than hardcoding the exhibition data.
3. Frontend subsystem
- Built with Vue 3, TypeScript, Vite, and Vue Router.
- src/pages/ contains the main screens, src/components/ holds reusable UI pieces like the main layout and timeline, and src/services/ centralizes API calls.
- public/image/ contains static image assets used in the exhibition experience.
4. Backend API subsystem
- Built with FastAPI and served via Uvicorn.
- backend/main.py is the application entrypoint, while backend/routers/ splits the API into domain routes: home, buildings, faq, and ai.
- This routing layout maps directly to the main product surfaces described in the README.
5. Core data model
- The backend is organized around four main tables: buildings, building_details, images, and faq.
- models.py and schemas.py define the persistence and response shapes used by the API, keeping the frontend-facing contract distinct from raw database storage.
6. Data access and persistence
- database.py and config.py handle MySQL connection setup and runtime configuration.
- The database is the system of record for the exhibition content; the frontend never reads the CSVs directly.
7. Content initialization pipeline
- The backend/sql/ directory contains the CSV source data plus SQL generation/loading scripts.
- write_sql.py is used to seed the database from CSV files, supporting repeatable initialization for the demo dataset.
- The repository also includes validation/check scripts such as check_all_tables.py and check_faq.py, suggesting the dataset is verified after import.
8. AI question-answering path
- The AI assistant is exposed through POST /ai/chat.
- The backend is configured to call ModelScope chat-completions services, so the AI experience is an external service integration layered on top of the curated exhibition content.
- The frontend’s AI page combines FAQ shortcuts with a chat UI, making FAQ content and LLM responses part of one user flow.
9. Content presentation strategy
- The home page aggregates high-level exhibition entry points: featured buildings, timeline, counts/statistics, and FAQ preview.
- Category pages act as a browse/filter layer, while building detail pages present structured deep content such as history, construction, materials, cultural value, image galleries, and related buildings.
- This means the frontend is not a generic CRUD app; it is a curated digital exhibit with multiple content depth levels.
10. Startup and deployment orchestration
- star_server.py is a convenience orchestrator that checks configuration, ensures the database is populated if needed, and then starts both backend and frontend services.
- This makes the repo usable as a single demo system while still keeping the runtime boundaries separate.
11. External dependencies and runtime boundaries
- Backend runtime: Python 3 with FastAPI, SQLAlchemy, Uvicorn, and PyMySQL-style MySQL connectivity implied by the config and seeding scripts.
- Frontend runtime: Node.js toolchain with Vite-based development server.
- External service: ModelScope is the only clearly identified remote AI dependency.
12. Diagramming summary
- A good architecture diagram should show: browser/UI on the left, Vue SPA in the middle, FastAPI routers as the backend API layer, MySQL as the content store, CSV/SQL scripts as the offline initialization path, and ModelScope as a separate AI service connected only through the AI router.
Main entry points: services API client · main.py API entry · App.vue Vue SPA · models.py Data model
Components 19
Presentation
Vue 3 SPA and user-facing content
- Browser · User entry point
- Vue SPA · App shell and routed exhibit experience
frontend/src/App.vue - Route map · Client-side page navigation
frontend/src/router/index.ts - Pages · Home, category, detail, about, and AI views
frontend/src/pages - Layout · Shared shell and timeline UI
frontend/src/components - API client · Centralized backend calls and AI chat client
frontend/src/services - Images · Exhibition image assets served by the frontend
frontend/public/image
Backend API
FastAPI entrypoint, routers, and data layer
- API entry · Application startup and router assembly
backend/main.py - Home API · Homepage aggregates and highlights
backend/routers/home.py - Buildings API · Category and building detail endpoints
backend/routers/buildings.py - FAQ API · FAQ content endpoints
backend/routers/faq.py - AI API · Chat endpoint for assistant flow
backend/routers/ai.py - Data model · Persistence models and response schemas
backend/models.py - DB config · MySQL connection and runtime configuration
backend/database.py - MySQL · System of record for exhibition content
Content & Init
CSV sources and database seeding scripts
- Seed SQL · CSV-to-database loading and validation support
backend/sql/write_sql.py - CSV content · Buildings, details, images, and FAQ datasets
backend/sql
Runtime
Convenience startup orchestration and external services
- Starter · Checks config, seeds data if needed, and starts services
star_server.py - ModelScope · Remote chat-completions provider
Connections 25
- Browser → Vue SPA: uses · Users interact with the Vue application
- Vue SPA → Route map: navigates · Client-side route transitions
- Route map → Pages: loads · Routes resolve to exhibit screens
- Vue SPA → Layout: composes · Shared shell and timeline are reused across pages
- Pages → API client: fetches data · Pages call the API layer for exhibit content
- API client → Home API: GET home · Homepage content and preview data
- API client → Buildings API: GET browse/detail · Category browsing and building detail data
- API client → FAQ API: GET faq · FAQ content for preview and page sections
- API client → AI API: POST chat · Assistant conversation requests
- API entry → Home API: mounts · FastAPI registers the home router
- API entry → Buildings API: mounts · FastAPI registers the buildings router
- API entry → FAQ API: mounts · FastAPI registers the FAQ router
- API entry → AI API: mounts · FastAPI registers the AI router
- Home API → Data model: reads shapes · Uses response and persistence definitions
- Buildings API → Data model: reads shapes · Uses response and persistence definitions
- FAQ API → Data model: reads shapes · Uses response and persistence definitions
- AI API → ModelScope: calls · Delegates chat completion to ModelScope
- Data model → DB config: persists via · ORM and DB access depend on connection setup
- DB config → MySQL: connects · Runtime database connection
- Seed SQL → CSV content: reads · Seeder consumes curated CSV content
- Seed SQL → MySQL: loads · Initializes the database tables
- Starter → Seed SQL: ensures data · Populates the database if needed
- Starter → API entry: starts backend · Launches the FastAPI service
- Starter → Vue SPA: starts frontend · Launches the Vue/Vite service
- Images → Pages: serves images · Frontend pages reference static exhibit images