# Admin Portal

The FluxiQ PIX Admin Portal is a Vue 3 single-page application providing comprehensive management of PIX operations, monitoring, and configuration.

## Prerequisites

- FluxiQ PIX backend running and accessible
- Admin user credentials (default: admin / Admin@2026!)
- Modern web browser (Chrome, Firefox, Safari, Edge)

## Overview

| Metric | Value |
|--------|-------|
| Routes | 82 |
| Views | 86 |
| Pinia Stores | 17 |
| Services | 27 |
| Components | 12 |
| Locales | 5 (en, pt, es, zh, fr) |

## Authentication

The admin portal uses a hardened authentication flow:

1. **RSA-OAEP Encryption**: Login credentials encrypted with 2048-bit RSA public key fetched from `/api/v1/auth/public-key`
2. **HttpOnly JWT Cookie**: Session stored in `pix_session` cookie (not accessible to JavaScript)
3. **CSRF Protection**: Double-submit cookie pattern
4. **MFA Support**: Optional TOTP verification step

### Login Flow

```mermaid
sequenceDiagram
    Browser->>+Backend: GET /api/v1/auth/public-key
    Backend-->>-Browser: RSA public key
    Browser->>Browser: Encrypt credentials (RSA-OAEP)
    Browser->>+Backend: POST /api/v1/auth/login
    Backend-->>-Browser: Set-Cookie: pix_session (HttpOnly)
    Browser->>+Backend: GET /api/v1/auth/me
    Backend-->>-Browser: User profile + permissions
```

## Main Sections

### Dashboard
Real-time overview of transaction volume, status distribution, and system health.

### Transactions
- Transaction list with filters (status, E2E ID, date range, instrument type)
- Transaction detail with BCB status labels in Portuguese
- ANS timing section (OK/EXCEEDED badge at 1.6s threshold)
- Status history timeline

### DICT Management
- PIX key list and search
- Key creation and deletion
- Claim management
- CID sync status

### Settlement
- Settlement cycle management
- Netting calculations
- Reconciliation reports
- Balance inquiries

### MED 2.0 (Infraction Reports)
- List reports with ISPB and status filters
- Report detail view
- Actions: Acknowledge, Analyse (AGREED/DISAGREED), Close

### Accounting
- Chart of Accounts (44 COSIF accounts)
- Journal entries with double-entry running balance
- Accounting events
- Cost center management

### Monitoring (Real-Time)
- 6-panel WebSocket dashboard
- Transaction live feed
- System health status
- Settlement status
- DICT operations
- BACEN channel health
- Queue depth monitoring

### System Configuration
- System parameters (13 configurable values)
- Security settings
- Balance parameters

### Users & RBAC
- User management
- Group/role assignment
- Permission management
- Audit logs

### BACEN Simulator
- Simulator status and configuration
- Scenario execution (8 pre-configured)
- Test run results
- Exchange monitoring

## Charts

Three reusable Chart.js components:
- `LineChart.vue` -- time series (TPS, transaction volume)
- `BarChart.vue` -- categorical data (status distribution)
- `DoughnutChart.vue` -- proportional data (instrument breakdown)

## Internationalization

The admin portal supports 5 locales with 568 keys each:
- English (en)
- Portuguese (pt)
- Spanish (es)
- Chinese (zh)
- French (fr)

Switch locale via the language selector in the header.

## Expected Outcome

After accessing the admin portal:

- Dashboard displays real-time transaction metrics
- Navigation provides access to all 82 routes
- Real-time monitoring updates via WebSocket connection
- RBAC controls visibility based on user permissions
