# Dashboard — Implementation Plan

## 1. Scope

Build the CodeIgniter 4 SaaS Dashboard on Debian 13.

The Dashboard manages and monitors the Copier system.

It does not own persistent MT5 WebSocket connections.

## 2. Runtime

Production:

```text
Debian 13
├── Apache native
├── PHP native
└── CodeIgniter 4 native
```

Development:

```text
Mac
├── PHP native
├── CodeIgniter 4 native
└── MySQL native
```

Docker is not used.

## 3. Core Responsibilities

- authentication
- users/roles
- Master Source management
- Follower management
- Master → Follower assignment
- copier credentials
- lot configuration
- symbol mapping
- risk configuration
- connection monitoring
- event monitoring
- execution logs
- position mappings
- audit logs

## 4. Modules

```text
Authentication
Dashboard
Master Sources
Followers
Assignments
Trade Events
Positions
Execution Logs
Configuration
System Health
Audit Logs
```

## 5. Master Source UI

Fields:

```text
Name
Broker
MT5 Login
MT5 Server
Status
Last Seen
```

Display:

```text
ONLINE/OFFLINE
Last heartbeat
Last event
Follower count
```

Read-only credentials should never be displayed in plain text after secure provisioning.

## 6. Follower UI

Fields:

```text
Name
Broker
MT5 Login
MT5 Server
Status
Copy Enabled
Lot Mode
Multiplier
Max Lot
Max Positions
```

## 7. Assignment UI

Example:

```text
MASTER-A
├── F-A1
├── F-A2
└── F-A3
```

Actions:

```text
Assign
Unassign
Enable
Disable
Configure
```

## 8. Dashboard Overview

Example metrics:

```text
Master Sources Online
Followers Online
Open Master Positions
Pending Deliveries
Failed Deliveries
Recent Events
Average Copy Latency
```

## 9. Event Monitoring

Display:

```text
Event ID
Master
Sequence
Event Type
Symbol
Side
Volume
Time
Delivery Status
```

## 10. Execution Monitoring

Display:

```text
Master
Follower
Master Position
Follower Position
Requested Volume
Executed Volume
Requested Price
Executed Price
Status
Error
Latency
```

## 11. Position Mapping

Display:

```text
Master A Position 12345
├── F-A1 Position 90001
├── F-A2 Position 90002
└── F-A3 Position 90003
```

## 12. Configuration

Per Master/Follower relationship support:

```text
Lot Mode
Multiplier
Max Lot
Max Positions
Allowed Symbols
Direction Filter
Symbol Mapping
Copy Enabled
```

## 13. Authentication and Authorization

Implement:

- login
- logout
- password hashing
- session protection
- roles
- permissions
- audit logs

Recommended roles:

```text
ADMIN
OPERATOR
VIEWER
```

## 14. CodeIgniter ↔ Go Boundary

CodeIgniter manages configuration and administration.

Go manages real-time MT5 connections.

Avoid implementing raw MT5 WebSocket connection management inside CodeIgniter.

## 15. Database

Shared MySQL 8.

Dashboard tables:

```text
users
audit_logs
system_settings
```

Operational data may be read from the same shared schema through repositories/services.

Use clear boundaries and avoid uncontrolled writes from both applications.

## 16. Implementation Phases

### Phase 1
Authentication + base layout.

### Phase 2
Master Sources CRUD.

### Phase 3
Followers CRUD.

### Phase 4
Master → Follower assignments.

### Phase 5
Configuration.

### Phase 6
Monitoring.

### Phase 7
Audit/reporting.

## 17. Definition of Done

Admin can:

```text
create Master
create Follower
assign Follower to Master
configure copy settings
enable/disable copying
view status
view events
view execution results
view position mappings
```

