--- title: CAAINP Backend emoji: 🧭 colorFrom: blue colorTo: green sdk: docker pinned: false license: mit --- # caanip-backend ## κ°œμš” 이 ν”„λ‘œμ νŠΈλŠ” μ‹€λ‚΄ λ„€λΉ„κ²Œμ΄μ…˜μ„ μœ„ν•œ λ°±μ—”λ“œ APIλ₯Ό μ œκ³΅ν•©λ‹ˆλ‹€. μ‚¬μš©μžμ˜ μžμ—°μ–΄ μš”μ²­κ³Ό ν˜„μž₯ 이미지λ₯Ό λ°›μ•„ λ„€λΉ„κ²Œμ΄μ…˜ μ•ˆλ‚΄λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€. ## μ„€μΉ˜ 및 μ‹€ν–‰ ### 사전 μš”κ΅¬μ‚¬ν•­ - Python 3.12 이상 - uv ### μ„€μΉ˜ ```bash uv sync ``` ### μ‹€ν–‰ ```bash uvicorn server:app --reload ``` μ„œλ²„λŠ” 기본적으둜 `http://localhost:8000`μ—μ„œ μ‹€ν–‰λ©λ‹ˆλ‹€. API λ¬Έμ„œλŠ” `http://localhost:8000/docs`μ—μ„œ 확인할 수 μžˆμŠ΅λ‹ˆλ‹€. ## API μ—”λ“œν¬μΈνŠΈ ### POST `/api/navigation/start` - μžμ—°μ–΄ μš”μ²­κ³Ό μ‹œμž‘ λ°©, ν˜„μž₯ 이미지λ₯Ό λ°›μ•„ λ„€λΉ„κ²Œμ΄μ…˜ μ„Έμ…˜μ„ μƒμ„±ν•˜κ³  첫 μ•ˆλ‚΄λ₯Ό λ°˜ν™˜ - Form 데이터: `request_text`(μžμ—°μ–΄ μš”μ²­), `start_room`(μ‹œμž‘ λ°© 번호), File: `image`(ν˜„μž₯ 이미지) - 응닡: 첫 λ„€λΉ„κ²Œμ΄μ…˜ μ•ˆλ‚΄(JSON). μ„Έμ…˜ μƒνƒœκ°€ `CAAINP-NAVIGATION-COOKIE`에 μ €μž₯됨. ### POST `/api/navigation/step` - 쿠킀에 μ €μž₯된 μ„Έμ…˜ μƒνƒœ(plan, prev_node)λ₯Ό μ‚¬μš©ν•΄ λ‹€μŒ 단계 μ•ˆλ‚΄λ₯Ό λ°˜ν™˜ - File: `image`(ν˜„μž₯ 이미지) - μ„Έμ…˜μ΄ μ—†μœΌλ©΄ `{ "status": "error", "message": "/api/navigation/startλ₯Ό λ¨Όμ € ν˜ΈμΆœν•˜μ„Έμš”." }` λ°˜ν™˜ - 응닡 μ˜ˆμ‹œ: ```json { "schema_version": 1, "current_node": 4106, "next_node": 4103, "move_instruction": { "direction_type": "STRAIGHT", "angle_deg": 0.0, "text_ko": "μ§μ§„ν•˜μ„Έμš”." }, "route_summary": { "current_step": 1, "total_steps": 3, "remaining_steps_text": "μ—˜λ¦¬λ² μ΄ν„° β†’ 4μΈ΅ 410호 β†’ 7μΈ΅ 7201호 순으둜 이동", "via_nodes": [4150, 410, 7201] } } ``` ### POST `/api/navigation/reset` - μ €μž₯된 λ„€λΉ„κ²Œμ΄μ…˜ μΏ ν‚€ μ‚­μ œ ν›„ μ„Έμ…˜ μ΄ˆκΈ°ν™” - 응닡: `{ "status": "success", "message": "λ„€λΉ„κ²Œμ΄μ…˜ μ„Έμ…˜μ΄ μ΄ˆκΈ°ν™”λ˜μ—ˆμŠ΅λ‹ˆλ‹€." }` ### POST `/api/navigation/mock` - μ‹€μ œ μ—”μ§„ λŒ€μ‹  λͺ¨μ˜ 응닡 λ°˜ν™˜(디버깅/ν”„λ‘ νŠΈμ—”λ“œ μ—°λ™μš©) - Form: `request_text`, File: `image` - 응닡: λͺ¨μ˜ λ„€λΉ„κ²Œμ΄μ…˜ JSON ### GET `/api/cookie/get` - ν˜„μž¬ μš”μ²­μ˜ `CAAINP-NAVIGATION-COOKIE` 값을 쑰회 - 응닡: `{ "cookie": {plan, prev_node} | null }` ### GET `/api/cookie/delete` - λ„€λΉ„κ²Œμ΄μ…˜ μΏ ν‚€ μ‚­μ œ - 응닡: `{ "status": "success", "message": "μΏ ν‚€κ°€ μ„±κ³΅μ μœΌλ‘œ μ‚­μ œλ˜μ—ˆμŠ΅λ‹ˆλ‹€." }` ## ν…ŒμŠ€νŠΈ ```bash uv run tests/navigation_test.py ``` ## ν”„λ‘œμ νŠΈ ꡬ쑰 ``` caanip-backend/ β”œβ”€β”€ server.py # FastAPI μ• ν”Œλ¦¬μΌ€μ΄μ…˜ 메인 파일 β”œβ”€β”€ mock_responses.py # λͺ¨μ˜ λ„€λΉ„κ²Œμ΄μ…˜ 응닡 생성 λͺ¨λ“ˆ β”œβ”€β”€ pyproject.toml # ν”„λ‘œμ νŠΈ μ„€μ • 및 μ˜μ‘΄μ„± └── README.md # ν”„λ‘œμ νŠΈ λ¬Έμ„œ ```