여러 외부 서비스(LLM, Memory, TTS)를 통합하여 AI 캐릭터와의 채팅 프로세스를 처리하고 클라이언트에게 제공하는 Clean Architecture 기반 .NET 8.0 API 서버입니다.
- .NET 8.0: C# 12, nullable reference types
- ASP.NET Core 8.0: Controllers 기반 REST API
- Entity Framework Core 8.0: Code-First, SQL Server
- Redis: StackExchange.Redis 세션 관리
- Authentication: JWT + Google OAuth2 PKCE
- Testing: xUnit + Moq + FluentAssertions
- Container: Docker + Docker Compose
┌─────────────────── Presentation Layer ──────────────────┐
│ ProjectVG.Api (Controllers, Middleware, Authentication) │
├─────────────────── Application Layer ───────────────────┤
│ ProjectVG.Application (Services, DTOs, Business Logic) │
├─────────────────── Domain Layer ────────────────────────┤
│ ProjectVG.Domain (Entities, Repositories, Domain Rules) │
├─────────────────── Infrastructure Layer ────────────────┤
│ ProjectVG.Infrastructure (Database, External Services) │
└─────────────────── Common/Tests ────────────────────────┘
- HTTP-WebSocket Bridge: 비동기 장기 실행 작업의 브리지 패턴
- ChatService 오케스트레이션: Facade 패턴으로 복합 처리 파이프라인 관리
- 외부 서비스 연동: LLM, Memory, TTS 서비스 통합
- 페이지네이션: 대화 기록 조회
- JWT 토큰: Access (15분) + Refresh (30일) 이중 토큰
- OAuth2 PKCE: Google 인증, 게스트 로그인
- Redis 세션: 토큰 관리 및 blacklist 지원
- 다중 헤더: Authorization, X-Access-Credit, X-Refresh-Credit
- 거래 기록: 완전한 audit trail
- 동시성 제어: Optimistic concurrency 지원
- 하이브리드 설정: JSON 필드 구성 + 직접 프롬프트 입력
- 소유권 모델: 시스템/공개/개인 캐릭터 권한 관리
- 프롬프트 생성: 설정 기반 SystemPrompt 구성
상세 구현: 각 기능의 구체적인 코드 구현과 아키텍처는 features.md를 참고하세요.
- 메모리 관리: ArrayPool 버퍼 재사용, IMemoryOwner 활용
- 비동기 패턴: I/O 작업 async/await 적용
- 데이터베이스: 연결 복원력 (지수 백오프 재시도), 자동 마이그레이션
- JWT 보안: 32자 이상 암호키, 다중 소스 헤더 지원
- OAuth2 PKCE: Proof Key for Code Exchange, CSRF 방지
- 입력 검증: Data Annotations + 도메인 레벨 검증
- SQL Injection 방지: EF Core 매개변수화 쿼리
- 인증 시스템 테스트: JWT Provider, Token Service, Auth Service, JWT Filter 테스트 포함
- 다층 테스트: Unit Tests (Mock), Integration Tests (실제 DB), End-to-End Tests (API)
- 성능 테스트: 메모리 최적화 검증
| 분류 | 메소드 | 엔드포인트 | 설명 | 인증 |
|---|---|---|---|---|
| 인증 | POST | /api/v1/auth/refresh |
Access Token 갱신 | ✓ |
| POST | /api/v1/auth/logout |
세션 종료 | ✓ | |
| POST | /api/v1/auth/guest-login |
게스트 인증 | - | |
| GET | /auth/oauth2/authorize/{provider} |
OAuth2 시작 | - | |
| 캐릭터 | GET | /api/v1/character |
캐릭터 조회 | ✓ |
| POST | /api/v1/character/individual |
JSON 설정 캐릭터 생성 | ✓ | |
| POST | /api/v1/character/systemprompt |
시스템 프롬프트 캐릭터 생성 | ✓ | |
| GET | /api/v1/character/my |
내 캐릭터 조회 | ✓ | |
| 채팅 | POST | /api/v1/chat |
채팅 메시지 처리 | ✓ |
| 크레딧 | GET | /api/v1/credits/balance |
잔액 조회 | ✓ |
| GET | /api/v1/credits/history |
거래 내역 조회 | ✓ |
- User: OAuth2 기반 사용자, 고유 UID, 크레딧 잔액
- Character: 하이브리드 구성 (JSON/Direct), 공개/개인 구분
- ConversationHistory: 역할별 메시지 저장
- CreditTransaction: 거래 기록, 소스 추적
- Optimistic Concurrency: RowVersion 타임스탬프
- JSON 컬럼: 캐릭터 설정 저장
- Decimal 정밀도: Decimal(18,2) 크레딧 계산
- 인덱스: 사용자별, 캐릭터별 조회 최적화
ProjectVG.Api/ # Presentation Layer
├── Controllers/ # REST API 컨트롤러
├── Middleware/ # 전역 예외 처리, WebSocket
├── Filters/ # JWT 인증 필터
└── Models/ # Request/Response DTO
ProjectVG.Application/ # Application Layer
├── Services/ # 비즈니스 로직 서비스
├── Models/ # 애플리케이션 DTO
└── Commands/ # 명령 객체
ProjectVG.Domain/ # Domain Layer
├── Entities/ # 도메인 엔티티
├── Repositories/ # 리포지토리 인터페이스
└── Common/ # 기본 엔티티, 값 객체
ProjectVG.Infrastructure/ # Infrastructure Layer
├── Persistence/ # EF Core DbContext
├── Auth/ # JWT, OAuth2 구현
├── Integrations/ # 외부 서비스 클라이언트
└── Services/ # 인프라 서비스
ProjectVG.Tests/ # Test Suite
├── Api/ # 컨트롤러, 필터 테스트
├── Application/ # 서비스 통합 테스트
├── Auth/ # 인증 시스템 테스트
└── Infrastructure/ # 리포지토리, 외부 서비스 테스트
- LLM Service: AI 모델 추론 처리
- Memory Service: 대화 컨텍스트 관리
- TTS Service: 텍스트 음성 변환
- SQL Server: 주 데이터베이스 (사용자, 캐릭터, 대화)
- Redis: 세션 관리, 토큰 캐시