Spaces:
Building
Building
File size: 16,104 Bytes
c616f96 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
# Flare Administration UI - GΓΌncel TasarΔ±m DokΓΌmanΔ±
## π Genel BakΔ±Ε
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.
## π Teknik AltyapΔ±
### Frontend Stack
```json
{
"framework": "Angular 16+",
"ui_library": "Angular Material",
"styling": "SCSS + Tailwind CSS (utility classes)",
"state_management": "RxJS + Services",
"http": "HttpClient with Interceptors",
"icons": "Material Icons + Lucide",
"editor": "CodeMirror (JSON/JSONC)",
"charts": "Chart.js",
"build": "Standalone Components"
}
```
### Backend Integration
- RESTful API endpoints
- JWT Authentication (`X-Auth-Token` header)
- Real-time updates (WebSocket - planned)
- File upload/download (import/export)
## π¨ UI YapΔ±sΔ±
### 1. Layout Structure
```
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Flare Admin [Environment] [User βΌ] [Logout] β <- Header
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Projects | APIs | Users | Logs | [Config β] β <- Tab Bar
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β [Tab Content] β <- Content Area
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
### 2. Login Component
- Material card design
- Username/Password fields
- "Remember Me" checkbox
- Error handling with snackbar
- Auto-redirect after login
### 3. Projects Tab
#### Project List View
```typescript
interface ProjectDisplay {
id: number;
name: string;
caption: string;
icon: string;
enabled: boolean;
versionCount: number;
lastUpdate?: string;
}
```
**Features:**
- Grid layout (responsive cards)
- Quick actions: Edit, Toggle Enable, Delete
- Version count badge
- Status indicator (enabled/disabled)
- Search/Filter toolbar
- "New Project" FAB
#### Project Edit Dialog
**Tabs Structure:**
1. **Basic Info**
- Name, Caption, Icon selector
- Description (textarea)
- Locale settings (default + supported)
- Timezone and region
2. **Versions**
- Version list with status badges
- Actions: Edit, Copy, Publish, Delete
- Published versions are read-only
- Version comparison (planned)
3. **Settings**
- Advanced project settings
- Integration configs
#### Version Editor
**Split-panel Layout:**
```
βββββββββββββββββββ¬βββββββββββββββββββββββββ
β Intent List β Intent Details β
β βββββββββββββββ β βββββββββββββββββββ β
β β searchFlights β Name: searchFlights β
β bookFlight β Caption: UΓ§uΕ Arama β
β checkBooking β [Requires Approval: β‘] β
β + Add Intent β Examples: [...] β
βββββββββββββββββββ΄βββββββββββββββββββββββββ
```
**Version Fields:**
- General Prompt (CodeMirror editor)
- Welcome Prompt (with LLM preview)
- LLM Configuration
- Model selection
- Generation config (expandable)
- Fine-tune settings
#### Intent Editor
**Sections:**
1. **Basic Info**
- Name (auto-slug)
- Caption
- requiresApproval toggle
- Dependencies (multi-select)
2. **Examples** (Multilingual)
```typescript
interface ExampleEditor {
locale: string;
examples: string[];
}
```
- Tab per locale
- Add/Remove examples
- Bulk import
3. **Parameters**
- Drag-drop reordering
- Inline editing
- Type-specific validators
- Multi-language captions
4. **Action**
- API selection dropdown
- API preview panel
- Test action (planned)
#### Parameter Editor Component
```html
<app-parameter-editor
[parameter]="param"
[locales]="['tr', 'en']"
[availableVariables]="variables"
(change)="onParameterChange($event)">
</app-parameter-editor>
```
**Features:**
- Smart variable name generation
- Type-specific controls
- Regex validator with tester
- Multi-language support
### 4. APIs Tab
#### API List
**DataTable Columns:**
- Name | URL | Method | Auth | Response | Actions
**Features:**
- Sorting and filtering
- Inline status indicators
- Batch operations
- Export to CSV
#### API Edit Dialog
**Advanced Tab Structure:**
1. **Basic Configuration**
```typescript
interface APIBasic {
name: string;
description?: string; // For approval messages
url: string;
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
}
```
2. **Headers & Body**
- JSON editor with syntax highlighting
- Variable autocomplete (`{{variables.xxx}}`)
- Template validation
- Format/Beautify button
3. **Authentication**
- Enable/Disable toggle
- Token endpoint configuration
- Token path (JSON path)
- Refresh mechanism setup
4. **Response Configuration**
- Response prompt editor
- Response mappings builder
- JSON path tester
- Sample response upload
5. **Advanced Settings**
- Timeout configuration
- Retry strategy
- Proxy settings
#### Response Mapping Builder
```typescript
interface ResponseMapping {
variable_name: string;
caption: string;
type: string;
json_path: string;
}
```
**Visual JSON Path Builder:**
- Upload sample response
- Click to build path
- Real-time validation
- Type inference
### 5. Environment Configuration
#### Provider Management
```
βββββββββββββββββββββββββββββββββββββββββββ
β LLM Provider β
β βββββββββββββββββββββββββββββββββββββββ β
β β β‘ Spark LLM [Configure βΌ] β β
β βββββββββββββββββββββββββββββββββββββββ β
β β
β TTS Provider β
β βββββββββββββββββββββββββββββββββββββββ β
β β π ElevenLabs [Configure βΌ] β β
β βββββββββββββββββββββββββββββββββββββββ β
β β
β STT Provider β
β βββββββββββββββββββββββββββββββββββββββ β
β β π€ Google STT [Configure βΌ] β β
β βββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββ
```
**Provider Configuration:**
- Dynamic form based on provider requirements
- API key encryption indicator
- Endpoint validation
- Test connection button
#### Internal Prompt Editor
- Full-screen CodeMirror
- Placeholder hints
- Template variables sidebar
- Save with validation
### 6. Activity Logs
#### Timeline View
```typescript
interface ActivityLog {
timestamp: string;
username: string;
action: string;
entity_type: string;
entity_name?: string;
details?: string;
}
```
**Features:**
- Infinite scroll
- Real-time updates
- Filter by action/user/date
- Export functionality
- Detailed view dialog
### 7. Test Console
#### Chat Test Interface
```
βββββββββββββββββββββββββββββββββββββββββββ
β Project: [pegasus_airlines βΌ] v[1 βΌ] β
βββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββββββββββββββββββββββββββ β
β β π¬ Chat Messages β β
β β βββββββββββββββββββββ β β
β β π€ HoΕ geldiniz! β β
β β π€ UΓ§uΕ aramak istiyorum β β
β β π€ [Intent: searchFlights] β β
β β Nereden nereye? β β
β βββββββββββββββββββββββββββββββββββββββ β
β [Message input] [π€] [Send] β
βββββββββββββββββββββββββββββββββββββββββββ€
β Session Info | Variables | API Calls β
βββββββββββββββββββββββββββββββββββββββββββ
```
**Debug Panel Tabs:**
- Session state and variables
- Intent detection details
- API call history
- Raw LLM responses
## π§© Reusable Components
### 1. Multi-Language Input
```typescript
@Component({
selector: 'app-multilang-input',
template: `
<mat-tab-group>
<mat-tab *ngFor="let locale of locales">
<ng-template mat-tab-label>
{{ getLocaleName(locale) }}
</ng-template>
<mat-form-field>
<input matInput [(ngModel)]="values[locale]">
</mat-form-field>
</mat-tab>
</mat-tab-group>
`
})
export class MultilangInputComponent {
@Input() locales: string[];
@Input() values: LocalizedValue[];
@Output() change = new EventEmitter();
}
```
### 2. Variable Selector
```typescript
interface Variable {
name: string;
source: 'intent' | 'api' | 'system';
type: string;
}
```
**Features:**
- Categorized dropdown
- Search functionality
- Type indicators
- Copy to clipboard
### 3. JSON Editor Wrapper
```typescript
@Component({
selector: 'app-json-editor',
template: `
<div class="editor-container">
<codemirror
[(ngModel)]="value"
[options]="editorOptions"
(change)="onChange()">
</codemirror>
<button mat-icon-button (click)="format()">
<mat-icon>format_align_left</mat-icon>
</button>
</div>
`
})
```
### 4. Confirmation Dialog
```typescript
interface ConfirmData {
title: string;
message: string;
confirmText?: string;
cancelText?: string;
dangerous?: boolean;
}
```
## π― Services Architecture
### Core Services
```typescript
// API communication
@Injectable()
export class ApiService {
// Project CRUD
getProjects(): Observable<Project[]>
createProject(data: ProjectData): Observable<Project>
updateProject(id: number, data: ProjectData): Observable<Project>
// Version management
createVersion(projectId: number): Observable<Version>
publishVersion(projectId: number, versionId: number): Observable<Version>
// Environment
getEnvironment(): Observable<EnvironmentConfig>
updateEnvironment(config: EnvironmentConfig): Observable<void>
}
// Authentication
@Injectable()
export class AuthService {
login(credentials: LoginData): Observable<AuthResponse>
logout(): void
getToken(): string | null
isAuthenticated(): boolean
}
// Environment state
@Injectable()
export class EnvironmentService {
ttsEnabled$: BehaviorSubject<boolean>
sttEnabled$: BehaviorSubject<boolean>
currentProvider$: BehaviorSubject<ProviderInfo>
}
```
### HTTP Interceptor
```typescript
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler) {
const token = this.authService.getToken();
if (token) {
req = req.clone({
setHeaders: { 'X-Auth-Token': token }
});
}
return next.handle(req);
}
}
```
## π¨ Theming and Styling
### Material Theme
```scss
// Custom theme
$primary: mat-palette($mat-indigo);
$accent: mat-palette($mat-pink, A200);
$warn: mat-palette($mat-red);
$theme: mat-light-theme((
color: (
primary: $primary,
accent: $accent,
warn: $warn
)
));
// Dark theme
$dark-theme: mat-dark-theme((
color: (
primary: $primary,
accent: $accent,
warn: $warn
)
));
```
### Component Styling Pattern
```scss
.component-container {
@apply p-4 h-full flex flex-col;
.header {
@apply flex justify-between items-center mb-4;
}
.content {
@apply flex-1 overflow-auto;
}
.actions {
@apply mt-4 flex justify-end gap-2;
}
}
```
## π± Responsive Design
### Breakpoints
```scss
$mobile: 640px;
$tablet: 768px;
$desktop: 1024px;
$wide: 1280px;
```
### Mobile Adaptations
- Collapsible sidebar
- Bottom sheet dialogs
- Touch-optimized controls
- Simplified layouts
## π Performance Optimizations
### Lazy Loading
```typescript
const routes: Routes = [
{
path: 'projects',
loadChildren: () => import('./projects/projects.module')
.then(m => m.ProjectsModule)
}
];
```
### Change Detection
```typescript
@Component({
changeDetection: ChangeDetectionStrategy.OnPush
})
```
### Virtual Scrolling
```html
<cdk-virtual-scroll-viewport itemSize="50">
<div *cdkVirtualFor="let item of items">
{{ item }}
</div>
</cdk-virtual-scroll-viewport>
```
## π Security Considerations
### XSS Prevention
- Sanitized HTML rendering
- Template validation
- CSP headers
### Authentication Flow
```
Login β JWT Token β Local Storage β HTTP Header β API Validation
β β
Redirect Auto Logout
```
### Sensitive Data
- Encrypted API keys (visual: `β’β’β’β’β’β’β’xyz`)
- No plaintext passwords
- Secure cookie options
## π§ͺ Testing Strategy
### Unit Tests
- Component logic
- Service methods
- Pipe transformations
### E2E Tests
- User workflows
- API integration
- Error scenarios
## π Analytics and Monitoring
### User Activity Tracking
- Feature usage metrics
- Performance timing
- Error reporting
### Dashboard Metrics
- Active projects count
- API call statistics
- User engagement
## π¦ Deployment
### Build Configuration
```json
{
"production": {
"optimization": true,
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false
}
}
```
### Environment Files
```typescript
// environment.prod.ts
export const environment = {
production: true,
apiUrl: '/api',
wsUrl: 'wss://flare.example.com'
};
```
## π Future Enhancements
### Planned Features
1. **Visual Flow Builder**: Drag-drop intent flow designer
2. **A/B Testing**: Version comparison framework
3. **Analytics Dashboard**: Usage statistics and insights
4. **Collaboration**: Multi-user editing with presence
5. **Plugin System**: Extensible architecture
6. **Mobile App**: Native mobile management app
### Technical Debt
- Migrate to signals (Angular 17+)
- Implement state management (NgRx)
- Add comprehensive error boundaries
- Improve test coverage to 80%+ |