2026-04-13 09:56:30 +07:00
|
|
|
# Story 2.2: Triển khai API Tải lên & Giới hạn Rate Limit (Upload API & Rate Limiting)
|
|
|
|
|
|
|
|
|
|
**Status:** done
|
|
|
|
|
**Epic:** Epic 2
|
|
|
|
|
**Story Key:** `2-2-upload-api-rate-limiting`
|
|
|
|
|
|
|
|
|
|
## 📖 Story Requirements (Context & PRD)
|
|
|
|
|
> This section maps directly to the original Product Requirements Document and Epics definition.
|
|
|
|
|
|
|
|
|
|
As a Kỹ sư Backend,
|
|
|
|
|
I want xây dựng endpoint FastAPI cho việc upload tài liệu kèm cơ chế Rate Limit,
|
|
|
|
|
So that server tiếp nhận an toàn và ngăn chặn upload spam quá mức hệ thống cho phép.
|
|
|
|
|
**Acceptance Criteria:**
|
|
|
|
|
**Given** người dùng đăng nhập hợp lệ
|
|
|
|
|
**When** đính kèm file và gửi POST tới `/api/v1/documents`
|
2026-04-13 23:17:12 +07:00
|
|
|
**Then** hệ thống check bộ nhớ đệm, lưu file vô Storage, tạo record ở DB với status 'Queue', và trigger đẩy task vào Celery.
|
|
|
|
|
*(Phần giới hạn Rate Limit (429) sẽ được triển khai chính thức ở Epic 5 - Usage Quota)*
|
2026-04-13 09:56:30 +07:00
|
|
|
|
|
|
|
|
## 🏗️ Architecture & Technical Guardrails
|
|
|
|
|
> Critical instructions for the development agent based on the project's established architecture.
|
|
|
|
|
|
|
|
|
|
### Technical Requirements
|
|
|
|
|
- Language/Framework: React, Next.js (TypeScript) for Web; FastAPI (Python) for Backend.
|
|
|
|
|
- Database: Prisma/Supabase.
|
|
|
|
|
- Strict Type checking must be enforced. No `any` types.
|
|
|
|
|
|
|
|
|
|
### Code Organization
|
|
|
|
|
This story is currently marked as `done`. Implementation should target the following components/files:
|
|
|
|
|
|
2026-04-13 23:17:12 +07:00
|
|
|
*(Files to be determined during implementation)*
|
2026-04-13 09:56:30 +07:00
|
|
|
|
|
|
|
|
### Developer Agent Constraints
|
|
|
|
|
1. **No Destructive Refactors**: Extend existing modules when possible.
|
|
|
|
|
2. **Context Check**: Always refer back to `task.md` and use Context7 to verify latest SDK usages.
|
|
|
|
|
3. **BMad Standard**: Update the sprint status using standard metrics.
|
|
|
|
|
|
|
|
|
|
## 🧪 Testing & Validation Requirements
|
|
|
|
|
- All new endpoints must be tested.
|
|
|
|
|
- Frontend components should gracefully degrade.
|
|
|
|
|
- Do not introduce regressions into existing user workflows.
|
|
|
|
|
|
|
|
|
|
## 📈 Completion Status
|
|
|
|
|
*(To be updated by the agent when completing this story)*
|
|
|
|
|
- Start Date: _____________
|
|
|
|
|
- Completion Date: _____________
|
|
|
|
|
- Key Files Changed:
|
|
|
|
|
-
|
|
|
|
|
|