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Provider-agnostic tasarΔ±mΔ± sayesinde farklΔ± LLM, TTS ve STT motorlarΔ± ile Γ§alΔ±Εabilir.
|
6 |
+
|
7 |
+
### Temel Γzellikler
|
8 |
+
- β
Provider-based mimari (LLM, TTS, STT)
|
9 |
+
- β
Intent detection ve parameter extraction
|
10 |
+
- β
AkΔ±llΔ± parametre toplama (smart grouping)
|
11 |
+
- β
Onay mekanizmasΔ± (requiresApproval)
|
12 |
+
- β
Multi-language destek (LocalizedExample, LocalizedCaption)
|
13 |
+
- β
Session-based state machine
|
14 |
+
- β
API orchestration ve response mapping
|
15 |
+
- β
Activity logging ve audit trail
|
16 |
+
|
17 |
+
## π KonfigΓΌrasyon YapΔ±sΔ±
|
18 |
+
|
19 |
+
### service_config.jsonc - Ana YapΔ±
|
20 |
+
```json
|
21 |
+
{
|
22 |
+
"config": {
|
23 |
+
// Provider tanΔ±mlarΔ±
|
24 |
+
"llm_provider": {
|
25 |
+
"name": "spark|gpt4o|gpt4o-mini",
|
26 |
+
"api_key": "enc:...", // ΕifrelenmiΕ
|
27 |
+
"endpoint": "https://...",
|
28 |
+
"settings": {
|
29 |
+
"internal_prompt": "Global LLM yΓΆnergesi",
|
30 |
+
"parameter_collection_config": {
|
31 |
+
"max_params_per_question": 2,
|
32 |
+
"smart_grouping": true,
|
33 |
+
"retry_unanswered": true,
|
34 |
+
"collection_prompt": "..."
|
35 |
+
}
|
36 |
+
}
|
37 |
+
},
|
38 |
+
"tts_provider": {
|
39 |
+
"name": "no_tts|elevenlabs|blaze",
|
40 |
+
"api_key": "enc:...",
|
41 |
+
"endpoint": null,
|
42 |
+
"settings": {}
|
43 |
+
},
|
44 |
+
"stt_provider": {
|
45 |
+
"name": "no_stt|google|azure|flicker",
|
46 |
+
"api_key": "/path/to/credentials.json",
|
47 |
+
"endpoint": null,
|
48 |
+
"settings": {
|
49 |
+
"language": "tr-TR",
|
50 |
+
"model": "latest_long"
|
51 |
+
}
|
52 |
+
},
|
53 |
+
"providers": [
|
54 |
+
// KullanΔ±labilir provider tanΔ±mlarΔ±
|
55 |
+
],
|
56 |
+
"users": [...]
|
57 |
+
},
|
58 |
+
"projects": [...],
|
59 |
+
"apis": [...],
|
60 |
+
"activity_log": [...],
|
61 |
+
"project_id_counter": 1,
|
62 |
+
"last_update_date": null,
|
63 |
+
"last_update_user": null
|
64 |
+
}
|
65 |
+
```
|
66 |
+
|
67 |
+
### Provider Sistemi
|
68 |
+
|
69 |
+
#### Provider Config
|
70 |
+
```json
|
71 |
+
{
|
72 |
+
"type": "llm|tts|stt",
|
73 |
+
"name": "spark",
|
74 |
+
"display_name": "Spark LLM",
|
75 |
+
"requires_endpoint": true,
|
76 |
+
"requires_api_key": true,
|
77 |
+
"requires_repo_info": false,
|
78 |
+
"description": "YTU Cosmos Spark LLM"
|
79 |
+
}
|
80 |
+
```
|
81 |
+
|
82 |
+
#### Provider Settings
|
83 |
+
```json
|
84 |
+
{
|
85 |
+
"name": "provider_name",
|
86 |
+
"api_key": "enc:encrypted_key",
|
87 |
+
"endpoint": "https://endpoint",
|
88 |
+
"settings": {
|
89 |
+
// Provider-specific ayarlar
|
90 |
+
}
|
91 |
+
}
|
92 |
+
```
|
93 |
+
|
94 |
+
### Project YapΔ±sΔ±
|
95 |
+
```json
|
96 |
+
{
|
97 |
+
"id": 1,
|
98 |
+
"name": "project_name",
|
99 |
+
"caption": "Proje BaΕlΔ±ΔΔ±",
|
100 |
+
"icon": "folder",
|
101 |
+
"description": "AΓ§Δ±klama",
|
102 |
+
"enabled": true,
|
103 |
+
"default_locale": "tr",
|
104 |
+
"supported_locales": ["tr", "en"],
|
105 |
+
"timezone": "Europe/Istanbul",
|
106 |
+
"region": "tr-TR",
|
107 |
+
"versions": [...],
|
108 |
+
"version_id_counter": 1,
|
109 |
+
"deleted": false,
|
110 |
+
"created_date": "2024-01-01T00:00:00Z",
|
111 |
+
"created_by": "username",
|
112 |
+
"last_update_date": null,
|
113 |
+
"last_update_user": null
|
114 |
+
}
|
115 |
+
```
|
116 |
+
|
117 |
+
### Version YapΔ±sΔ±
|
118 |
+
```json
|
119 |
+
{
|
120 |
+
"id": 1,
|
121 |
+
"no": 1,
|
122 |
+
"caption": "v1",
|
123 |
+
"description": "Version aΓ§Δ±klamasΔ±",
|
124 |
+
"published": true,
|
125 |
+
"deleted": false,
|
126 |
+
"general_prompt": "Asistan iΓ§in genel yΓΆnerge",
|
127 |
+
"welcome_prompt": "HoΕgeldin mesajΔ± yΓΆnergesi",
|
128 |
+
"llm": {
|
129 |
+
"repo_id": "model-id",
|
130 |
+
"generation_config": {},
|
131 |
+
"use_fine_tune": false,
|
132 |
+
"fine_tune_zip": ""
|
133 |
+
},
|
134 |
+
"intents": [...],
|
135 |
+
"created_date": "2024-01-01T00:00:00Z",
|
136 |
+
"created_by": "username",
|
137 |
+
"publish_date": null,
|
138 |
+
"published_by": null
|
139 |
+
}
|
140 |
+
```
|
141 |
+
|
142 |
+
### Intent YapΔ±sΔ±
|
143 |
+
```json
|
144 |
+
{
|
145 |
+
"name": "intent_name",
|
146 |
+
"caption": "Intent BaΕlΔ±ΔΔ±",
|
147 |
+
"requiresApproval": false,
|
148 |
+
"dependencies": [],
|
149 |
+
"examples": [
|
150 |
+
{
|
151 |
+
"locale_code": "tr",
|
152 |
+
"example": "Γrnek cΓΌmle"
|
153 |
+
}
|
154 |
+
],
|
155 |
+
"detection_prompt": "Intent algΔ±lama yΓΆnergesi",
|
156 |
+
"parameters": [...],
|
157 |
+
"action": "api_name",
|
158 |
+
"fallback_timeout_prompt": "Zaman aΕΔ±mΔ± mesajΔ±",
|
159 |
+
"fallback_error_prompt": "Hata mesajΔ±"
|
160 |
+
}
|
161 |
+
```
|
162 |
+
|
163 |
+
### Parameter YapΔ±sΔ±
|
164 |
+
```json
|
165 |
+
{
|
166 |
+
"name": "param_name",
|
167 |
+
"caption": [
|
168 |
+
{
|
169 |
+
"locale_code": "tr",
|
170 |
+
"caption": "Parametre BaΕlΔ±ΔΔ±"
|
171 |
+
}
|
172 |
+
],
|
173 |
+
"type": "str|int|float|bool|date",
|
174 |
+
"required": true,
|
175 |
+
"variable_name": "variable_name",
|
176 |
+
"extraction_prompt": "Parametre Γ§Δ±karma yΓΆnergesi",
|
177 |
+
"validation_regex": "^pattern$",
|
178 |
+
"invalid_prompt": "GeΓ§ersiz deΔer mesajΔ±",
|
179 |
+
"type_error_prompt": "Tip hatasΔ± mesajΔ±"
|
180 |
+
}
|
181 |
+
```
|
182 |
+
|
183 |
+
### API YapΔ±sΔ±
|
184 |
+
```json
|
185 |
+
{
|
186 |
+
"name": "api_name",
|
187 |
+
"description": "{{variables.x}} iΓ§in iΕlem aΓ§Δ±klamasΔ±",
|
188 |
+
"url": "https://api-endpoint",
|
189 |
+
"method": "GET|POST|PUT|DELETE",
|
190 |
+
"headers": "{}", // JSON string
|
191 |
+
"body_template": "{}", // JSON string
|
192 |
+
"timeout_seconds": 10,
|
193 |
+
"retry": {
|
194 |
+
"max_attempts": 3,
|
195 |
+
"backoff_seconds": 2,
|
196 |
+
"strategy": "static|exponential"
|
197 |
+
},
|
198 |
+
"auth": {
|
199 |
+
"enabled": true,
|
200 |
+
"token_endpoint": "https://auth-endpoint",
|
201 |
+
"response_token_path": "access_token",
|
202 |
+
"token_request_body": "{}",
|
203 |
+
"token_refresh_endpoint": null,
|
204 |
+
"token_refresh_body": "{}"
|
205 |
+
},
|
206 |
+
"response_mappings": [
|
207 |
+
{
|
208 |
+
"variable_name": "result",
|
209 |
+
"caption": "SonuΓ§",
|
210 |
+
"type": "str",
|
211 |
+
"json_path": "$.data.result"
|
212 |
+
}
|
213 |
+
],
|
214 |
+
"response_prompt": "Response insanileΕtirme yΓΆnergesi",
|
215 |
+
"deleted": false,
|
216 |
+
"created_date": "2024-01-01T00:00:00Z",
|
217 |
+
"created_by": "username"
|
218 |
+
}
|
219 |
+
```
|
220 |
+
|
221 |
+
## π Session ve State YΓΆnetimi
|
222 |
+
|
223 |
+
### Session Γzellikleri
|
224 |
+
```python
|
225 |
+
class Session:
|
226 |
+
session_id: str
|
227 |
+
project_name: str
|
228 |
+
version_number: int
|
229 |
+
version_config: VersionConfig
|
230 |
+
|
231 |
+
# State machine
|
232 |
+
state: str # idle | await_param | call_api | humanize
|
233 |
+
last_intent: str | None
|
234 |
+
awaiting_parameters: List[str]
|
235 |
+
missing_ask_count: int
|
236 |
+
|
237 |
+
# Data storage
|
238 |
+
variables: Dict[str, str]
|
239 |
+
auth_tokens: Dict[str, Dict]
|
240 |
+
chat_history: List[Dict[str, str]]
|
241 |
+
|
242 |
+
# Smart parameter tracking
|
243 |
+
asked_parameters: Dict[str, int]
|
244 |
+
unanswered_parameters: List[str]
|
245 |
+
parameter_ask_rounds: int
|
246 |
+
|
247 |
+
# Real-time support
|
248 |
+
is_realtime_session: bool
|
249 |
+
active_websocket: Any
|
250 |
+
```
|
251 |
+
|
252 |
+
### State Machine Flow
|
253 |
+
```
|
254 |
+
start_session β welcome_prompt
|
255 |
+
β
|
256 |
+
idle β β β β β β β β β β β β β β β β β β β β β
|
257 |
+
β β
|
258 |
+
detect_intent β collect_params β approval? β call_api β humanize
|
259 |
+
β β
|
260 |
+
β await_param β
|
261 |
+
```
|
262 |
+
|
263 |
+
## π Onay MekanizmasΔ±
|
264 |
+
|
265 |
+
Intent'te `requiresApproval: true` olduΔunda:
|
266 |
+
|
267 |
+
1. **Otomatik parametre ekleme**: `is_approved` parametresi dinamik olarak eklenir
|
268 |
+
2. **Onay sorusu oluΕturma**: API description'daki placeholder'lar deΔiΕtirilir
|
269 |
+
3. **Onay kontrolΓΌ**:
|
270 |
+
- Onay verilirse β API Γ§aΔrΔ±sΔ±
|
271 |
+
- Onay verilmezse β Δ°Εlem iptali
|
272 |
+
|
273 |
+
## π Multi-Language Destek
|
274 |
+
|
275 |
+
### Locale YΓΆnetimi
|
276 |
+
- Project seviyesinde `default_locale` ve `supported_locales`
|
277 |
+
- LocalizedExample ve LocalizedCaption yapΔ±larΔ±
|
278 |
+
- Locale JSON dosyalarΔ± (`tr.json`, `en.json`, vb.)
|
279 |
+
|
280 |
+
### LocaleManager
|
281 |
+
```python
|
282 |
+
# Locale bilgilerini yΓΆnetir
|
283 |
+
LocaleManager.get_locale("tr")
|
284 |
+
LocaleManager.format_date(date, "tr")
|
285 |
+
LocaleManager.parse_date_expression("yarΔ±n", "tr")
|
286 |
+
LocaleManager.format_number(1234.56, "tr")
|
287 |
+
```
|
288 |
+
|
289 |
+
## π€ TTS/STT Entegrasyonu
|
290 |
+
|
291 |
+
### TTS Providers
|
292 |
+
- **ElevenLabs**: YΓΌksek kaliteli, Γ§ok dilli
|
293 |
+
- **Blaze**: Alternatif TTS
|
294 |
+
- **No TTS**: Devre dΔ±ΕΔ±
|
295 |
+
|
296 |
+
### STT Providers
|
297 |
+
- **Google**: Cloud Speech-to-Text
|
298 |
+
- **Azure**: Azure Speech Services
|
299 |
+
- **Flicker**: Alternatif STT
|
300 |
+
- **No STT**: Devre dΔ±ΕΔ±
|
301 |
+
|
302 |
+
### Real-time Features
|
303 |
+
- WebSocket-based audio streaming
|
304 |
+
- Voice Activity Detection (VAD)
|
305 |
+
- Noise reduction
|
306 |
+
- Interim results
|
307 |
+
|
308 |
+
## π LLM Provider DesteΔi
|
309 |
+
|
310 |
+
### Spark
|
311 |
+
- YTU Cosmos modelleri
|
312 |
+
- HuggingFace Cloud veya on-premise
|
313 |
+
- Custom fine-tuning desteΔi
|
314 |
+
|
315 |
+
### GPT-4o / GPT-4o-mini
|
316 |
+
- OpenAI API entegrasyonu
|
317 |
+
- Temperature ve max_tokens kontrolΓΌ
|
318 |
+
- Maliyet optimizasyonu
|
319 |
+
|
320 |
+
### Provider SeΓ§imi
|
321 |
+
```python
|
322 |
+
# chat_handler.py
|
323 |
+
if llm_provider.name == "spark":
|
324 |
+
llm = SparkLLM(endpoint, token)
|
325 |
+
elif llm_provider.name.startswith("gpt4o"):
|
326 |
+
llm = GPT4oLLM(api_key, model)
|
327 |
+
```
|
328 |
+
|
329 |
+
## π‘ API YΓΆnetimi
|
330 |
+
|
331 |
+
### API ΓaΔrΔ± SΓΌreci
|
332 |
+
1. **Variable substitution**: `{{variables.xxx}}` β gerΓ§ek deΔerler
|
333 |
+
2. **Auth token yΓΆnetimi**: Otomatik token alma ve yenileme
|
334 |
+
3. **Retry logic**: Configurable retry stratejisi
|
335 |
+
4. **Response mapping**: JSON path ile veri Γ§Δ±karma
|
336 |
+
5. **Response humanization**: LLM ile insanileΕtirme
|
337 |
+
|
338 |
+
### Auth MekanizmasΔ±
|
339 |
+
```python
|
340 |
+
# Token alma ve cache'leme
|
341 |
+
if api.auth.enabled:
|
342 |
+
token = get_or_refresh_token(api, session)
|
343 |
+
headers["Authorization"] = f"Bearer {token}"
|
344 |
+
```
|
345 |
+
|
346 |
+
## π GΓΌvenlik
|
347 |
+
|
348 |
+
### Encryption
|
349 |
+
- API key'ler `enc:` prefix ile ΕifrelenmiΕ saklanΔ±r
|
350 |
+
- Fernet encryption (symmetric)
|
351 |
+
- Environment variable: `FERNET_KEY`
|
352 |
+
|
353 |
+
### Authentication
|
354 |
+
- JWT-based session yΓΆnetimi
|
355 |
+
- Bcrypt password hashing
|
356 |
+
- Session timeout kontrolΓΌ
|
357 |
+
|
358 |
+
### Race Condition KorumasΔ±
|
359 |
+
- `last_update_date` ile optimistic locking
|
360 |
+
- Thread-safe session store
|
361 |
+
- Concurrent update kontrolΓΌ
|
362 |
+
|
363 |
+
## π Monitoring ve Logging
|
364 |
+
|
365 |
+
### Activity Log
|
366 |
+
```json
|
367 |
+
{
|
368 |
+
"timestamp": "2024-01-01T00:00:00Z",
|
369 |
+
"username": "admin",
|
370 |
+
"action": "CREATE_PROJECT",
|
371 |
+
"entity_type": "project",
|
372 |
+
"entity_id": 1,
|
373 |
+
"entity_name": "project_name",
|
374 |
+
"details": "Additional info"
|
375 |
+
}
|
376 |
+
```
|
377 |
+
|
378 |
+
### Log Actions
|
379 |
+
- Project CRUD: CREATE, UPDATE, DELETE, ENABLE, DISABLE
|
380 |
+
- Version: CREATE, UPDATE, PUBLISH, DELETE
|
381 |
+
- API: CREATE, UPDATE, DELETE
|
382 |
+
- Environment: UPDATE_ENVIRONMENT
|
383 |
+
- Import/Export: IMPORT_PROJECT, EXPORT_PROJECT
|
384 |
+
|
385 |
+
## π§ͺ Test ve Development
|
386 |
+
|
387 |
+
### Mock Backend
|
388 |
+
- Scenario-based testing
|
389 |
+
- Configurable responses
|
390 |
+
- Error simulation
|
391 |
+
|
392 |
+
### Debug Features
|
393 |
+
- Detailed timestamped logging
|
394 |
+
- Request/Response tracking
|
395 |
+
- Performance metrics
|
396 |
+
|
397 |
+
## π Import/Export
|
398 |
+
|
399 |
+
### Project Export Format
|
400 |
+
```json
|
401 |
+
{
|
402 |
+
"name": "project_name",
|
403 |
+
"caption": "Project Caption",
|
404 |
+
"icon": "folder",
|
405 |
+
"description": "Description",
|
406 |
+
"default_locale": "tr",
|
407 |
+
"supported_locales": ["tr", "en"],
|
408 |
+
"versions": [
|
409 |
+
{
|
410 |
+
"caption": "v1",
|
411 |
+
"general_prompt": "...",
|
412 |
+
"llm": {...},
|
413 |
+
"intents": [...]
|
414 |
+
}
|
415 |
+
]
|
416 |
+
}
|
417 |
+
```
|
418 |
+
|
419 |
+
## π¦ Production Deployment
|
420 |
+
|
421 |
+
### Docker Support
|
422 |
+
- HuggingFace Spaces uyumlu
|
423 |
+
- Health check endpoint
|
424 |
+
- Environment-based configuration
|
425 |
+
- Volume mount iΓ§in permission handling
|
426 |
+
|
427 |
+
### Environment Variables
|
428 |
+
```bash
|
429 |
+
FERNET_KEY=... # Encryption key
|
430 |
+
SPARK_TOKEN=... # Spark API token
|
431 |
+
OPENAI_API_KEY=... # GPT-4o key
|
432 |
+
GOOGLE_APPLICATION_CREDENTIALS=... # STT credentials
|
433 |
+
HF_HOME=/app/.cache # HuggingFace cache
|
434 |
+
```
|
435 |
+
|
436 |
+
### Health Check
|
437 |
+
```python
|
438 |
+
@app.get("/")
|
439 |
+
def health():
|
440 |
+
return {"status": "ok"}
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Flare Administration UI - GΓΌncel TasarΔ±m DokΓΌmanΔ±
|
2 |
+
|
3 |
+
## π Genel BakΔ±Ε
|
4 |
+
|
5 |
+
Flare Administration UI, Flare platformunun web tabanlΔ± yΓΆnetim arayΓΌzΓΌdΓΌr. Angular 16+ ile geliΕtirilmiΕ, Material Design prensiplerine uygun, responsive ve modern bir single-page application'dΔ±r.
|
6 |
+
|
7 |
+
## π Teknik AltyapΔ±
|
8 |
+
|
9 |
+
### Frontend Stack
|
10 |
+
```json
|
11 |
+
{
|
12 |
+
"framework": "Angular 16+",
|
13 |
+
"ui_library": "Angular Material",
|
14 |
+
"styling": "SCSS + Tailwind CSS (utility classes)",
|
15 |
+
"state_management": "RxJS + Services",
|
16 |
+
"http": "HttpClient with Interceptors",
|
17 |
+
"icons": "Material Icons + Lucide",
|
18 |
+
"editor": "CodeMirror (JSON/JSONC)",
|
19 |
+
"charts": "Chart.js",
|
20 |
+
"build": "Standalone Components"
|
21 |
+
}
|
22 |
+
```
|
23 |
+
|
24 |
+
### Backend Integration
|
25 |
+
- RESTful API endpoints
|
26 |
+
- JWT Authentication (`X-Auth-Token` header)
|
27 |
+
- Real-time updates (WebSocket - planned)
|
28 |
+
- File upload/download (import/export)
|
29 |
+
|
30 |
+
## π¨ UI YapΔ±sΔ±
|
31 |
+
|
32 |
+
### 1. Layout Structure
|
33 |
+
```
|
34 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
35 |
+
β Flare Admin [Environment] [User βΌ] [Logout] β <- Header
|
36 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
37 |
+
β Projects | APIs | Users | Logs | [Config β] β <- Tab Bar
|
38 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
39 |
+
β β
|
40 |
+
β [Tab Content] β <- Content Area
|
41 |
+
β β
|
42 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
43 |
+
```
|
44 |
+
|
45 |
+
### 2. Login Component
|
46 |
+
- Material card design
|
47 |
+
- Username/Password fields
|
48 |
+
- "Remember Me" checkbox
|
49 |
+
- Error handling with snackbar
|
50 |
+
- Auto-redirect after login
|
51 |
+
|
52 |
+
### 3. Projects Tab
|
53 |
+
|
54 |
+
#### Project List View
|
55 |
+
```typescript
|
56 |
+
interface ProjectDisplay {
|
57 |
+
id: number;
|
58 |
+
name: string;
|
59 |
+
caption: string;
|
60 |
+
icon: string;
|
61 |
+
enabled: boolean;
|
62 |
+
versionCount: number;
|
63 |
+
lastUpdate?: string;
|
64 |
+
}
|
65 |
+
```
|
66 |
+
|
67 |
+
**Features:**
|
68 |
+
- Grid layout (responsive cards)
|
69 |
+
- Quick actions: Edit, Toggle Enable, Delete
|
70 |
+
- Version count badge
|
71 |
+
- Status indicator (enabled/disabled)
|
72 |
+
- Search/Filter toolbar
|
73 |
+
- "New Project" FAB
|
74 |
+
|
75 |
+
#### Project Edit Dialog
|
76 |
+
**Tabs Structure:**
|
77 |
+
1. **Basic Info**
|
78 |
+
- Name, Caption, Icon selector
|
79 |
+
- Description (textarea)
|
80 |
+
- Locale settings (default + supported)
|
81 |
+
- Timezone and region
|
82 |
+
|
83 |
+
2. **Versions**
|
84 |
+
- Version list with status badges
|
85 |
+
- Actions: Edit, Copy, Publish, Delete
|
86 |
+
- Published versions are read-only
|
87 |
+
- Version comparison (planned)
|
88 |
+
|
89 |
+
3. **Settings**
|
90 |
+
- Advanced project settings
|
91 |
+
- Integration configs
|
92 |
+
|
93 |
+
#### Version Editor
|
94 |
+
**Split-panel Layout:**
|
95 |
+
```
|
96 |
+
βββββββββββββββββββ¬βββββββββββββββββββββββββ
|
97 |
+
β Intent List β Intent Details β
|
98 |
+
β βββββββββββββββ β βββββββββββββββββββ β
|
99 |
+
β β searchFlights β Name: searchFlights β
|
100 |
+
β bookFlight β Caption: UΓ§uΕ Arama β
|
101 |
+
β checkBooking β [Requires Approval: β‘] β
|
102 |
+
β + Add Intent β Examples: [...] β
|
103 |
+
βββββββββββββββββββ΄βββββββββββββββββββββββββ
|
104 |
+
```
|
105 |
+
|
106 |
+
**Version Fields:**
|
107 |
+
- General Prompt (CodeMirror editor)
|
108 |
+
- Welcome Prompt (with LLM preview)
|
109 |
+
- LLM Configuration
|
110 |
+
- Model selection
|
111 |
+
- Generation config (expandable)
|
112 |
+
- Fine-tune settings
|
113 |
+
|
114 |
+
#### Intent Editor
|
115 |
+
**Sections:**
|
116 |
+
1. **Basic Info**
|
117 |
+
- Name (auto-slug)
|
118 |
+
- Caption
|
119 |
+
- requiresApproval toggle
|
120 |
+
- Dependencies (multi-select)
|
121 |
+
|
122 |
+
2. **Examples** (Multilingual)
|
123 |
+
```typescript
|
124 |
+
interface ExampleEditor {
|
125 |
+
locale: string;
|
126 |
+
examples: string[];
|
127 |
+
}
|
128 |
+
```
|
129 |
+
- Tab per locale
|
130 |
+
- Add/Remove examples
|
131 |
+
- Bulk import
|
132 |
+
|
133 |
+
3. **Parameters**
|
134 |
+
- Drag-drop reordering
|
135 |
+
- Inline editing
|
136 |
+
- Type-specific validators
|
137 |
+
- Multi-language captions
|
138 |
+
|
139 |
+
4. **Action**
|
140 |
+
- API selection dropdown
|
141 |
+
- API preview panel
|
142 |
+
- Test action (planned)
|
143 |
+
|
144 |
+
#### Parameter Editor Component
|
145 |
+
```html
|
146 |
+
<app-parameter-editor
|
147 |
+
[parameter]="param"
|
148 |
+
[locales]="['tr', 'en']"
|
149 |
+
[availableVariables]="variables"
|
150 |
+
(change)="onParameterChange($event)">
|
151 |
+
</app-parameter-editor>
|
152 |
+
```
|
153 |
+
|
154 |
+
**Features:**
|
155 |
+
- Smart variable name generation
|
156 |
+
- Type-specific controls
|
157 |
+
- Regex validator with tester
|
158 |
+
- Multi-language support
|
159 |
+
|
160 |
+
### 4. APIs Tab
|
161 |
+
|
162 |
+
#### API List
|
163 |
+
**DataTable Columns:**
|
164 |
+
- Name | URL | Method | Auth | Response | Actions
|
165 |
+
|
166 |
+
**Features:**
|
167 |
+
- Sorting and filtering
|
168 |
+
- Inline status indicators
|
169 |
+
- Batch operations
|
170 |
+
- Export to CSV
|
171 |
+
|
172 |
+
#### API Edit Dialog
|
173 |
+
**Advanced Tab Structure:**
|
174 |
+
|
175 |
+
1. **Basic Configuration**
|
176 |
+
```typescript
|
177 |
+
interface APIBasic {
|
178 |
+
name: string;
|
179 |
+
description?: string; // For approval messages
|
180 |
+
url: string;
|
181 |
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
182 |
+
}
|
183 |
+
```
|
184 |
+
|
185 |
+
2. **Headers & Body**
|
186 |
+
- JSON editor with syntax highlighting
|
187 |
+
- Variable autocomplete (`{{variables.xxx}}`)
|
188 |
+
- Template validation
|
189 |
+
- Format/Beautify button
|
190 |
+
|
191 |
+
3. **Authentication**
|
192 |
+
- Enable/Disable toggle
|
193 |
+
- Token endpoint configuration
|
194 |
+
- Token path (JSON path)
|
195 |
+
- Refresh mechanism setup
|
196 |
+
|
197 |
+
4. **Response Configuration**
|
198 |
+
- Response prompt editor
|
199 |
+
- Response mappings builder
|
200 |
+
- JSON path tester
|
201 |
+
- Sample response upload
|
202 |
+
|
203 |
+
5. **Advanced Settings**
|
204 |
+
- Timeout configuration
|
205 |
+
- Retry strategy
|
206 |
+
- Proxy settings
|
207 |
+
|
208 |
+
#### Response Mapping Builder
|
209 |
+
```typescript
|
210 |
+
interface ResponseMapping {
|
211 |
+
variable_name: string;
|
212 |
+
caption: string;
|
213 |
+
type: string;
|
214 |
+
json_path: string;
|
215 |
+
}
|
216 |
+
```
|
217 |
+
|
218 |
+
**Visual JSON Path Builder:**
|
219 |
+
- Upload sample response
|
220 |
+
- Click to build path
|
221 |
+
- Real-time validation
|
222 |
+
- Type inference
|
223 |
+
|
224 |
+
### 5. Environment Configuration
|
225 |
+
|
226 |
+
#### Provider Management
|
227 |
+
```
|
228 |
+
βββββββββββββββββββββββββββββββββββββββββββ
|
229 |
+
β LLM Provider β
|
230 |
+
β βββββββββββββββββββββββββββββββββββββββ β
|
231 |
+
β β β‘ Spark LLM [Configure βΌ] β β
|
232 |
+
β βββββββββββββββββββββββββββββββββββββββ β
|
233 |
+
β β
|
234 |
+
β TTS Provider β
|
235 |
+
β βββββββββββββββββββββββββββββββββββββββ β
|
236 |
+
β β π ElevenLabs [Configure βΌ] β β
|
237 |
+
β βββββββββββββββββββββββββββββββββββββββ β
|
238 |
+
β β
|
239 |
+
β STT Provider β
|
240 |
+
β βββββββββββββββββββββββββββββββββββββββ β
|
241 |
+
β β π€ Google STT [Configure βΌ] β β
|
242 |
+
β βββββββββββββββββββββββββββββββββββββββ β
|
243 |
+
βββββββββββββββββββββββββββββββββββββββββββ
|
244 |
+
```
|
245 |
+
|
246 |
+
**Provider Configuration:**
|
247 |
+
- Dynamic form based on provider requirements
|
248 |
+
- API key encryption indicator
|
249 |
+
- Endpoint validation
|
250 |
+
- Test connection button
|
251 |
+
|
252 |
+
#### Internal Prompt Editor
|
253 |
+
- Full-screen CodeMirror
|
254 |
+
- Placeholder hints
|
255 |
+
- Template variables sidebar
|
256 |
+
- Save with validation
|
257 |
+
|
258 |
+
### 6. Activity Logs
|
259 |
+
|
260 |
+
#### Timeline View
|
261 |
+
```typescript
|
262 |
+
interface ActivityLog {
|
263 |
+
timestamp: string;
|
264 |
+
username: string;
|
265 |
+
action: string;
|
266 |
+
entity_type: string;
|
267 |
+
entity_name?: string;
|
268 |
+
details?: string;
|
269 |
+
}
|
270 |
+
```
|
271 |
+
|
272 |
+
**Features:**
|
273 |
+
- Infinite scroll
|
274 |
+
- Real-time updates
|
275 |
+
- Filter by action/user/date
|
276 |
+
- Export functionality
|
277 |
+
- Detailed view dialog
|
278 |
+
|
279 |
+
### 7. Test Console
|
280 |
+
|
281 |
+
#### Chat Test Interface
|
282 |
+
```
|
283 |
+
βββββββββββββββββββββββββββββββββββββββββββ
|
284 |
+
β Project: [pegasus_airlines βΌ] v[1 βΌ] β
|
285 |
+
βββββββββββββββββββββββββββββββββββββββββββ€
|
286 |
+
β βββββββββββββββββββββββββββββββββββββββ β
|
287 |
+
β β π¬ Chat Messages β β
|
288 |
+
β β βββββββββββββββββββββ β β
|
289 |
+
β β π€ HoΕ geldiniz! β β
|
290 |
+
β β π€ UΓ§uΕ aramak istiyorum β β
|
291 |
+
β β π€ [Intent: searchFlights] β β
|
292 |
+
β β Nereden nereye? β β
|
293 |
+
β βββββββββββββββββββββββββββββββββββββββ β
|
294 |
+
β [Message input] [π€] [Send] β
|
295 |
+
βββββββββββββββββββββββββββββββββββββββββββ€
|
296 |
+
β Session Info | Variables | API Calls β
|
297 |
+
βββββββββββββββββββββββββββββββββββββββββββ
|
298 |
+
```
|
299 |
+
|
300 |
+
**Debug Panel Tabs:**
|
301 |
+
- Session state and variables
|
302 |
+
- Intent detection details
|
303 |
+
- API call history
|
304 |
+
- Raw LLM responses
|
305 |
+
|
306 |
+
## π§© Reusable Components
|
307 |
+
|
308 |
+
### 1. Multi-Language Input
|
309 |
+
```typescript
|
310 |
+
@Component({
|
311 |
+
selector: 'app-multilang-input',
|
312 |
+
template: `
|
313 |
+
<mat-tab-group>
|
314 |
+
<mat-tab *ngFor="let locale of locales">
|
315 |
+
<ng-template mat-tab-label>
|
316 |
+
{{ getLocaleName(locale) }}
|
317 |
+
</ng-template>
|
318 |
+
<mat-form-field>
|
319 |
+
<input matInput [(ngModel)]="values[locale]">
|
320 |
+
</mat-form-field>
|
321 |
+
</mat-tab>
|
322 |
+
</mat-tab-group>
|
323 |
+
`
|
324 |
+
})
|
325 |
+
export class MultilangInputComponent {
|
326 |
+
@Input() locales: string[];
|
327 |
+
@Input() values: LocalizedValue[];
|
328 |
+
@Output() change = new EventEmitter();
|
329 |
+
}
|
330 |
+
```
|
331 |
+
|
332 |
+
### 2. Variable Selector
|
333 |
+
```typescript
|
334 |
+
interface Variable {
|
335 |
+
name: string;
|
336 |
+
source: 'intent' | 'api' | 'system';
|
337 |
+
type: string;
|
338 |
+
}
|
339 |
+
```
|
340 |
+
|
341 |
+
**Features:**
|
342 |
+
- Categorized dropdown
|
343 |
+
- Search functionality
|
344 |
+
- Type indicators
|
345 |
+
- Copy to clipboard
|
346 |
+
|
347 |
+
### 3. JSON Editor Wrapper
|
348 |
+
```typescript
|
349 |
+
@Component({
|
350 |
+
selector: 'app-json-editor',
|
351 |
+
template: `
|
352 |
+
<div class="editor-container">
|
353 |
+
<codemirror
|
354 |
+
[(ngModel)]="value"
|
355 |
+
[options]="editorOptions"
|
356 |
+
(change)="onChange()">
|
357 |
+
</codemirror>
|
358 |
+
<button mat-icon-button (click)="format()">
|
359 |
+
<mat-icon>format_align_left</mat-icon>
|
360 |
+
</button>
|
361 |
+
</div>
|
362 |
+
`
|
363 |
+
})
|
364 |
+
```
|
365 |
+
|
366 |
+
### 4. Confirmation Dialog
|
367 |
+
```typescript
|
368 |
+
interface ConfirmData {
|
369 |
+
title: string;
|
370 |
+
message: string;
|
371 |
+
confirmText?: string;
|
372 |
+
cancelText?: string;
|
373 |
+
dangerous?: boolean;
|
374 |
+
}
|
375 |
+
```
|
376 |
+
|
377 |
+
## π― Services Architecture
|
378 |
+
|
379 |
+
### Core Services
|
380 |
+
```typescript
|
381 |
+
// API communication
|
382 |
+
@Injectable()
|
383 |
+
export class ApiService {
|
384 |
+
// Project CRUD
|
385 |
+
getProjects(): Observable<Project[]>
|
386 |
+
createProject(data: ProjectData): Observable<Project>
|
387 |
+
updateProject(id: number, data: ProjectData): Observable<Project>
|
388 |
+
|
389 |
+
// Version management
|
390 |
+
createVersion(projectId: number): Observable<Version>
|
391 |
+
publishVersion(projectId: number, versionId: number): Observable<Version>
|
392 |
+
|
393 |
+
// Environment
|
394 |
+
getEnvironment(): Observable<EnvironmentConfig>
|
395 |
+
updateEnvironment(config: EnvironmentConfig): Observable<void>
|
396 |
+
}
|
397 |
+
|
398 |
+
// Authentication
|
399 |
+
@Injectable()
|
400 |
+
export class AuthService {
|
401 |
+
login(credentials: LoginData): Observable<AuthResponse>
|
402 |
+
logout(): void
|
403 |
+
getToken(): string | null
|
404 |
+
isAuthenticated(): boolean
|
405 |
+
}
|
406 |
+
|
407 |
+
// Environment state
|
408 |
+
@Injectable()
|
409 |
+
export class EnvironmentService {
|
410 |
+
ttsEnabled$: BehaviorSubject<boolean>
|
411 |
+
sttEnabled$: BehaviorSubject<boolean>
|
412 |
+
currentProvider$: BehaviorSubject<ProviderInfo>
|
413 |
+
}
|
414 |
+
```
|
415 |
+
|
416 |
+
### HTTP Interceptor
|
417 |
+
```typescript
|
418 |
+
@Injectable()
|
419 |
+
export class AuthInterceptor implements HttpInterceptor {
|
420 |
+
intercept(req: HttpRequest<any>, next: HttpHandler) {
|
421 |
+
const token = this.authService.getToken();
|
422 |
+
if (token) {
|
423 |
+
req = req.clone({
|
424 |
+
setHeaders: { 'X-Auth-Token': token }
|
425 |
+
});
|
426 |
+
}
|
427 |
+
return next.handle(req);
|
428 |
+
}
|
429 |
+
}
|
430 |
+
```
|
431 |
+
|
432 |
+
## π¨ Theming and Styling
|
433 |
+
|
434 |
+
### Material Theme
|
435 |
+
```scss
|
436 |
+
// Custom theme
|
437 |
+
$primary: mat-palette($mat-indigo);
|
438 |
+
$accent: mat-palette($mat-pink, A200);
|
439 |
+
$warn: mat-palette($mat-red);
|
440 |
+
|
441 |
+
$theme: mat-light-theme((
|
442 |
+
color: (
|
443 |
+
primary: $primary,
|
444 |
+
accent: $accent,
|
445 |
+
warn: $warn
|
446 |
+
)
|
447 |
+
));
|
448 |
+
|
449 |
+
// Dark theme
|
450 |
+
$dark-theme: mat-dark-theme((
|
451 |
+
color: (
|
452 |
+
primary: $primary,
|
453 |
+
accent: $accent,
|
454 |
+
warn: $warn
|
455 |
+
)
|
456 |
+
));
|
457 |
+
```
|
458 |
+
|
459 |
+
### Component Styling Pattern
|
460 |
+
```scss
|
461 |
+
.component-container {
|
462 |
+
@apply p-4 h-full flex flex-col;
|
463 |
+
|
464 |
+
.header {
|
465 |
+
@apply flex justify-between items-center mb-4;
|
466 |
+
}
|
467 |
+
|
468 |
+
.content {
|
469 |
+
@apply flex-1 overflow-auto;
|
470 |
+
}
|
471 |
+
|
472 |
+
.actions {
|
473 |
+
@apply mt-4 flex justify-end gap-2;
|
474 |
+
}
|
475 |
+
}
|
476 |
+
```
|
477 |
+
|
478 |
+
## π± Responsive Design
|
479 |
+
|
480 |
+
### Breakpoints
|
481 |
+
```scss
|
482 |
+
$mobile: 640px;
|
483 |
+
$tablet: 768px;
|
484 |
+
$desktop: 1024px;
|
485 |
+
$wide: 1280px;
|
486 |
+
```
|
487 |
+
|
488 |
+
### Mobile Adaptations
|
489 |
+
- Collapsible sidebar
|
490 |
+
- Bottom sheet dialogs
|
491 |
+
- Touch-optimized controls
|
492 |
+
- Simplified layouts
|
493 |
+
|
494 |
+
## π Performance Optimizations
|
495 |
+
|
496 |
+
### Lazy Loading
|
497 |
+
```typescript
|
498 |
+
const routes: Routes = [
|
499 |
+
{
|
500 |
+
path: 'projects',
|
501 |
+
loadChildren: () => import('./projects/projects.module')
|
502 |
+
.then(m => m.ProjectsModule)
|
503 |
+
}
|
504 |
+
];
|
505 |
+
```
|
506 |
+
|
507 |
+
### Change Detection
|
508 |
+
```typescript
|
509 |
+
@Component({
|
510 |
+
changeDetection: ChangeDetectionStrategy.OnPush
|
511 |
+
})
|
512 |
+
```
|
513 |
+
|
514 |
+
### Virtual Scrolling
|
515 |
+
```html
|
516 |
+
<cdk-virtual-scroll-viewport itemSize="50">
|
517 |
+
<div *cdkVirtualFor="let item of items">
|
518 |
+
{{ item }}
|
519 |
+
</div>
|
520 |
+
</cdk-virtual-scroll-viewport>
|
521 |
+
```
|
522 |
+
|
523 |
+
## π Security Considerations
|
524 |
+
|
525 |
+
### XSS Prevention
|
526 |
+
- Sanitized HTML rendering
|
527 |
+
- Template validation
|
528 |
+
- CSP headers
|
529 |
+
|
530 |
+
### Authentication Flow
|
531 |
+
```
|
532 |
+
Login β JWT Token β Local Storage β HTTP Header β API Validation
|
533 |
+
β β
|
534 |
+
Redirect Auto Logout
|
535 |
+
```
|
536 |
+
|
537 |
+
### Sensitive Data
|
538 |
+
- Encrypted API keys (visual: `β’β’β’β’β’β’β’xyz`)
|
539 |
+
- No plaintext passwords
|
540 |
+
- Secure cookie options
|
541 |
+
|
542 |
+
## π§ͺ Testing Strategy
|
543 |
+
|
544 |
+
### Unit Tests
|
545 |
+
- Component logic
|
546 |
+
- Service methods
|
547 |
+
- Pipe transformations
|
548 |
+
|
549 |
+
### E2E Tests
|
550 |
+
- User workflows
|
551 |
+
- API integration
|
552 |
+
- Error scenarios
|
553 |
+
|
554 |
+
## π Analytics and Monitoring
|
555 |
+
|
556 |
+
### User Activity Tracking
|
557 |
+
- Feature usage metrics
|
558 |
+
- Performance timing
|
559 |
+
- Error reporting
|
560 |
+
|
561 |
+
### Dashboard Metrics
|
562 |
+
- Active projects count
|
563 |
+
- API call statistics
|
564 |
+
- User engagement
|
565 |
+
|
566 |
+
## π¦ Deployment
|
567 |
+
|
568 |
+
### Build Configuration
|
569 |
+
```json
|
570 |
+
{
|
571 |
+
"production": {
|
572 |
+
"optimization": true,
|
573 |
+
"sourceMap": false,
|
574 |
+
"namedChunks": false,
|
575 |
+
"extractLicenses": true,
|
576 |
+
"vendorChunk": false
|
577 |
+
}
|
578 |
+
}
|
579 |
+
```
|
580 |
+
|
581 |
+
### Environment Files
|
582 |
+
```typescript
|
583 |
+
// environment.prod.ts
|
584 |
+
export const environment = {
|
585 |
+
production: true,
|
586 |
+
apiUrl: '/api',
|
587 |
+
wsUrl: 'wss://flare.example.com'
|
588 |
+
};
|
589 |
+
```
|
590 |
+
|
591 |
+
## π Future Enhancements
|
592 |
+
|
593 |
+
### Planned Features
|
594 |
+
1. **Visual Flow Builder**: Drag-drop intent flow designer
|
595 |
+
2. **A/B Testing**: Version comparison framework
|
596 |
+
3. **Analytics Dashboard**: Usage statistics and insights
|
597 |
+
4. **Collaboration**: Multi-user editing with presence
|
598 |
+
5. **Plugin System**: Extensible architecture
|
599 |
+
6. **Mobile App**: Native mobile management app
|
600 |
+
|
601 |
+
### Technical Debt
|
602 |
+
- Migrate to signals (Angular 17+)
|
603 |
+
- Implement state management (NgRx)
|
604 |
+
- Add comprehensive error boundaries
|
605 |
+
- Improve test coverage to 80%+
|