๐ API Detail Design Document
1. API Informationโ
- API Name: Collect branch data
- Module/Service: amdp-ags-dashboard-backend
- Author: Reus
- Created Date: 2025/08/18
- Last Updated: 2025/08/18
2. Overviewโ
- Purpose: API collect data branches on git server
- Description: Collect branch data
3. Endpoint Specificationโ
- Method: POST
- URL: /dashboard/collect/branch
- Headers:
- Authorization: Bearer
<token user> - Content-Type: application/json
- Authorization: Bearer
Query Paramsโ
| Name | Type | Required | Description | Example |
|---|---|---|---|---|
Path Paramsโ
| Name | Type | Required | Description | Example |
|---|---|---|---|---|
Request Bodyโ
{
"branch": "main",
"collectFrom": "2024-12-01",
"collectTo": "2024-12-15",
"host": "https://github.com",
"organizationId": "org456",
"projectId": 14245,
"projectName": "My Project",
"repositoryId": "repo123",
"repositoryName": "example-repo",
"token": "ghp_exampletoken123",
"tool": "GIT"
}
4. Response Specificationโ
Success Response (200/201)โ
{"code": 200,"message": "Success"}
Error Response (400/401/404/500)โ
{"code": 400,"message": "Bad Request"}
5. Sequence / Flow (Source)โ
@startuml
actor Client
participant "Dashboard Service" as DS
queue "Request Queue" as Q
participant "Scheduler (5s)" as Sch
database "MongoDB\nstatusManagerCollection" as StatusDB
participant "Worker Pool (max=5)" as Worker
participant "Git Provider (GitHub)" as Git
database "MongoDB\ngitCommitCollection" as CommitDB
database "MongoDB\ngitPullRequestCollection" as PRDB
database "MongoDB\ngitBranchCollection" as BranchDB
Client -> DS: POST /collectAllData\n{repo, branch, collectFrom, collectTo, ...}
activate DS
DS -> Q: Push collect request
DS -> StatusDB: Insert status = "waiting for sync"
DS --> Client: 200 OK\n{ "message": "Request queued" }
deactivate DS
Sch -> Q: Poll request (FIFO)
Q --> Sch: Request (if available)
alt If request found
Sch -> Worker: Dispatch request (max 5 parallel)
activate Worker
Worker -> StatusDB: Update status = "in sync"
Worker -> Git: Fetch branch/commit/PR data
activate Git
Git --> Worker: JSON data
deactivate Git
Worker -> CommitDB: Insert commit data
Worker -> PRDB: Insert pull request data
Worker -> BranchDB: Insert branch data
Worker -> StatusDB: Update status = "success"
deactivate Worker
else No request
Sch -> Sch: Wait 5s
end
'--- Error handling ---
Worker -> StatusDB: Update status = "failed" (on error)
@enduml
6. Sequence / Flow (Image)โ

7. Dependenciesโ
- DB tables:
gitCommitCollection, gitPullRequestCollection, gitBranchCollection, statusManagerCollecton
- External service call:
- Message broker/topic:
8. Security & Performance Considerationsโ
- Authentication & Authorization
- Rate limit / Throttling
- Caching
- Timeout & Retry logic
9. Test Cases (basic)โ
| Case | Input | Expected Output | Notes |
|---|---|---|---|
| Valid request | {...} | 200 + data | |
| Missing param | {} | 400 error | |
| Unauthorized | 401 error |
10. Change Historyโ
| Version | Date | Author | Change |
|---|