Skip to content

Commit 16bbd5d

Browse files
committed
Refactor documentation and code for improved clarity and consistency
- Updated setup instructions in `index.md` to include Docker options and clarify manual setup steps. - Simplified method signatures in various service classes for better readability. - Consolidated test cases in `unit.md` and `integration.md` to enhance maintainability. - Improved performance testing scripts for better clarity and efficiency. - Updated database setup instructions in `quickstart.md` to reflect changes in database configuration. - Enhanced error handling and logging in service methods across multiple files.
1 parent 588f336 commit 16bbd5d

38 files changed

Lines changed: 988 additions & 1403 deletions

docs/.vitepress/theme/index.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,20 @@ export default {
3030
// Function to render mermaid diagrams
3131
const renderMermaidDiagrams = async () => {
3232
// Try multiple selectors to find mermaid code blocks
33-
let mermaidElements = document.querySelectorAll(
34-
'pre code.language-mermaid'
35-
);
33+
let mermaidElements = document.querySelectorAll('pre code.language-mermaid');
3634

3735
// If not found, try alternative selectors
3836
if (mermaidElements.length === 0) {
39-
mermaidElements = document.querySelectorAll(
40-
'code.language-mermaid'
41-
);
37+
mermaidElements = document.querySelectorAll('code.language-mermaid');
4238
}
4339
if (mermaidElements.length === 0) {
44-
mermaidElements = document.querySelectorAll(
45-
'pre[class*="language-mermaid"] code'
46-
);
40+
mermaidElements = document.querySelectorAll('pre[class*="language-mermaid"] code');
4741
}
4842
if (mermaidElements.length === 0) {
49-
mermaidElements = document.querySelectorAll(
50-
'[class*="language-mermaid"]'
51-
);
43+
mermaidElements = document.querySelectorAll('[class*="language-mermaid"]');
5244
}
5345

54-
console.log(
55-
`Found ${mermaidElements.length} mermaid diagrams to render`
56-
);
46+
console.log(`Found ${mermaidElements.length} mermaid diagrams to render`);
5747

5848
for (let i = 0; i < mermaidElements.length; i++) {
5949
const element = mermaidElements[i] as HTMLElement;

docs/api/analytics.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ graph TD
3838

3939
Get a comprehensive dashboard view of your search analytics.
4040

41-
**Endpoint**: `GET /api/analytics/dashboard`
41+
**Endpoint**: `GET /api/v1/analytics/dashboard`
4242

4343
**Query Parameters**:
4444

@@ -136,7 +136,7 @@ Authorization: Bearer <YOUR_API_KEY>
136136

137137
Get detailed search trend analysis over time.
138138

139-
**Endpoint**: `GET /api/analytics/trends`
139+
**Endpoint**: `GET /api/v1/analytics/trends`
140140

141141
**Query Parameters**:
142142

@@ -216,7 +216,7 @@ Get detailed search trend analysis over time.
216216

217217
Get detailed performance analytics including response times, error rates, and resource utilization.
218218

219-
**Endpoint**: `GET /api/analytics/performance`
219+
**Endpoint**: `GET /api/v1/analytics/performance`
220220

221221
**Query Parameters**:
222222

@@ -242,7 +242,7 @@ Get detailed performance analytics including response times, error rates, and re
242242
},
243243
"endpoints": [
244244
{
245-
"endpoint": "/api/search",
245+
"endpoint": "/api/v1/search",
246246
"totalRequests": 1250,
247247
"averageResponseTime": 267,
248248
"successRate": 0.981,
@@ -302,7 +302,7 @@ Get detailed performance analytics including response times, error rates, and re
302302

303303
Get the most popular search queries with detailed analytics.
304304

305-
**Endpoint**: `GET /api/analytics/popular-queries`
305+
**Endpoint**: `GET /api/v1/analytics/popular-queries`
306306

307307
**Query Parameters**:
308308

@@ -373,7 +373,7 @@ Get the most popular search queries with detailed analytics.
373373

374374
Get AI-powered insights and recommendations based on your search patterns.
375375

376-
**Endpoint**: `GET /api/analytics/insights`
376+
**Endpoint**: `GET /api/v1/analytics/insights`
377377

378378
**Query Parameters**:
379379

@@ -481,7 +481,7 @@ Get AI-powered insights and recommendations based on your search patterns.
481481

482482
Get comprehensive system-wide analytics and health metrics.
483483

484-
**Endpoint**: `GET /api/analytics/overview`
484+
**Endpoint**: `GET /api/v1/analytics/overview`
485485

486486
**Response**:
487487

@@ -545,7 +545,7 @@ Get comprehensive system-wide analytics and health metrics.
545545

546546
Get detailed user activity and engagement metrics.
547547

548-
**Endpoint**: `GET /api/analytics/user-activity`
548+
**Endpoint**: `GET /api/v1/analytics/user-activity`
549549

550550
**Query Parameters**:
551551

@@ -620,7 +620,7 @@ Get detailed user activity and engagement metrics.
620620

621621
Define custom metrics for tracking specific KPIs.
622622

623-
**Endpoint**: `POST /api/analytics/custom-metrics`
623+
**Endpoint**: `POST /api/v1/analytics/custom-metrics`
624624

625625
**Request Body**:
626626

@@ -646,7 +646,7 @@ Define custom metrics for tracking specific KPIs.
646646

647647
Export analytics data in various formats for external analysis.
648648

649-
**Endpoint**: `GET /api/analytics/export`
649+
**Endpoint**: `GET /api/v1/analytics/export`
650650

651651
**Query Parameters**:
652652

@@ -677,7 +677,7 @@ class Altus4Analytics {
677677
if (databases) params.append('databases', databases.join(','));
678678

679679
const response = await fetch(
680-
`${this.baseUrl}/api/analytics/dashboard?${params}`,
680+
`${this.baseUrl}/api/v1/analytics/dashboard?${params}`,
681681
{ headers: this.headers }
682682
);
683683

@@ -692,7 +692,7 @@ class Altus4Analytics {
692692
});
693693

694694
const response = await fetch(
695-
`${this.baseUrl}/api/analytics/trends?${params}`,
695+
`${this.baseUrl}/api/v1/analytics/trends?${params}`,
696696
{ headers: this.headers }
697697
);
698698

@@ -704,7 +704,7 @@ class Altus4Analytics {
704704
if (category) params.append('category', category);
705705

706706
const response = await fetch(
707-
`${this.baseUrl}/api/analytics/popular-queries?${params}`,
707+
`${this.baseUrl}/api/v1/analytics/popular-queries?${params}`,
708708
{ headers: this.headers }
709709
);
710710

@@ -715,7 +715,7 @@ class Altus4Analytics {
715715
const params = new URLSearchParams({ type });
716716

717717
const response = await fetch(
718-
`${this.baseUrl}/api/analytics/insights?${params}`,
718+
`${this.baseUrl}/api/v1/analytics/insights?${params}`,
719719
{ headers: this.headers }
720720
);
721721

@@ -730,7 +730,7 @@ class Altus4Analytics {
730730
});
731731

732732
const response = await fetch(
733-
`${this.baseUrl}/api/analytics/performance?${params}`,
733+
`${this.baseUrl}/api/v1/analytics/performance?${params}`,
734734
{ headers: this.headers }
735735
);
736736

@@ -781,23 +781,23 @@ class Altus4AnalyticsDashboard:
781781

782782
def get_dashboard_data(self, period='week'):
783783
response = requests.get(
784-
f'{self.base_url}/api/analytics/dashboard',
784+
f'{self.base_url}/api/v1/analytics/dashboard',
785785
headers=self.headers,
786786
params={'period': period}
787787
)
788788
return response.json()['data']['dashboard']
789789

790790
def get_search_trends(self, period='month', limit=100):
791791
response = requests.get(
792-
f'{self.base_url}/api/analytics/trends',
792+
f'{self.base_url}/api/v1/analytics/trends',
793793
headers=self.headers,
794794
params={'period': period, 'limit': limit}
795795
)
796796
return response.json()['data']['trends']
797797

798798
def get_performance_metrics(self, period='day'):
799799
response = requests.get(
800-
f'{self.base_url}/api/analytics/performance',
800+
f'{self.base_url}/api/v1/analytics/performance',
801801
headers=self.headers,
802802
params={'period': period, 'breakdown': 'endpoint,database'}
803803
)

docs/api/authentication.md

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The format includes:
4747

4848
Register a new user account to begin the authentication process.
4949

50-
**Endpoint**: `POST /api/auth/register`
50+
**Endpoint**: `POST /api/v1/auth/register`
5151

5252
**Headers**:
5353

@@ -86,7 +86,7 @@ Content-Type: application/json
8686
**cURL Example**:
8787

8888
```bash
89-
curl -X POST https://api.altus4.dev/api/auth/register \
89+
curl -X POST https://api.altus4.dev/api/v1/auth/register \
9090
-H "Content-Type: application/json" \
9191
-d '{
9292
"email": "user@example.com",
@@ -99,7 +99,7 @@ curl -X POST https://api.altus4.dev/api/auth/register \
9999

100100
Login to receive a JWT token for API key creation. This JWT token should only be used to create your initial API key.
101101

102-
**Endpoint**: `POST /api/auth/login`
102+
**Endpoint**: `POST /api/v1/auth/login`
103103

104104
**Headers**:
105105

@@ -139,7 +139,7 @@ Content-Type: application/json
139139
**cURL Example**:
140140

141141
```bash
142-
curl -X POST https://api.altus4.dev/api/auth/login \
142+
curl -X POST https://api.altus4.dev/api/v1/auth/login \
143143
-H "Content-Type: application/json" \
144144
-d '{
145145
"email": "user@example.com",
@@ -151,7 +151,7 @@ curl -X POST https://api.altus4.dev/api/auth/login \
151151

152152
Create your first API key using the JWT token from login. This is a one-time setup process.
153153

154-
**Endpoint**: `POST /api/management/setup`
154+
**Endpoint**: `POST /api/v1/management/setup`
155155

156156
**Headers**:
157157

@@ -181,7 +181,7 @@ Authorization: Bearer <JWT_TOKEN_FROM_LOGIN>
181181
**cURL Example**:
182182

183183
```bash
184-
curl -X POST https://api.altus4.dev/api/management/setup \
184+
curl -X POST https://api.altus4.dev/api/v1/management/setup \
185185
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
186186
```
187187

@@ -193,7 +193,7 @@ Once you have your initial API key, use it to manage additional keys and your ac
193193

194194
Create additional API keys for different environments or use cases.
195195

196-
**Endpoint**: `POST /api/keys`
196+
**Endpoint**: `POST /api/v1/keys`
197197

198198
**Headers**:
199199

@@ -240,7 +240,7 @@ Content-Type: application/json
240240

241241
Retrieve all API keys associated with your account.
242242

243-
**Endpoint**: `GET /api/keys`
243+
**Endpoint**: `GET /api/v1/keys`
244244

245245
**Headers**:
246246

@@ -275,7 +275,7 @@ Authorization: Bearer <YOUR_API_KEY>
275275

276276
Update an existing API key's name, tier, or permissions.
277277

278-
**Endpoint**: `PUT /api/keys/:keyId`
278+
**Endpoint**: `PUT /api/v1/keys/:keyId`
279279

280280
**Headers**:
281281

@@ -298,7 +298,7 @@ Content-Type: application/json
298298

299299
Permanently revoke an API key. This action cannot be undone.
300300

301-
**Endpoint**: `DELETE /api/keys/:keyId`
301+
**Endpoint**: `DELETE /api/v1/keys/:keyId`
302302

303303
**Headers**:
304304

@@ -322,7 +322,7 @@ Authorization: Bearer <YOUR_API_KEY>
322322

323323
Generate a new secret for an existing API key while maintaining the same ID and settings.
324324

325-
**Endpoint**: `POST /api/keys/:keyId/regenerate`
325+
**Endpoint**: `POST /api/v1/keys/:keyId/regenerate`
326326

327327
**Headers**:
328328

@@ -351,7 +351,7 @@ Authorization: Bearer <YOUR_API_KEY>
351351

352352
Get detailed usage statistics for a specific API key.
353353

354-
**Endpoint**: `GET /api/keys/:keyId/usage`
354+
**Endpoint**: `GET /api/v1/keys/:keyId/usage`
355355

356356
**Query Parameters**:
357357

@@ -378,7 +378,7 @@ Authorization: Bearer <YOUR_API_KEY>
378378
"averageResponseTime": 245,
379379
"topEndpoints": [
380380
{
381-
"endpoint": "/api/search",
381+
"endpoint": "/api/v1/search",
382382
"requests": 800,
383383
"averageResponseTime": 280
384384
}
@@ -408,7 +408,7 @@ Authorization: Bearer altus4_sk_live_abc123def456...
408408
```javascript
409409
const apiKey = 'altus4_sk_live_abc123def456...';
410410

411-
const response = await fetch('https://api.altus4.dev/api/search', {
411+
const response = await fetch('https://api.altus4.dev/api/v1/search', {
412412
method: 'POST',
413413
headers: {
414414
Authorization: `Bearer ${apiKey}`,
@@ -432,7 +432,7 @@ import requests
432432
api_key = 'altus4_sk_live_abc123def456...'
433433

434434
response = requests.post(
435-
'https://api.altus4.dev/api/search',
435+
'https://api.altus4.dev/api/v1/search',
436436
headers={
437437
'Authorization': f'Bearer {api_key}',
438438
'Content-Type': 'application/json'
@@ -578,4 +578,60 @@ Expected response:
578578

579579
---
580580

581+
## Testing Authentication
582+
583+
For local development and testing, you can use these pre-configured credentials:
584+
585+
### Test User Credentials
586+
587+
```json
588+
{
589+
"email": "postman@example.com",
590+
"password": "postman123"
591+
}
592+
```
593+
594+
### Complete Testing Flow
595+
596+
1. **Login to get JWT token**:
597+
598+
```bash
599+
curl -X POST http://localhost:3000/api/v1/auth/login \
600+
-H "Content-Type: application/json" \
601+
-d '{
602+
"email": "postman@example.com",
603+
"password": "postman123"
604+
}'
605+
```
606+
607+
2. **Create API key using JWT**:
608+
609+
```bash
610+
curl -X POST http://localhost:3000/api/v1/management/setup \
611+
-H "Content-Type: application/json" \
612+
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
613+
-d '{
614+
"name": "Test API Key"
615+
}'
616+
```
617+
618+
3. **Use API key for search**:
619+
620+
```bash
621+
curl -X POST http://localhost:3000/api/v1/search \
622+
-H "Content-Type: application/json" \
623+
-H "Authorization: Bearer YOUR_API_KEY" \
624+
-d '{
625+
"query": "test search",
626+
"databases": [],
627+
"limit": 5
628+
}'
629+
```
630+
631+
### Postman Collection
632+
633+
A complete Postman collection with all authentication flows is available in the `/examples` directory.
634+
635+
---
636+
581637
**Next Steps**: [Search Operations](./search.md) | [Database Management](./database.md)

0 commit comments

Comments
 (0)