Skip to content

Cheondongmin/tarot-mistic-ktor

Repository files navigation

Tarot Mystic Backend API

타로 미스틱 서비스의 백엔드 API 서버

프로젝트 개요

기존 Spring Boot 기반 프로젝트를 Ktor 프레임워크로 마이그레이션한 Kotlin 백엔드 서비스입니다.

아키텍처

src/main/kotlin/com/tarotmystic/
├── app/
│   ├── application/          # 애플리케이션 서비스 (Facade 패턴)
│   │   └── dto/             # 애플리케이션 계층 DTO
│   ├── domain/              # 도메인 모델 및 비즈니스 로직
│   │   ├── auth/           # 인증 관련 도메인
│   │   ├── email/          # 이메일 관련 도메인
│   │   ├── tarot/          # 타로 관련 도메인
│   │   └── user/           # 사용자 관련 도메인
│   ├── infrastructure/      # 외부 시스템 연동
│   │   ├── auth/           # JWT, 암호화
│   │   ├── database/       # MongoDB 연결
│   │   ├── email/          # 이메일 전송
│   │   ├── repository/     # 데이터 저장소 구현
│   │   └── telegram/       # 텔레그램 봇
│   └── interfaces/          # 외부 인터페이스 (REST API)
│       ├── auth/           # 인증 API
│       ├── common/         # 공통 응답 DTO
│       └── tarot/          # 타로 API
├── config/                  # 설정 클래스
└── Application.kt          # 메인 애플리케이션

환경 설정

1. 설정 파일 준비

cp src/main/resources/application.yaml.example src/main/resources/application.yaml

2. 필수 설정 값 입력

application.yaml 파일에서 다음 값들을 실제 환경에 맞게 수정:

app:
  database:
    mongodb:
      uri: "mongodb+srv://username:password@cluster.mongodb.net/database"
      database: "your_database_name"
  
  security:
    jwt:
      secret: "your-256-bit-secret-key"
  
  mail:
    username: "your-email@gmail.com"
    password: "your-app-password"
  
  message:
    bot-token: "your-telegram-bot-token"
    chat-id: "your-telegram-chat-id"

3. 애플리케이션 실행

./gradlew run

서버는 기본적으로 http://localhost:8080에서 실행됩니다.

API 엔드포인트

타로 관련

  • POST /api/v1/tarot/add - 타로 결과 저장
  • GET /api/v1/tarot/list - 타로 결과 목록 조회 (페이징)
  • POST /api/v1/tarot/message - 관리자에게 메시지 전송
  • POST /api/v1/tarot/image-history - 이미지 히스토리 저장

인증 관련

  • POST /api/v1/auth/register - 회원가입
  • POST /api/v1/auth/login - 로그인
  • GET /api/v1/auth/verify-email - 이메일 인증

응답 형식

모든 API는 통일된 응답 형식을 사용합니다:

{
  "resultType": "SUCCESS|INVALID_PARAMETER|SERVER_ERROR",
  "message": "응답 메시지",
  "data": { }
}

빌드 및 배포

개발 환경

./gradlew run

프로덕션 빌드

./gradlew buildFatJar
java -jar build/libs/tarot-mistic-ktor-all.jar

Docker

docker build -t tarot-mystic-ktor .
docker run -p 8080:8080 tarot-mystic-ktor

About

Ktor를 사용한 api 백엔드 프로젝트

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages