5.0 KiB
5.0 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Repository Overview
This is the live-forum server repository, a live streaming forum platform with three main components:
- webapi/ - Main API service (.NET 8 Web API) for the forum application
- crawler/ - Python-based data crawlers for ByteDance live streaming platforms
- admin/ - Backend admin panel (ZrAdminNetCore framework, .NET 8 + Vue)
Build and Run Commands
WebAPI (Forum API)
# Navigate to solution directory
cd webapi/LiveForum
# Restore dependencies
dotnet restore LiveForum.sln
# Build
dotnet build LiveForum.sln
# Run in development mode
dotnet run --project LiveForum.WebApi
# Run in release mode
dotnet run --project LiveForum.WebApi --configuration Release
The API runs on http://*:8080 by default (configured in appsettings.json).
Crawler (Python)
# Commerce crawler
cd crawler/commerce
pip install -r requirements.txt
playwright install chromium
# Login (opens browser for manual login)
python main.py login
# Fetch data
python main.py fetch-daren
python main.py daemon # Daemon mode for scheduled crawling
# Entertainment crawler
cd crawler/entertainment
pip install -r requirements.txt
playwright install chromium
python main.py login
python main.py crawl
python main.py daemon # Daemon mode
Admin Panel
# Backend (.NET)
cd admin/ZrAdminNetCore
dotnet restore ZRAdmin.sln
dotnet run --project ZR.Admin.WebApi
# Frontend (Vue)
cd admin/ZrAdminNetCore/ZR.Vue
npm install
npm run dev
Architecture
WebAPI Solution Structure
webapi/LiveForum/
├── LiveForum.WebApi # Controllers, Background Services, Program.cs entry point
├── LiveForum.Service # Business logic implementation
├── LiveForum.IService # Service interfaces
├── LiveForum.Model # DTOs, Entities, Enums
├── LiveForum.Code # Infrastructure (JWT, Redis, Middleware, Utilities)
├── LiveForum.Repository # Data access layer
└── LiveForum # Core shared library
Key Technologies
- ORM: FreeSql (SQL Server)
- DI Container: Autofac (with property injection for services)
- Caching: Redis (StackExchange.Redis)
- Background Jobs: Hangfire (SQL Server storage)
- Configuration: AgileConfig (remote config center with hot reload)
- Logging: Serilog (console + file sinks)
- Authentication: JWT tokens
- WeChat: SKIT.FlurlHttpClient.Wechat.Api
- File Storage: Tencent COS
Service Registration Pattern
Services in LiveForum.Service are automatically registered via Autofac assembly scanning:
autofac.RegisterAssemblyTypes(Assembly.Load("LiveForum.Service"))
.AsImplementedInterfaces()
.PropertiesAutowired()
.InstancePerLifetimeScope();
Exceptions: SensitiveWordService and WechatApiClientManager are registered as singletons in Program.cs.
Background Services
LikeMessageConsumer- Processes like notifications from RedisCommentReplyMessageConsumer- Processes comment reply notificationsCustomMessageConsumer- Custom message processingLikeBatchSyncService- Batch syncs likes to databaseViewBatchSyncService- Batch syncs view countsFlowerBatchSyncService- Batch syncs flower (gift) counts
Scheduled Jobs (Hangfire)
streamer-flower-reset- Resets streamer flower counts monthly (1st day, 3 AM)
Configuration
Configuration sources (priority order):
- AgileConfig (remote, supports hot reload)
- appsettings.json
Key configuration sections:
ConnectionStrings:LiveForumConnection- SQL Server connectionRedis:Configuration- Redis connection stringJwtTokenConfig- JWT secret, issuer, audience, expirationWechat- WeChat Mini Program AppId/AppSecretTENCENT_COS- Tencent COS storage settingsSensitiveWord- Sensitive word filtering configuration
API Endpoints
Access Swagger UI at: http://localhost:8080/swagger
Main controller areas:
/api/Auth- Authentication (WeChat login)/api/Posts- Posts CRUD/api/PostComments- Comments/api/UsersInfo- User profiles/api/UserFollow- Follow relationships/api/Streamers- Streamer data/api/Flowers- Gift/flower system/api/Messages- Notifications/api/Search- Search functionality
Crawler Structure
Both crawlers share similar architecture:
crawler/{commerce,entertainment}/
├── config/settings.py # Configuration
├── core/
│ ├── cookie_manager.py # Cookie persistence
│ ├── browser_login.py # Playwright browser automation
│ └── api_client.py # API calls with cookies
├── services/
│ └── crawler_service.py # Data fetching logic
├── data/ # Output JSON files
├── logs/ # Log files
└── main.py # CLI entry point
Cookies are saved to data/cookies.json after manual browser login.