# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

This is a .NET 8 ASP.NET Core e-commerce affiliate tracking API server called "molilian" that handles multiple affiliate platforms including Taobao, JD.com, PDD (拼多多), and others. The system processes coupon tracking, link generation, order tracking, and data reporting for affiliate marketing operations.

## Architecture

- **molilian.api**: ASP.NET Core Web API project with controllers for admin and public endpoints
- **molilian.core**: Core business logic library containing all platform integrations and data processing
- **taobao-sdk-netcore-auto**: Third-party Taobao SDK for API integration
- **YunhuiKit**: External dependency for additional utilities

The system follows a layered architecture:
- Controllers handle HTTP requests/responses
- Core classes contain business logic for different platforms (taobao, jd, pdd, etc.)
- Plus classes provide additional utilities and managers
- DTO classes define data transfer objects

## Development Commands

### Build
```bash
dotnet build molilian.sln
```

### Run API Server
```bash
cd molilian.api
dotnet run
```
The API will be available at http://localhost:8186 with Swagger UI at /swagger

### Run with Docker
```bash
cd molilian.api
docker-compose up
```

### Restore Dependencies
```bash
dotnet restore molilian.sln
```

## Key Platform Integrations

The system integrates with multiple Chinese e-commerce platforms:

- **Taobao/Tmall**: `molilian.core/Core/taoke/` - Handles Taobao affiliate operations
- **JD.com**: `molilian.core/Core/jd/` - JD affiliate platform integration  
- **PDD (拼多多)**: `molilian.core/Core/pdd/` - Pinduoduo affiliate operations
- **Kuaishou**: `molilian.core/Core/ks/` - Short video platform integration
- **Douyin**: `molilian.core/Core/douyin/` - TikTok China platform
- **CPS Platforms**: `molilian.core/Core/cps/` - Various CPS affiliate networks

## Database Configuration

The application uses MySQL with Redis for caching. Configuration is handled through environment variables:
- `DBConfig`: MySQL connection string
- `RedisConfig`: Redis connection string  
- `EndPoint`: Deployment endpoint identifier

Multiple environment profiles are configured in launchSettings.json for different deployment scenarios.

## API Structure

- **Admin Controllers** (`Controllers/admin/`): Management endpoints for platform configurations, user management, and reporting
- **Public Controllers** (`Controllers/public/`): Public-facing APIs for link generation, task processing, and affiliate operations

## Core Components

- **Risk Control**: `molilian.core/Core/taoke/RiskControlCore.cs` - Handles fraud detection and risk management
- **Order Tracking**: `molilian.core/Core/taoke/OrderTrackingCore.cs` - Tracks affiliate order conversions
- **Union Parse**: `molilian.core/Core/taoke/UnionParseCore/` - Parses and converts affiliate links
- **Proxy Management**: `molilian.core/Plus/ProxyManager.cs` - Manages proxy rotation for API calls
- **Task Workers**: `molilian.core/Worker/` - Background job processing

## Logging

Extensive logging is implemented across all platforms in `molilian.core/Core/log/` with separate log handlers for each affiliate platform.

## Docker Support

The project includes Docker support with Dockerfile and docker-compose.yml for containerized deployment.