๐ API Detail Design Document
1. API Informationโ
- API Name: Collect sonar all 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 sonar on sonar server
- Description: Collect branch data
3. Endpoint Specificationโ
- Method: POST
- URL: /dashboard/collect/sonar/all-data
- 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โ
{
"applicationId": "app-67890",
"applicationName": "My Application",
"collectFrom": "2024-01-01T00:00:00Z",
"collectTo": "2024-12-31T23:59:59Z",
"componentKey": "component-123",
"componentName": "Main Component",
"host": "http://sonar.example.com",
"password": "securePassword",
"profileId": 12345,
"profileName": "My Sonar Profile",
"projectId": 14245,
"projectName": "My Project",
"token": "abc123token",
"tool": "SONAR",
"username": "user123"
}
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 "SonarQube API" as Sonar
database "MongoDB\nsonarMeasureComponentCollection" as SonarDB
Client -> DS: POST /collectSonarData\n{projectKey, metrics, 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 -> Sonar: Fetch measure component data\\n(using token, projectKey, metrics)
activate Sonar
Sonar --> Worker: Measure component data (JSON)
deactivate Sonar
Worker -> SonarDB: Insert measure component 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:
- sonarMeasureComponentCollection
-
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 |
|---|