# CLAUDE.md

## Project Overview

bitForum - Clean Architecture 기반 커뮤니티 플랫폼 (.NET 10.0)

## Solution Structure

```
Admin/           → Razor Pages 관리자 패널 (https://localhost:5000)
Web.Api/         → RESTful Minimal API (https://localhost:4000)
Application/     → CQRS Handler (in-house dispatcher)
Domain/          → Entity, ValueObject
Infrastructure/  → DB, Auth, Storage, Email
SharedKernel/    → AppSettings, Result Pattern
```

## Code Style Rules

- PK/ID 변수명: `memberID`, `userID` (camelCase + 대문자 ID)
- if 문은 반드시 `{}` 사용
- Tuple 속성은 각 필드를 별도 줄에 작성
- 외부 라이브러리 대신 순수 C# 우선 (FluentValidation 등 사용 안 함)
- 배열 패턴 사용 (체이닝 `||` 대신)
- Handler에서 직접 유효성 검사 (Data Annotation 사용 안 함)
- 파일 내용의 마지막 줄 제거
- EF Core 문은 항상 한 줄로 작성(단, 객체나 data 사용 시 여러 줄로 표시)
- 마이그레이션 migrationBuilder.Sql() 의 한글 문자열 리터럴은 반드시 `N'...'` (유니코드) 사용 — CP949/nvarchar 파손 방지

## Architecture Rules
- Domain layer has ZERO external dependencies
- Application layer defines interfaces, Infrastructure implements them
- All database access goes through EF Core DbContext (no repository pattern)
- Use the in-house dispatcher (ISender/IMediator) for all command/query handling (no MediatR)
- API layer is thin — endpoint definitions only

## Code Conventions

### Patterns We Use
- Primary constructors for DI
- Records for DTOs and commands
- Result<T> pattern for error handling (no exceptions for flow control)
- File-scoped namespaces
- Always pass CancellationToken to async methods (단, StackExchange.Redis 등 CancellationToken을 지원하지 않는 라이브러리는 예외)

### Patterns We DON'T Use (Never Suggest)
- Repository pattern (use EF Core directly)
- AutoMapper (write explicit mappings)
- Exceptions for business logic errors
- Stored procedures

## Architecture

- CQRS: in-house dispatcher (ISender/IMediator, Application/Messaging/Sender.cs; MediatR 제거 2026-07)
- Auth: API는 Member 엔티티 + PBKDF2 해싱, Admin은 ASP.NET Identity
- DB: SQL Server (AppDbContext + IdentityDbContext)
- Cache: Redis (StackExchange.Redis)
- DI: 각 레이어별 DependencyInjection.cs
  - `AddApplication()` → 리플렉션으로 ICommandHandler/IQueryHandler 전체 등록 (+ Sender/ISender/IMediator)
  - `AddApiInfrastructure()` → API 전용 (JWT Bearer + 모든 서비스)
  - `AddAdminInfrastructure()` → Admin 전용 (Identity + 모든 서비스)
  - `AddPresentation()` → Swagger, ExceptionHandler

## Build & Run

```bash
# Solution build
dotnet build Backend.slnx

# API 실행
dotnet run --project Web.Api

# Admin 실행
dotnet run --project Admin

# Migration
dotnet ef migrations add <Name> --project Infrastructure --startup-project Admin --context AppDbContext
dotnet ef database update --project Infrastructure --startup-project Admin --context AppDbContext
```

## Key Patterns

- Result Pattern: `Result<T>` / `Error` (SharedKernel/Results/)
- ErrorType: Validation(400), Problem(400), Unauthorized(401), NotFound(404), Forbidden(403), Conflict(409), MethodNotAllowed(405)
- Endpoint: `IEndpoint` 인터페이스 → `MapEndpoint()` 구현
- Feature 구조: `Application/Features/{Domain}/{Action}/Command.cs, Handler.cs, Response.cs`

## 사용 Domain
- https://bitforum.io -> 사용자 단 사용 URL
- https://admin.bitforum.io  -> 관리자 단 사용 URL
- https://api.bitforum.io -> 사용자 단 통신 API URL

## Upbit.com API 문서
https://docs.upbit.com/kr/reference/api-overview
https://docs.upbit.com/kr/reference/auth
https://docs.upbit.com/kr/reference/rate-limits
https://docs.upbit.com/kr/reference/rest-api-guide
https://docs.upbit.com/kr/reference/websocket-guide
https://docs.upbit.com/kr/reference/list-trading-pairs
https://docs.upbit.com/kr/reference/list-candles-seconds
https://docs.upbit.com/kr/reference/list-candles-minutes
https://docs.upbit.com/kr/reference/list-candles-days
https://docs.upbit.com/kr/reference/list-candles-weeks
https://docs.upbit.com/kr/reference/list-candles-months
https://docs.upbit.com/kr/reference/list-candles-years
https://docs.upbit.com/kr/reference/recent-trades-history
https://docs.upbit.com/kr/reference/list-tickers
https://docs.upbit.com/kr/reference/list-quote-tickers
https://docs.upbit.com/kr/reference/list-orderbooks
https://docs.upbit.com/kr/reference/list-orderbook-instruments
https://docs.upbit.com/kr/reference/websocket-ticker
https://docs.upbit.com/kr/reference/websocket-trade
https://docs.upbit.com/kr/reference/websocket-orderbook
https://docs.upbit.com/kr/reference/websocket-candle
https://docs.upbit.com/kr/reference/websocket-myorder
https://docs.upbit.com/kr/reference/websocket-myasset
https://docs.upbit.com/kr/reference/list-subscriptions