Spaces:
Sleeping
Sleeping
File size: 5,560 Bytes
7aae924 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# π SmartEyeSsen Backend μ€μ κ°μ΄λ
νμμ μν κ°λ° νκ²½ μ€μ κ°μ΄λμ
λλ€.
---
## π **λͺ©μ°¨**
1. [μμ€ν
μꡬμ¬ν](#1-μμ€ν
-μꡬμ¬ν)
2. [MySQL μ€μΉ λ° μ€μ ](#2-mysql-μ€μΉ-λ°-μ€μ )
3. [νλ‘μ νΈ ν΄λ‘ λ° μ€μ ](#3-νλ‘μ νΈ-ν΄λ‘ -λ°-μ€μ )
4. [λ°μ΄ν°λ² μ΄μ€ μμ±](#4-λ°μ΄ν°λ² μ΄μ€-μμ±)
5. [Python νκ²½ μ€μ ](#5-python-νκ²½-μ€μ )
6. [μλ² μ€ν](#6-μλ²-μ€ν)
7. [νΈλ¬λΈμν
](#7-νΈλ¬λΈμν
)
---
## **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
# PowerShell (κ΄λ¦¬μ κΆν)
Start-Service MySQL80
```
#### **MySQL μ μ ν
μ€νΈ**
```powershell
mysql -u root -p
# λΉλ°λ²νΈ μ
λ ₯ ν μ μλλ©΄ μ±κ³΅
```
---
### **2-2. Windows + WSL2 (Ubuntu)**
#### **WSL2 μ€μΉ (μ²μ μ¬μ©νλ κ²½μ°)**
```powershell
# PowerShell (κ΄λ¦¬μ κΆν)
wsl --install -d Ubuntu-22.04
```
μ¬λΆν
ν Ubuntu μ¬μ©μλͺ
/λΉλ°λ²νΈ μ€μ
#### **MySQL μ€μΉ (WSL λ΄λΆ)**
```bash
# WSL Ubuntu ν°λ―Έλ
sudo apt update
sudo apt install mysql-server -y
# MySQL μλΉμ€ μμ
sudo service mysql start
# Root λΉλ°λ²νΈ μ€μ
sudo mysql
```
```sql
-- MySQL μ½μμμ
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
FLUSH PRIVILEGES;
EXIT;
```
#### **MySQL μ μ ν
μ€νΈ**
```bash
mysql -u root -p
# λΉλ°λ²νΈ μ
λ ₯ ν μ μλλ©΄ μ±κ³΅
```
---
## **3. νλ‘μ νΈ ν΄λ‘ λ° μ€μ **
### **3-2. νκ²½ λ³μ μ€μ **
```bash
# .env νμΌ μμ± (Backend ν΄λ λ΄)
cd Backend
cp .env.example .env
```
#### **`.env` νμΌ μμ **
ν
μ€νΈ μλν°λ‘ `.env` νμΌμ μ΄κ³ λ€μ νλͺ©μ μμ :
```ini
# λ°μ΄ν°λ² μ΄μ€ μ€μ
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` νμΌμλ λ°μ΄ν°λ² μ΄μ€ μμ±λΆν° ν
μ΄λΈ μμ±, μ΄κΈ° λ°μ΄ν° μ½μ
κΉμ§ λͺ¨λ μμ
μ΄ ν¬ν¨λμ΄ μμ΅λλ€.
```bash
# νλ‘μ νΈ λ£¨νΈ λλ ν 리μμ μ€ν
# (SmartEye-FrontWeb ν΄λ)
mysql -u root -p < Project/DB/erd_schema.sql
```
### **4-4. ν
μ΄λΈ μμ± νμΈ**
```bash
mysql -u root -p smarteyessen_db
```
```sql
-- 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) κ΄ν μ€ν λ°©λ²**
```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"
}
````
|