Spaces:
Sleeping
Sleeping
π SmartEyeSsen Backend μ€μ κ°μ΄λ
νμμ μν κ°λ° νκ²½ μ€μ κ°μ΄λμ λλ€.
π λͺ©μ°¨
- μμ€ν μꡬμ¬ν
- MySQL μ€μΉ λ° μ€μ
- νλ‘μ νΈ ν΄λ‘ λ° μ€μ
- λ°μ΄ν°λ² μ΄μ€ μμ±
- Python νκ²½ μ€μ
- μλ² μ€ν
- νΈλ¬λΈμν
1. μμ€ν μꡬμ¬ν
νμ νλ‘κ·Έλ¨
- Python 3.9 μ΄μ
- MySQL 8.0 μ΄μ
- Git
μ΄μ체μ λ³ μ§μ
- β Windows 10/11
- β Windows + WSL2 (Ubuntu 20.04/22.04)
- β macOS
- β Linux (Ubuntu/Debian)
2. MySQL μ€μΉ λ° μ€μ
MySQL μλΉμ€ μμ
# PowerShell (κ΄λ¦¬μ κΆν)
Start-Service MySQL80
MySQL μ μ ν μ€νΈ
mysql -u root -p
# λΉλ°λ²νΈ μ
λ ₯ ν μ μλλ©΄ μ±κ³΅
2-2. Windows + WSL2 (Ubuntu)
WSL2 μ€μΉ (μ²μ μ¬μ©νλ κ²½μ°)
# PowerShell (κ΄λ¦¬μ κΆν)
wsl --install -d Ubuntu-22.04
μ¬λΆν ν Ubuntu μ¬μ©μλͺ /λΉλ°λ²νΈ μ€μ
MySQL μ€μΉ (WSL λ΄λΆ)
# WSL Ubuntu ν°λ―Έλ
sudo apt update
sudo apt install mysql-server -y
# MySQL μλΉμ€ μμ
sudo service mysql start
# Root λΉλ°λ²νΈ μ€μ
sudo mysql
-- MySQL μ½μμμ
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
FLUSH PRIVILEGES;
EXIT;
MySQL μ μ ν μ€νΈ
mysql -u root -p
# λΉλ°λ²νΈ μ
λ ₯ ν μ μλλ©΄ μ±κ³΅
3. νλ‘μ νΈ ν΄λ‘ λ° μ€μ
3-2. νκ²½ λ³μ μ€μ
# .env νμΌ μμ± (Backend ν΄λ λ΄)
cd Backend
cp .env.example .env
.env νμΌ μμ
ν
μ€νΈ μλν°λ‘ .env νμΌμ μ΄κ³ λ€μ νλͺ©μ μμ :
# λ°μ΄ν°λ² μ΄μ€ μ€μ
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=your_actual_password # β οΈ μ¬κΈ°μ μ€μ MySQL λΉλ°λ²νΈ μ
λ ₯
DB_NAME=smarteyessen_db
# OpenAI API
OPENAI_API_KEY= # μ΄κ±΄ λ°κΏμΌλΌ!
# μλ² μ€μ
API_HOST=0.0.0.0
API_PORT=8000
4. λ°μ΄ν°λ² μ΄μ€ μμ±
4-1. μ€ν€λ§ μ μ© (λ°μ΄ν°λ² μ΄μ€ μλ μμ±)
erd_schema.sql νμΌμλ λ°μ΄ν°λ² μ΄μ€ μμ±λΆν° ν
μ΄λΈ μμ±, μ΄κΈ° λ°μ΄ν° μ½μ
κΉμ§ λͺ¨λ μμ
μ΄ ν¬ν¨λμ΄ μμ΅λλ€.
# νλ‘μ νΈ λ£¨νΈ λλ ν 리μμ μ€ν
# (SmartEye-FrontWeb ν΄λ)
mysql -u root -p < Project/DB/erd_schema.sql
4-4. ν μ΄λΈ μμ± νμΈ
mysql -u root -p smarteyessen_db
-- 12κ° ν
μ΄λΈ νμΈ
SHOW TABLES;
-- μμ κ²°κ³Ό:
-- +------------------------------+
-- | Tables_in_smarteyessen_db |
-- +------------------------------+
-- | ai_descriptions |
-- | combined_results |
-- | document_types |
-- | formatting_rules |
-- | layout_elements |
-- | pages |
-- | projects |
-- | question_elements |
-- | question_groups |
-- | text_contents |
-- | text_versions |
-- | users |
-- +------------------------------+
-- μ΄κΈ° λ°μ΄ν° νμΈ
SELECT * FROM document_types;
-- 2κ° νμ΄ μ‘°νλμ΄μΌ ν¨ (worksheet, document)
EXIT;
### **5-2. μμ‘΄μ± μ€μΉ**
```bash
# Backend ν΄λλ‘ μ΄λ
cd Backend
# ν¨ν€μ§ μ€μΉ
pip install -r requirements.txt
6. μλ² μ€ν
6-1. μλ² μμ
Windows (PowerShell) κ΄ν μ€ν λ°©λ²
# pytorch νκ²½ νμ±ν
conda activate pytorch
# Backend ν΄λλ‘ μ΄λ
cd Backend
# μλ² μ€ν
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
WSL/macOS/Linux μ’ μ μ€νλ°©λ²
Backend ν΄λλ‘ μ΄λ
cd Backend
μλ² μ€ν
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
### **6-2. μλ² μ€ν νμΈ**
λ€μκ³Ό κ°μ μΆλ ₯μ΄ λνλλ©΄ μ±κ³΅:
INFO: Will watch for changes in these directories: ['C:\git\Smart-Eye-OCR\SmartEye-FrontWeb\Backend'] INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) INFO: Started reloader process [12345] using WatchFiles INFO: Started server process [67890] INFO: Waiting for application startup.
π SmartEyeSsen Backend Starting...
β Database connection successful! β Database connection successful β Database tables created successfully! β Database tables initialized
β SmartEyeSsen Backend Ready! π API Docs: http://localhost:8000/docs
INFO: Application startup complete.
### **6-3. API λ¬Έμ μ μ**
λΈλΌμ°μ μμ λ€μ URLλ‘ μ μ:
- π **λ©μΈ**: http://localhost:8000
- π **API λ¬Έμ (Swagger UI)**: http://localhost:8000/docs
- π **API λ¬Έμ (ReDoc)**: http://localhost:8000/redoc
- β€οΈ **ν¬μ€ 체ν¬**: http://localhost:8000/health
**ν¬μ€ μ²΄ν¬ μλ΅ μμ:**
```json
{
"status": "healthy",
"message": "SmartEyeSsen Backend is running",
"database": "connected",
"timestamp": "2025-01-22T15:30:00.123456"
}