# p-bitm-framework/p-bitm architecture

> Architecture diagram of the GitHub repository p-bitm-framework/p-bitm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/p-bitm-framework/p-bitm
- Repository: https://github.com/p-bitm-framework/p-bitm

## Overview

P-BitM is a containerized platform for authorized browser-in-the-middle security assessments. The principal workflow runs from an operator configuring a campaign in the dashboard, through the admin control plane provisioning isolated campaign and browser workloads, to a victim session being admitted and viewed or managed, with bounded evidence retained for campaign exports. The graph also preserves the documented resource libraries, email scheduling, role-based access, and runtime operations. Most cross-service links follow the README architecture; unsampled route and orchestration internals are not inferred beyond it.

Main entry points: [`server/backend/main.py`](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/main.py) (Admin API), [`server/backend-phishing/app/main.py`](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend-phishing/app/main.py) (Campaign service), [`server/frontend/src/App.vue`](https://github.com/p-bitm-framework/p-bitm/blob/main/server/frontend/src/App.vue) (Admin dashboard), [`server/backend-phishing/app/routes/public.py`](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend-phishing/app/routes/public.py) (Public campaign routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operator_ui["Operator dashboard"]
  node_dashboard["Admin dashboard<br/>[App.vue]"]
  node_campaign_ui["Campaign workflow"]
  node_resource_libraries["Resource libraries"]
  node_victim_console["Victim console"]
end

subgraph group_control_plane["Admin control plane"]
  node_admin_api["Admin API<br/>[main.py]"]
  node_auth["Admin authentication<br/>[auth.py]"]
  node_campaign_routes["Campaign management<br/>[campaigns.py]"]
  node_campaign_models["Campaign and victim state<br/>[campaign.py]"]
  node_admin_store[("Persistent state<br/>[database.py]")]
  node_email_scheduler["Email scheduling<br/>[email_sender.py]"]
  node_reconciliation["Runtime reconciliation"]
end

subgraph group_campaign_runtime["Campaign runtime"]
  node_campaign_service["Campaign service<br/>[main.py]"]
  node_public_routes["Public campaign routes<br/>[public.py]"]
  node_tracking["Tracking and evidence<br/>[tracking.py]"]
  node_session_gate["Session admission"]
  node_websocket_manager["Live session channel"]
end

subgraph group_browser_sessions["Browser sessions"]
  node_browser_container["Browser container<br/>[selkies-core.js]"]
  node_session_modes["VNC and Selkies modes"]
end

subgraph group_operations["Deployment operations"]
  node_cli["CLI lifecycle tools<br/>[commands.py]"]
  node_docker_ops["Container operations<br/>[docker_ops.py]"]
end

node_operator(("Operator"))
node_victim(("Victim browser"))
node_router["Traefik routing"]
node_docker_proxy["Restricted Docker proxy"]

node_operator -->|"uses"| node_dashboard
node_dashboard -->|"calls"| node_admin_api
node_dashboard -->|"configures campaigns"| node_campaign_ui
node_campaign_ui -.->|"submits campaigns"| node_campaign_routes
node_dashboard -->|"manages resources"| node_resource_libraries
node_dashboard -->|"views sessions"| node_victim_console
node_admin_api -->|"routes requests"| node_auth
node_admin_api -->|"routes requests"| node_campaign_routes
node_campaign_routes -.->|"manages state"| node_campaign_models
node_admin_api -->|"persists state"| node_admin_store
node_admin_api -->|"schedules email"| node_email_scheduler
node_admin_api -->|"schedules reconciliation"| node_reconciliation
node_admin_api -->|"provisions workloads"| node_docker_proxy
node_docker_proxy -->|"starts campaigns"| node_campaign_service
node_docker_proxy -->|"starts sessions"| node_browser_container
node_router -->|"routes public traffic"| node_campaign_service
node_victim -->|"opens campaign"| node_router
node_campaign_service -->|"serves routes"| node_public_routes
node_public_routes -->|"admits sessions"| node_session_gate
node_campaign_service -->|"mounts tracking routes"| node_tracking
node_public_routes -->|"manages connections"| node_websocket_manager
node_websocket_manager -.->|"streams session state"| node_victim_console
node_campaign_service -->|"forwards campaign data"| node_admin_api
node_campaign_service -->|"connects assigned session"| node_browser_container
node_session_modes -->|"provides runtime mode"| node_browser_container
node_cli -->|"runs lifecycle operations"| node_docker_ops
node_cli -.->|"reads campaign state"| node_admin_store

click node_dashboard "https://github.com/p-bitm-framework/p-bitm/blob/main/server/frontend/src/App.vue"
click node_campaign_ui "https://github.com/p-bitm-framework/p-bitm/blob/main/server/frontend/src/composables/useCampaignWizard.js"
click node_resource_libraries "https://github.com/p-bitm-framework/p-bitm/tree/main/server/frontend/src/services/api/library"
click node_victim_console "https://github.com/p-bitm-framework/p-bitm/blob/main/server/frontend/src/views/DashboardVictim.vue"
click node_admin_api "https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/main.py"
click node_auth "https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/routes/auth.py"
click node_campaign_routes "https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/routes/campaigns.py"
click node_campaign_models "https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/models/campaign.py"
click node_admin_store "https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/database.py"
click node_email_scheduler "https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/services/email_sender.py"
click node_reconciliation "https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/services/runtime_reconciler.py"
click node_campaign_service "https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend-phishing/app/main.py"
click node_public_routes "https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend-phishing/app/routes/public.py"
click node_tracking "https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/routes/tracking.py"
click node_session_gate "https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend-phishing/app/core/session_admission.py"
click node_websocket_manager "https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend-phishing/app/core/websocket_manager.py"
click node_browser_container "https://github.com/p-bitm-framework/p-bitm/blob/main/bitm-images/selkies/selkies/selkies-core.js"
click node_session_modes "https://github.com/p-bitm-framework/p-bitm/tree/main/bitm-images/selkies"
click node_cli "https://github.com/p-bitm-framework/p-bitm/blob/main/cli/commands.py"
click node_docker_ops "https://github.com/p-bitm-framework/p-bitm/blob/main/cli/docker_ops.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_campaign_ui,node_resource_libraries,node_victim_console,node_victim toneBlue
class node_admin_api,node_auth,node_campaign_routes,node_campaign_models,node_admin_store,node_email_scheduler,node_reconciliation toneAmber
class node_campaign_service,node_public_routes,node_tracking,node_session_gate,node_websocket_manager toneMint
class node_browser_container,node_session_modes toneRose
class node_cli,node_docker_ops,node_operator,node_router,node_docker_proxy toneIndigo
```

## Components

### Operator dashboard

- [Admin dashboard](https://github.com/p-bitm-framework/p-bitm/blob/main/server/frontend/src/App.vue): `server/frontend/src/App.vue`
- [Campaign workflow](https://github.com/p-bitm-framework/p-bitm/blob/main/server/frontend/src/composables/useCampaignWizard.js): `server/frontend/src/composables/useCampaignWizard.js`
- [Resource libraries](https://github.com/p-bitm-framework/p-bitm/tree/main/server/frontend/src/services/api/library): `server/frontend/src/services/api/library`
- [Victim console](https://github.com/p-bitm-framework/p-bitm/blob/main/server/frontend/src/views/DashboardVictim.vue): `server/frontend/src/views/DashboardVictim.vue`

### Admin control plane

- [Admin API](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/main.py): `server/backend/main.py`
- [Admin authentication](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/routes/auth.py): `server/backend/routes/auth.py`
- [Campaign management](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/routes/campaigns.py): `server/backend/routes/campaigns.py`
- [Campaign and victim state](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/models/campaign.py): `server/backend/models/campaign.py`
- [Persistent state](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/database.py): `server/backend/database.py`
- [Email scheduling](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/services/email_sender.py): `server/backend/services/email_sender.py`
- [Runtime reconciliation](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/services/runtime_reconciler.py): `server/backend/services/runtime_reconciler.py`

### Campaign runtime

- [Campaign service](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend-phishing/app/main.py): `server/backend-phishing/app/main.py`
- [Public campaign routes](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend-phishing/app/routes/public.py): `server/backend-phishing/app/routes/public.py`
- [Tracking and evidence](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend/routes/tracking.py): `server/backend/routes/tracking.py`
- [Session admission](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend-phishing/app/core/session_admission.py): `server/backend-phishing/app/core/session_admission.py`
- [Live session channel](https://github.com/p-bitm-framework/p-bitm/blob/main/server/backend-phishing/app/core/websocket_manager.py): `server/backend-phishing/app/core/websocket_manager.py`

### Browser sessions

- [Browser container](https://github.com/p-bitm-framework/p-bitm/blob/main/bitm-images/selkies/selkies/selkies-core.js): `bitm-images/selkies/selkies/selkies-core.js`
- [VNC and Selkies modes](https://github.com/p-bitm-framework/p-bitm/tree/main/bitm-images/selkies): `bitm-images/selkies`

### Deployment operations

- [CLI lifecycle tools](https://github.com/p-bitm-framework/p-bitm/blob/main/cli/commands.py): `cli/commands.py`
- [Container operations](https://github.com/p-bitm-framework/p-bitm/blob/main/cli/docker_ops.py): `cli/docker_ops.py`

### Other components

- **Operator**
- **Victim browser**
- **Traefik routing**
- **Restricted Docker proxy**

## Connections

- Operator → Admin dashboard: uses (evidence: `README.md`)
- Admin dashboard → Admin API: calls (evidence: `README.md`)
- Admin dashboard → Campaign workflow: configures campaigns (evidence: `README.md`)
- Campaign workflow → Campaign management: submits campaigns
- Admin dashboard → Resource libraries: manages resources (evidence: `README.md`)
- Admin dashboard → Victim console: views sessions (evidence: `README.md`)
- Admin API → Admin authentication: routes requests (evidence: `server/backend/main.py`)
- Admin API → Campaign management: routes requests (evidence: `server/backend/main.py`)
- Campaign management → Campaign and victim state: manages state
- Admin API → Persistent state: persists state (evidence: `README.md`)
- Admin API → Email scheduling: schedules email (evidence: `server/backend/main.py`)
- Admin API → Runtime reconciliation: schedules reconciliation (evidence: `server/backend/main.py`)
- Admin API → Restricted Docker proxy: provisions workloads (evidence: `README.md`)
- Restricted Docker proxy → Campaign service: starts campaigns (evidence: `README.md`)
- Restricted Docker proxy → Browser container: starts sessions (evidence: `README.md`)
- Traefik routing → Campaign service: routes public traffic (evidence: `README.md`)
- Victim browser → Traefik routing: opens campaign (evidence: `README.md`)
- Campaign service → Public campaign routes: serves routes (evidence: `server/backend-phishing/app/main.py`)
- Public campaign routes → Session admission: admits sessions (evidence: `server/backend-phishing/app/routes/public.py`)
- Campaign service → Tracking and evidence: mounts tracking routes (evidence: `server/backend-phishing/app/main.py`)
- Public campaign routes → Live session channel: manages connections (evidence: `server/backend-phishing/app/routes/public.py`)
- Live session channel → Victim console: streams session state
- Campaign service → Admin API: forwards campaign data
- Campaign service → Browser container: connects assigned session (evidence: `README.md`)
- VNC and Selkies modes → Browser container: provides runtime mode (evidence: `README.md`)
- CLI lifecycle tools → Container operations: runs lifecycle operations (evidence: `cli/commands.py`)
- CLI lifecycle tools → Persistent state: reads campaign state
