This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
WoniuNote is a high-performance blog system with a hybrid architecture: the project contains two parallel backend implementations (C++ and Python), but the C++ backend is the active development target. The Python Flask backend is legacy code.
Current branch: dev_cpp (C++ development)
Main branch: master
[Frontend: Vue 3 + Vite + Element Plus]
↓ (API calls)
[Nginx] → Reverse proxy / static file serving
↓ (/api/*)
[C++ Backend: Drogon framework]
↓
[MySQL 8.0 + Redis]
Use the provided scripts instead of manual commands:
# Development mode (frontend with hot-reload on :8888)
bash start_app.sh dev
# Production mode (frontend built + served by Nginx on :80/:443)
bash start_app.sh prod
# Stop all services
bash stop_app.sh
# Restart services
bash restart_app.sh [prod|dev]cd backend_cpp
# Build (uses build.sh which wraps CMake + vcpkg)
./build.sh
# Manual build
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build . --config Release -j8
# Run (after build)
cd build
./woniunote_backend # Runs on port 5173cd frontend
# Install dependencies
npm install
# Development server (port 8888)
npm run dev
# Production build
npm run buildThe Python tests cover the legacy backend and integration testing:
# Run all tests with coverage (recommended)
python tests/run_all_tests.py
# Fast mode (skip slow/integration tests)
python tests/run_all_tests.py --fast
# Debug mode (verbose output)
python tests/run_all_tests.py --debug
# Sequential execution (no parallelization)
python tests/run_all_tests.py --sequential
# Direct pytest commands
pytest tests/unit/ -v
pytest tests/integration/ -v
pytest tests/ -v --cov=woniunote --cov-report=htmlPre-commit hooks are configured. Install with:
pip install pre-commit
pre-commit installTools configured:
- black: Code formatting (line length: 100)
- isort: Import sorting
- flake8: Linting
- mypy: Type checking
- main.cc: Application entry point
- core/: Infrastructure modules
config.h/cc: Configuration loading from config.jsondatabase.h/cc: Database connection utilitiessecurity.h/cc: JWT token generation/validation, bcrypt password hashinglogger.h/cc: Logging utilities using spdlog
- controllers/: API endpoint handlers (Auth, Article, Comment, User, Admin, etc.)
- models/: Data models (User, Article, Comment, Favorite, Credit, MathTraining)
- filters/: Middleware (AuthFilter for JWT validation, AdminFilter for admin access, RateLimitFilter)
- third_party/: Contains bcrypt headers (bcrypt.h, bcrypt.cpp)
backend_cpp/config.json: Development configuration (backend runs on port 5173)backend_cpp/config.prod.json: Production configuration- Key config sections:
listeners: HTTP server binding (address/port)db_clients: MySQL connection settingsredis_clients: Redis connection for cachingcustom_config: JWT secrets, CORS origins, token expiration
- src/api/: Axios API wrappers (communicate with backend on :5173)
- src/components/: Reusable Vue components
- src/views/: Page components (Home, ArticleDetail, Login, admin/, etc.)
- src/stores/: Pinia state management
- src/router/: Vue Router configuration
| Service | Port | Notes |
|---|---|---|
| C++ Backend | 5173 | Drogon HTTP server |
| Frontend (dev) | 8888 | Vite dev server |
| Frontend (prod) | 80/443 | Served by Nginx |
C++ Backend (via vcpkg):
- drogon (web framework)
- jwt-cpp (JWT tokens)
- openssl (cryptography)
- jsoncpp (JSON parsing)
- hiredis (Redis client)
- libmariadb (MySQL client)
- spdlog (logging)
Frontend (npm):
- vue 3.4
- vite 5
- element-plus 2.5
- pinia (state management)
- vue-router
- axios
The project is transitioning from Python Flask to C++ Drogon. When working on features:
- Prioritize the C++ backend implementation
- The Python backend (
woniunote/directory) is maintained for reference but not actively developed - API endpoints should match between implementations for compatibility
CREATE DATABASE woniunote CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'woniunote_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON woniunote.* TO 'woniunote_user'@'localhost';
FLUSH PRIVILEGES;For production deployment on Ubuntu, use:
sudo bash scripts/setup_ubuntu.shThis installs system dependencies, MySQL, Redis, Node.js, vcpkg, and compiles the C++ backend.