📌 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
participant "Git Provider (GitHub)" as Git
database "MongoDB\ngitBranchCollection" as DB
Client -> DS: POST /collectBranchData\n{branch, collectFrom, collectTo, ...}
activate DS
DS -> DS: Parse & validate request
DS -> Git: Fetch branch data\n(using token, repo info)
activate Git
Git --> DS: Branch data (JSON)
deactivate Git
DS -> DS: Transform & prepare data
DS -> DB: Insert branch data
activate DB
DB --> DS: Ack (insert success)
deactivate DB
DS --> Client: 200 OK\n{ "message": "Collect success" }
deactivate DS
@enduml
6. Sequence / Flow (Image)

7. Dependencies
- DB tables:
{ "_id": {"$oid": "66974109ba38fa3fb6e904e6"}, "_class": "com.amdp.dashboard.entity.mongodb.gitprovider.common.GitBranchCollection", "lastModifiedDate": {"$date": "2024-07-17T03:56:57.678Z"}, "repositoryId": "844", "repositoryName": "amdp-awesome-shopping-demo-account"}
- 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 |
|---|