Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Git
.git
.gitignore

# Python
__pycache__
*.pyc
*.pyo
*.pyd
.Python
*.so
*.egg
*.egg-info
dist
build

# Virtual Environment
.venv
venv/
ENV/
env/

# IDE
.vscode
.idea
*.swp
*.swo
*~

# Environment
.env
.env.local

# Documentation
*.md
!README.md

# Database
*.db
*.sqlite
*.sqlite3

# Logs
*.log
logs/

# OS
.DS_Store
Thumbs.db

# Docker
Dockerfile
docker-compose.yml
.dockerignore

# CI/CD
.github

# Others
alembic.ini
manage_db.py
create_migration.py
init_questions.py
credentials/
130 changes: 128 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,143 @@ pip install -r requirements.txt

## μ‹€ν–‰

### 둜컬 개발 ν™˜κ²½

개발 μ„œλ²„(Uvicorn) μ‹€ν–‰:

```bash
uvicorn app.main:app --reload --port 8000
```

API λ¬Έμ„œ: `http://127.0.0.1:8000/docs`

### Dockerλ₯Ό μ‚¬μš©ν•œ μ‹€ν–‰

#### 1. ν™˜κ²½ λ³€μˆ˜ μ„€μ •
`.env` νŒŒμΌμ— AWS RDS 및 ν•„μš”ν•œ 섀정을 μΆ”κ°€ν•˜μ„Έμš”:

```env
# λ°μ΄ν„°λ² μ΄μŠ€ (AWS RDS)
DB_HOST=your-rds-endpoint.region.rds.amazonaws.com
DB_PORT=3306
DB_USER=admin
DB_PASSWORD=your_password
DB_NAME=caring_voice

# AWS μ„€μ •
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=ap-northeast-2
S3_BUCKET_NAME=your-bucket-name

# Google Cloud μ„€μ •
GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/google-credentials.json
```

#### 2. Docker Compose둜 μ„œλ²„ μ‹€ν–‰

```bash
# λΉŒλ“œ 및 μ‹€ν–‰
docker-compose up -d

# 둜그 확인
docker-compose logs -f

# 쀑지
docker-compose down
```

#### 3. API μ ‘κ·Ό
- 둜컬: `http://localhost:8000`
- API λ¬Έμ„œ: `http://localhost:8000/docs`

## λ°μ΄ν„°λ² μ΄μŠ€ λ§ˆμ΄κ·Έλ ˆμ΄μ…˜

### μžλ™ λ§ˆμ΄κ·Έλ ˆμ΄μ…˜
μ„œλ²„ μ‹œμž‘ μ‹œ μžλ™μœΌλ‘œ λ§ˆμ΄κ·Έλ ˆμ΄μ…˜μ΄ μ‹€ν–‰λ©λ‹ˆλ‹€.

### μˆ˜λ™ λ§ˆμ΄κ·Έλ ˆμ΄μ…˜
```bash
# λ§ˆμ΄κ·Έλ ˆμ΄μ…˜ 파일 생성
alembic revision --autogenerate -m "컀밋 λ©”μ‹œμ§€"

# λ§ˆμ΄κ·Έλ ˆμ΄μ…˜ μ‹€ν–‰
alembic upgrade head

# λ§ˆμ΄κ·Έλ ˆμ΄μ…˜ λ‘€λ°±
alembic downgrade -1
```

## 질문 데이터 μ΄ˆκΈ°ν™”

질문 ν…œν”Œλ¦Ώμ„ λ°μ΄ν„°λ² μ΄μŠ€μ— μ €μž₯ν•©λ‹ˆλ‹€:

```bash
python -m app.main
python init_questions.py
```

이 λͺ…λ Ήμ–΄λŠ” λ‹€μŒ μΉ΄ν…Œκ³ λ¦¬μ˜ μ§ˆλ¬Έλ“€μ„ μžλ™μœΌλ‘œ μΆ”κ°€ν•©λ‹ˆλ‹€:
- emotion (14개)
- stress (10개)
- physical (10개)
- social (10개)
- self_reflection (15개)

총 59개의 질문이 λ°μ΄ν„°λ² μ΄μŠ€μ— μ €μž₯λ©λ‹ˆλ‹€.

## ν™˜κ²½ λ³€μˆ˜ μ„€μ •

ν”„λ‘œμ νŠΈ λ£¨νŠΈμ— `.env` νŒŒμΌμ„ μƒμ„±ν•˜κ³  λ‹€μŒ 값을 μ±„μš°μ„Έμš”. μ˜ˆμ‹œλŠ” `.env.example` μ°Έκ³ .

```
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_REGION=ap-northeast-2
S3_BUCKET_NAME=your-bucket
S3_PREFIX=voices
```

### Google Cloud μ„€μ •
```
# μ„œλΉ„μŠ€ 계정 ν‚€ 파일 경둜 μ„€μ • (Speech-to-Text, Natural Language API 곡톡)
GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service-account-key.json
```

### λ°μ΄ν„°λ² μ΄μŠ€ μ„€μ •
```
# MySQL λ°μ΄ν„°λ² μ΄μŠ€ μ—°κ²° 정보
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=table_name
```

`.env`λŠ” `app/database.py`μ—μ„œ μžλ™ λ‘œλ“œλ©λ‹ˆλ‹€.

> πŸ’‘ **배포 ν™˜κ²½**: 운영 ν™˜κ²½μ—μ„œλŠ” ν™˜κ²½λ³€μˆ˜λ₯Ό μ‹œμŠ€ν…œμ— 직접 μ„€μ •ν•˜κ±°λ‚˜, `.env` νŒŒμΌμ„ μ‚¬μš©ν•˜μ§€ μ•Šκ³  μ»¨ν…Œμ΄λ„ˆ/Docker의 ν™˜κ²½λ³€μˆ˜ 섀정을 μ‚¬μš©ν•˜μ„Έμš”.

## API μ—”λ“œν¬μΈνŠΈ

### μŒμ„± κ΄€λ ¨ API
- `POST /voices/upload`: μŒμ„± 파일 μ—…λ‘œλ“œ + STT λ³€ν™˜
- `POST /voices/transcribe`: STT λ³€ν™˜λ§Œ
- `POST /voices/{voice_key}/analyze-emotion`: S3 파일 감정 뢄석
- `GET /voices`: 파일 λͺ©λ‘ 쑰회

### ν…μŠ€νŠΈ 뢄석 API (Google Natural Language)
- `POST /nlp/sentiment`: ν…μŠ€νŠΈ 감정 뢄석
- `POST /nlp/entities`: μ—”ν‹°ν‹° μΆ”μΆœ
- `POST /nlp/syntax`: ꡬ문 뢄석
- `POST /nlp/analyze`: μ’…ν•© ν…μŠ€νŠΈ 뢄석

## ν”„λ‘œμ νŠΈ ꡬ쑰

```
caring-voice/
β”œβ”€β”€ app/
β”‚ β”œβ”€β”€ __init__.py
β”‚ └── main.py # 메인 μ—”νŠΈλ¦¬ 포인트
β”‚ └── main.py # FastAPI μ—”νŠΈλ¦¬ 포인트 및 μ—”λ“œν¬μΈνŠΈ
β”œβ”€β”€ .gitignore
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
Expand Down
60 changes: 60 additions & 0 deletions alembic.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Alembic μ„€μ • 파일

[alembic]
# λ§ˆμ΄κ·Έλ ˆμ΄μ…˜ 파일 μœ„μΉ˜
script_location = migrations

# 버전 파일 이름 ν˜•μ‹
file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s

# SQLAlchemy URL
sqlalchemy.url = driver://user:pass@localhost/dbname

# μ„œλ²„ 인코딩
prepend_sys_path = .

# 둜그 레벨
log_level = INFO

# UTC νƒ€μž„μŠ€νƒ¬ν”„ μ‚¬μš©
date_format = %%Y-%%m-%%d %%H:%%M:%%S

# μ œμ™Έν•  ν…Œμ΄λΈ” νŒ¨ν„΄
exclude_tables =

[post_write_hooks]

# 둜그 좜λ ₯
[loggers]
keys = root,sqlalchemy,alembic

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console
qualname =

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[logger_alembic]
level = INFO
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
3 changes: 3 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from dotenv import load_dotenv # type: ignore
load_dotenv()

Loading