1
+ > [ !CAUTION]
2
+ > These design documents are generated by AI and may not be fully accurate or complete. They are intended to provide a starting point for understanding the system architecture and design patterns used in the template-fastapi application.
3
+
1
4
# External API Specification
2
5
3
6
## Overview
@@ -13,6 +16,7 @@ The template-fastapi application provides a comprehensive REST API built with Fa
13
16
** Purpose** : Core CRUD operations for item management with Azure CosmosDB backend.
14
17
15
18
** Endpoints** :
19
+
16
20
- ` GET /items/ ` - List all items with pagination
17
21
- ` GET /items/{item_id} ` - Retrieve specific item
18
22
- ` POST /items/ ` - Create new item
@@ -21,10 +25,11 @@ The template-fastapi application provides a comprehensive REST API built with Fa
21
25
- ` GET /items/search/?q={query} ` - Search items by text
22
26
23
27
** Data Model** :
28
+
24
29
``` json
25
30
{
26
31
"id" : " string" ,
27
- "name" : " string" ,
32
+ "name" : " string" ,
28
33
"description" : " string" ,
29
34
"price" : 0.0 ,
30
35
"tax" : 0.0
@@ -38,6 +43,7 @@ The template-fastapi application provides a comprehensive REST API built with Fa
38
43
** Purpose** : File upload, storage, and retrieval using Azure Blob Storage.
39
44
40
45
** Endpoints** :
46
+
41
47
- ` GET /files/ ` - List files with optional prefix filter
42
48
- ` POST /files/upload ` - Upload single file
43
49
- ` POST /files/upload-multiple ` - Upload multiple files
@@ -47,6 +53,7 @@ The template-fastapi application provides a comprehensive REST API built with Fa
47
53
- ` DELETE /files/ ` - Delete multiple files (request body)
48
54
49
55
** Features** :
56
+
50
57
- Automatic content type detection
51
58
- File metadata tracking
52
59
- Bulk operations support
@@ -58,6 +65,7 @@ The template-fastapi application provides a comprehensive REST API built with Fa
58
65
** Purpose** : Restaurant management with geospatial search capabilities.
59
66
60
67
** Endpoints** :
68
+
61
69
- ` GET /restaurants/ ` - List restaurants with pagination
62
70
- ` GET /restaurants/{id} ` - Get restaurant details
63
71
- ` POST /restaurants/ ` - Create new restaurant
@@ -67,6 +75,7 @@ The template-fastapi application provides a comprehensive REST API built with Fa
67
75
- ` GET /restaurants/near/?latitude={lat}&longitude={lng} ` - Geospatial proximity search
68
76
69
77
** Search Features** :
78
+
70
79
- Text-based vector search using embeddings
71
80
- Location-based proximity search with configurable radius
72
81
- Pagination support for all list operations
@@ -78,6 +87,7 @@ The template-fastapi application provides a comprehensive REST API built with Fa
78
87
** Purpose** : Batch audio transcription using Azure AI Speech Services.
79
88
80
89
** Endpoints** :
90
+
81
91
- ` GET /transcriptions/ ` - List all transcription jobs
82
92
- ` POST /transcriptions/ ` - Create transcription job
83
93
- ` GET /transcriptions/{job_id} ` - Get job status
@@ -86,38 +96,45 @@ The template-fastapi application provides a comprehensive REST API built with Fa
86
96
- ` DELETE /transcriptions/{job_id} ` - Delete job
87
97
88
98
** Workflow** :
99
+
89
100
1 . Submit audio URLs for batch processing
90
101
2 . Monitor job status (Created → Running → Succeeded/Failed)
91
102
3 . Retrieve transcription results when complete
92
103
93
104
### 5. Agent-Based Conversation API
94
105
95
106
#### LangGraph Agents
107
+
96
108
** Base Path** : ` /agents/langgraph/ `
97
109
98
110
** Purpose** : AI agents with custom tools for mathematical calculations, web search, and time queries.
99
111
100
112
** Endpoints** :
113
+
101
114
- ` GET /tools ` - List available agent tools
102
115
103
116
** Available Tools** :
117
+
104
118
- Calculator: Mathematical expression evaluation
105
119
- Current Time: Timezone-aware time queries
106
120
- Search: Web search capabilities
107
121
108
122
#### Azure AI Foundry Agents
123
+
109
124
** Base Path** : ` /agents/azure-ai-foundry/ `
110
125
111
126
** Purpose** : Thread-based conversational AI using Azure AI Foundry platform.
112
127
113
128
** Agent Management** :
129
+
114
130
- ` GET / ` - List agents
115
131
- ` POST / ` - Create agent
116
132
- ` GET /{agent_id} ` - Get agent details
117
133
- ` DELETE /{agent_id} ` - Delete agent
118
134
- ` POST /{agent_id}/chat ` - Chat with agent
119
135
120
136
** Thread Management** :
137
+
121
138
- ` GET /threads/ ` - List conversation threads
122
139
- ` POST /threads/ ` - Create new thread
123
140
- ` GET /threads/{thread_id} ` - Get thread details
@@ -130,10 +147,12 @@ The template-fastapi application provides a comprehensive REST API built with Fa
130
147
** Purpose** : WebSocket-based real-time chat with HTML interface.
131
148
132
149
** Endpoints** :
150
+
133
151
- ` GET / ` - Chat interface (HTML page)
134
152
- ` WebSocket /ws/{client_id} ` - Real-time messaging
135
153
136
154
** Features** :
155
+
137
156
- Real-time bidirectional communication
138
157
- Multi-client support
139
158
- Agent integration capabilities
@@ -145,6 +164,7 @@ The template-fastapi application provides a comprehensive REST API built with Fa
145
164
** Purpose** : Demonstration endpoints for testing and monitoring.
146
165
147
166
** Endpoints** :
167
+
148
168
- ` GET /roll_dice ` - Random dice roll (1-6)
149
169
- ` GET /flaky/{failure_rate} ` - Configurable failure simulation (0-100%)
150
170
- ` GET /flaky/exception ` - Guaranteed exception endpoint
@@ -153,43 +173,51 @@ The template-fastapi application provides a comprehensive REST API built with Fa
153
173
## Azure Cloud Services Integration
154
174
155
175
### Azure CosmosDB
176
+
156
177
- ** Purpose** : Primary database for items and restaurant data
157
178
- ** Features** : Global distribution, automatic scaling, vector search support
158
179
- ** Configuration** : Connection string in ` AZURE_COSMOSDB_CONNECTION_STRING `
159
180
160
181
### Azure Blob Storage
182
+
161
183
- ** Purpose** : File storage and management
162
184
- ** Features** : Hierarchical namespace, metadata support, CDN integration
163
185
- ** Configuration** : Connection string in ` AZURE_BLOB_STORAGE_CONNECTION_STRING `
164
186
165
187
### Azure OpenAI Service
188
+
166
189
- ** Purpose** : LLM capabilities for agents and embeddings
167
190
- ** Models** : GPT-4o for chat, text-embedding-3-small for search
168
191
- ** Configuration** : Endpoint and API key in environment variables
169
192
170
193
### Azure AI Speech
194
+
171
195
- ** Purpose** : Batch audio transcription
172
196
- ** Features** : Multi-language support, custom vocabulary, speaker diarization
173
197
- ** Configuration** : API key and endpoint in environment variables
174
198
175
199
### Azure AI Foundry
200
+
176
201
- ** Purpose** : Enterprise AI agent platform
177
202
- ** Features** : Thread-based conversations, tool integration, model selection
178
203
- ** Configuration** : Project endpoint and API key
179
204
180
205
### Azure Application Insights
206
+
181
207
- ** Purpose** : Application monitoring and telemetry
182
208
- ** Features** : Request tracing, performance monitoring, custom metrics
183
209
- ** Configuration** : Connection string enables automatic instrumentation
184
210
185
211
## Authentication & Security
186
212
187
213
### Current Implementation
214
+
188
215
- No authentication required (template/development setup)
189
216
- Internal service-to-service authentication via API keys
190
217
- Azure services authenticate via connection strings
191
218
192
219
### Production Recommendations
220
+
193
221
- Implement OAuth 2.0 / JWT authentication
194
222
- Use Azure Active Directory integration
195
223
- Enable API rate limiting
@@ -199,6 +227,7 @@ The template-fastapi application provides a comprehensive REST API built with Fa
199
227
## Error Handling
200
228
201
229
### Standard HTTP Status Codes
230
+
202
231
- ` 200 ` - Success
203
232
- ` 201 ` - Created
204
233
- ` 400 ` - Bad Request (validation errors)
@@ -207,6 +236,7 @@ The template-fastapi application provides a comprehensive REST API built with Fa
207
236
- ` 500 ` - Internal Server Error
208
237
209
238
### Error Response Format
239
+
210
240
``` json
211
241
{
212
242
"detail" : " Error description in Japanese/English" ,
@@ -218,28 +248,33 @@ The template-fastapi application provides a comprehensive REST API built with Fa
218
248
## Monitoring & Observability
219
249
220
250
### Structured Logging
251
+
221
252
- Configurable log levels via ` LOG_LEVEL ` environment variable
222
253
- JSON-structured logs for production deployment
223
254
- Request/response logging with correlation IDs
224
255
225
256
### Metrics & Tracing
257
+
226
258
- OpenTelemetry integration with Azure Application Insights
227
259
- Custom metrics for business operations
228
260
- Distributed tracing across service boundaries
229
261
230
262
### Health Checks
263
+
231
264
- Built-in FastAPI health monitoring
232
265
- Azure service dependency health checks
233
266
- Container readiness and liveness probes
234
267
235
268
## API Versioning & Compatibility
236
269
237
270
### Current Version
271
+
238
272
- API Version: 1.0
239
273
- No explicit versioning in URLs (future consideration)
240
274
- Backward compatibility maintained for minor updates
241
275
242
276
### Future Considerations
277
+
243
278
- URL-based versioning (` /v1/ ` , ` /v2/ ` )
244
279
- Header-based versioning
245
- - Feature flags for gradual rollouts
280
+ - Feature flags for gradual rollouts
0 commit comments