Skip to main content

Architecture

Bloqd follows a client-server architecture with a central management server and distributed agents.

System Overview

┌─────────────────────────────────────────────────────────────────┐
│ BLOQD SERVER │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Express API │ │
│ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │
│ │ │ Auth │ │ Servers │ │ Bans │ │Templates│ │ │
│ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │ │
│ └──────────────────────────────────────────────────────────┘ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Services │ │
│ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │
│ │ │Scheduler│ │ Discord │ │AbuseIPDB│ │ SMTP │ │ │
│ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │ │
│ └──────────────────────────────────────────────────────────┘ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ SQLite DB │ │ WebSocket │ │ React │ │
│ │ │ │ Server │ │ Frontend │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────────┘

HTTPS / WebSocket

┌─────────────────────┼─────────────────────┐
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ SERVER 1 │ │ SERVER 2 │ │ SERVER N │
│ ┌───────────┐ │ │ ┌───────────┐ │ │ ┌───────────┐ │
│ │ Bloqd │ │ │ │ Bloqd │ │ │ │ Bloqd │ │
│ │ Agent │ │ │ │ Agent │ │ │ │ Agent │ │
│ └───────────┘ │ │ └───────────┘ │ │ └───────────┘ │
│ ┌───────────┐ │ │ ┌───────────┐ │ │ ┌───────────┐ │
│ │ fail2ban │ │ │ │ fail2ban │ │ │ │ fail2ban │ │
│ └───────────┘ │ │ └───────────┘ │ │ └───────────┘ │
└───────────────┘ └───────────────┘ └───────────────┘

Components

Bloqd Server

The central management server consists of:

ComponentDescription
Express APIRESTful API for all operations
WebSocket ServerReal-time updates to dashboard
SQLite DatabasePersistent storage for all data
React FrontendWeb-based dashboard
SchedulerBackground jobs (summaries, cleanup)

Bloqd Agent

A Python-based daemon running on each managed server:

ModuleDescription
SyncFetches whitelist from server
ReporterReports bans via Unix socket
MetricsCollects system metrics (CPU, RAM, disk)
HealthPerforms health checks
CommandsExecutes remote commands

fail2ban Integration

The agent integrates with fail2ban through:

  • Action Script - Reports bans to Bloqd
  • Whitelist File - Synced from central server
  • Jail Configurations - Deployed from templates

Data Flow

Ban Reporting Flow

fail2ban detects attack


Executes bloqd-report action


Writes to Unix socket (/var/run/bloqd-agent/report.sock)


Agent Reporter module reads from socket


POST /api/v1/report to Bloqd server


Server stores in database


WebSocket broadcast to dashboard


Discord notification (if enabled)

Whitelist Sync Flow

User adds IP to whitelist in dashboard


Stored in SQLite database


Agent polls /api/v1/whitelist/plain


Writes to /etc/fail2ban/bloqd-whitelist.txt


fail2ban-client reload

Command Execution Flow

User executes command in dashboard


Command stored in database with "pending" status


Agent polls /api/v1/servers/:id/commands


Agent acknowledges and executes command


Result sent back to server


WebSocket broadcast with result

Database Schema

Key tables in SQLite:

TablePurpose
serversRegistered managed servers
api_keysAuthentication tokens
whitelistIP/CIDR whitelist entries
ban_reportsBan history
templatesJail templates
agent_commandsPending/completed commands
usersUser accounts
rolesRBAC role definitions

Network Requirements

Server

DirectionPortProtocolPurpose
Inbound3000TCPHTTP API & Dashboard
Outbound443TCPDiscord, AbuseIPDB, SMTP

Agent

DirectionPortProtocolPurpose
Outbound443/3000TCPConnection to Bloqd server

Scalability

Single Server

  • Handles 50+ managed servers comfortably
  • SQLite handles millions of ban records
  • WebSocket connections limited by file descriptors

High Availability

For larger deployments:

  • Place Bloqd behind a load balancer
  • Use sticky sessions for WebSocket
  • Consider PostgreSQL for database (future feature)

Security Boundaries

┌─────────────────────────────────────────────┐
│ TRUST BOUNDARY │
│ ┌─────────────────────────────────────┐ │
│ │ Bloqd Server │ │
│ │ - API Key validation │ │
│ │ - JWT verification │ │
│ │ - Input sanitization │ │
│ │ - Rate limiting │ │
│ └─────────────────────────────────────┘ │
└─────────────────────────────────────────────┘

HTTPS

┌─────────────────────────────────────────────┐
│ MANAGED SERVERS │
│ - Agent runs as root (required for f2b) │
│ - Commands executed with restrictions │
│ - Whitelist only writes to specific file │
└─────────────────────────────────────────────┘

Technology Stack

Server

LayerTechnology
RuntimeNode.js 20+
FrameworkExpress 4.x
DatabaseSQLite (better-sqlite3)
AuthJWT + API Keys
Real-timeWebSocket (ws)
ValidationZod
LoggingPino

Frontend

LayerTechnology
FrameworkReact 18
BuildVite
StylingTailwind CSS
StateZustand
ChartsRecharts

Agent

LayerTechnology
RuntimePython 3.10+
HTTPrequests
ConfigYAML
Servicesystemd