# CLAUDE.md ## Project Overview DPOT - Clean Architecture 기반 Creators Support and donate platform (.NET 10.0) - **Framework**: .NET 10.0, ASP.NET Core - **CQRS**: MediatR 14.0 - **ORM**: Entity Framework Core 10.0 (SQL Server) - **Cache**: StackExchange.Redis 10.0 - **Logging**: Serilog 10.0 ## Solution Structure ``` Admin/ → Razor Pages 관리자 패널 (https://localhost:5000) Web.Api/ → RESTful Minimal API (https://localhost:4000) Application/ → CQRS Handler (MediatR) └── Features/ ├── Api/ → Auth, Banner, Document, Faq, Forum, Member, MyPage, Popup └── Admin/ → Banner, Cache, Channel, Document, Faq, Forum, Member, MemberGrade, Popup, ReferenceData Domain/ → Entity, ValueObject Infrastructure/ → DB, Auth, Storage, Email ├── Authentication/ → JWT, Identity ├── Cache/ → Redis ├── Chat/ → WebSocket 채팅 ├── Forum/ → 게시판 비즈니스 로직 ├── Messaging/ → Email (SMTP, MimeKit) ├── Persistence/ → AppDbContext, IdentityDbContext, Migrations ├── Storage/ → 파일 업로드 └── Extensions/ → 확장 메서드 SharedKernel/ → AppSettings, Result Pattern Database/ → SQL 배포 스크립트 (deploy-app.sql, deploy-identity.sql, deploy-missing.sql) ``` ## API Endpoints (Web.Api/Endpoints/) Auth, Banner, Config, Document, Faq, Forum, MyPage, Popup, Wallet ## Code Style Rules - PK/ID 변수명: `memberID`, `userID` (camelCase + 대문자 ID) - if 문은 반드시 `{}` 사용 - Tuple 속성은 각 필드를 별도 줄에 작성 - 외부 라이브러리 대신 순수 C# 우선 (FluentValidation 등 사용 안 함) - 배열 패턴 사용 (체이닝 `||` 대신) - Handler에서 직접 유효성 검사 (Data Annotation 사용 안 함) - 파일 내용의 마지막 줄 제거 - EF Core 문은 항상 한 줄로 작성(단, 객체나 data 사용 시 여러 줄로 표시) ## 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 Mediator for all command/query handling - API layer is thin — endpoint definitions only ## Code Conventions ### Patterns We Use - Primary constructors for DI - Records for DTOs and commands - Result 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: MediatR (Command/Query → Handler) - Auth: API는 Member 엔티티 + PBKDF2 해싱, Admin은 ASP.NET Identity - DB: SQL Server (AppDbContext + IdentityDbContext) - Cache: Redis (StackExchange.Redis) - Real-time: SignalR WebSocket (채팅 /hubs/chat) - DI: 각 레이어별 DependencyInjection.cs - `AddApplication()` → MediatR 전체 Handler 등록 - `AddApiInfrastructure()` → API 전용 (JWT Bearer + 모든 서비스) - `AddAdminInfrastructure()` → Admin 전용 (Identity + 모든 서비스) - `AddPresentation()` → Swagger, ExceptionHandler ## Build & Run ```bash # Solution build dotnet build Admin/Admin.slnx # API 실행 dotnet run --project Web.Api # Admin 실행 dotnet run --project Admin # Migration dotnet ef migrations add --project Infrastructure --startup-project Admin --context AppDbContext dotnet ef database update --project Infrastructure --startup-project Admin --context AppDbContext ``` ## Key Patterns - Result Pattern: `Result` / `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://dpot.web.or.kr -> 사용자 단 사용 URL - https://admin.dpot.web.or.kr -> 관리자 단 사용 URL - https://api.dpot.web.or.kr -> 사용자 단 통신 API URL ## Payment Gateway 결제 대행사 API