AI ํ๋ก ๋ฆฌ๋ฉ ์๋น์ค ๋ฐฑ์๋ API
Service โข
Frontend Repo
ArcanaWhisper Backend๋ AI ํ๋ก ๋ฆฌ๋ฉ ์๋น์ค์ API ์๋ฒ์
๋๋ค. AWS Lambda ๊ธฐ๋ฐ ์๋ฒ๋ฆฌ์ค ์ํคํ
์ฒ๋ก ๊ตฌ์ถ๋์์ผ๋ฉฐ, Google Gemini์ LangChain์ ํ์ฉํ์ฌ ํ๋ก ํด์์ ์ ๊ณตํฉ๋๋ค.
์๋ฒ๋ฆฌ์ค - AWS Lambda๋ก ์ด์ ๋น์ฉ ์ต์ ํ
ํ์ฅ์ฑ - API Gateway + Lambda ์๋ ์ค์ผ์ผ๋ง
๋ณด์ - Firebase Auth ํ ํฐ ๊ฒ์ฆ, SSM Parameter Store ์ํฌ๋ฆฟ ๊ด๋ฆฌ
Category
Technology
Language
Python 3.11
Compute
AWS Lambda (Serverless)
API
API Gateway HTTP API
AI/LLM
LangChain + Google Gemini
Database
Firebase Firestore
Auth
Firebase Authentication
Secrets
AWS SSM Parameter Store
IaC
AWS SAM
Category
Technology
CI/CD
GitHub Actions
Deployment
AWS SAM CLI
Monitoring
CloudWatch Logs
๊ธฐ๋ฅ
์ค๋ช
AI ํ๋ก ๋ฆฌ๋ฉ
Gemini ๊ธฐ๋ฐ ํ๋ก ํด์
์ฌ์ฉ์ ์ธ์ฆ
Firebase ID Token ๊ฒ์ฆ (Google, Apple)
Rate Limiting
Guest 1ํ/์ผ, ๋ก๊ทธ์ธ ์ฌ์ฉ์ 10ํ/์ผ
ํ์คํ ๋ฆฌ
๋ก๊ทธ์ธ ์ฌ์ฉ์ ํ๋ก ๊ธฐ๋ก ์ ์ฅ ๋ฐ ์กฐํ
์ฌ์ฉ๋ ์กฐํ
์ผ์ผ ์ฌ์ฉ๋ ๋ฐ ๋ฆฌ์
์๊ฐ ํ์ธ
๊ฒฐ๊ณผ ๊ณต์
์นด์นด์คํก ๋ฑ ์ธ๋ถ ๊ณต์ ๋งํฌ ์์ฑ (30์ผ ๋ง๋ฃ)
Method
Endpoint
Description
Auth
GET
/health
ํฌ์ค ์ฒดํฌ
-
POST
/tarot
ํ๋ก ๋ฆฌ๋ฉ ์์ฒญ
Required
GET
/usage
์ฌ์ฉ๋ ์กฐํ
Required
GET
/tarot/history
ํ์คํ ๋ฆฌ ์กฐํ
Login Only
POST
/readings
๊ณต์ ๋งํฌ ์์ฑ
Required
GET
/readings/{share_id}
๊ณต์ ๊ฒฐ๊ณผ ์กฐํ
-
# ๋ก๊ทธ์ธ ์ฌ์ฉ์
Authorization: Bearer < firebase_id_token>
# Guest (๋น๋ก๊ทธ์ธ)
X-Guest-Token: < uuid>
์ฌ์ฉ์
์ผ์ผ ์ ํ
๋ฆฌ์
์๊ฐ
Guest
1ํ
KST 00:00
๋ก๊ทธ์ธ
10ํ
KST 00:00
โโโ src/
โ โโโ lambda_handler.py # Lambda ์ํธ๋ฆฌํฌ์ธํธ, ๋ผ์ฐํ
โ โโโ services/ # ๋น์ฆ๋์ค ๋ก์ง
โ โ โโโ tarot_service.py # ํ๋ก ๋ฆฌ๋ฉ ์๋น์ค
โ โ โโโ history_service.py # ํ์คํ ๋ฆฌ ์๋น์ค
โ โ โโโ usage_service.py # Rate Limit ์๋น์ค
โ โโโ repository/ # ๋ฐ์ดํฐ ์ ๊ทผ ๊ณ์ธต
โ โ โโโ history_repository.py
โ โ โโโ reading_repository.py # ๊ณต์ ๋งํฌ ๊ด๋ฆฌ
โ โโโ schema/ # Pydantic ๋ชจ๋ธ
โ โโโ tarot.py
โโโ infra/
โ โโโ template.yaml # AWS SAM ํ
ํ๋ฆฟ
โโโ docs/ # API ๋ฌธ์
โโโ .github/workflows/ # CI/CD
โโโ requirements.txt
Python 3.11+
AWS CLI & SAM CLI
Firebase ํ๋ก์ ํธ (Firestore, Auth ํ์ฑํ)
# ์ ์ฅ์ ํด๋ก
git clone https://github.com/gguip1/ArcanaWhisper-Back.git
cd ArcanaWhisper-Back
# ๊ฐ์ํ๊ฒฝ ์์ฑ ๋ฐ ํ์ฑํ
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# ์์กด์ฑ ์ค์น
pip install -r requirements.txt
# SSM Parameter Store์ ์ํฌ๋ฆฟ ์ ์ฅ (AWS CLI)
aws ssm put-parameter --name " /arcana-whisper/gemini-api-key" --value " your-api-key" --type SecureString
aws ssm put-parameter --name " /arcana-whisper/firebase-credentials" --value " base64-encoded-json" --type SecureString
cd infra
sam build
sam deploy --guided
๋ฐ์ดํฐ๋ฒ ์ด์ค ๊ตฌ์กฐ
guest_usage/
โโโ {guest_token}/
โโโ count: number
โโโ date: "YYYY-MM-DD"
โโโ updated_at: "ISO8601"
user_usage/
โโโ {firebase_uid}/
โโโ count: number
โโโ date: "YYYY-MM-DD"
โโโ updated_at: "ISO8601"
tarot_history/
โโโ {history_id}/
โโโ user_id: string
โโโ provider: string
โโโ question: string
โโโ cards: { cards: number[], reversed: boolean[] }
โโโ result: string
โโโ created_at: timestamp
โโโ is_shared: boolean # ๊ณต์ ์ฌ๋ถ
readings/
โโโ {share_id}/ # UUID
โโโ history_id: string # tarot_history ์ฐธ์กฐ
โโโ created_at: timestamp
โโโ expires_at: timestamp # 30์ผ ํ ๋ง๋ฃ (TTL)