A unified behavioural logging system that collects and analyzes user interactions (both human and bot) to detect automated traffic. Built for the HackByte 4.0 hackathon.
- Unified event schema for both human (
frontend/logger.js) and bot (bot/bot_script.py). - Backend endpoint
POST /api/logsthat saves one JSON file per session inlogs/. - Session file naming convention:
human_YYYYMMDD_HHMMSS_uniqueID.jsonagent_YYYYMMDD_HHMMSS_uniqueID.json
- Feature extraction pipeline:
extract_features.pywrites a CSV table for ML training.
This workspace collects comparable behavioural data for human and agent sessions.
cd backend
python main.pyBackend runs on http://localhost:8001 and serves frontend at http://localhost:8001/demo/index.html.
Open in browser:
http://localhost:8001/demo/index.html
Interact naturally across pages; logger sends full session snapshots every 30 seconds and on page unload.
cd bot
python bot_script.pyThe bot writes a local session file to logs/ and also POSTs to /api/logs.
http://localhost:8001/sessions?session_type=humanhttp://localhost:8001/sessions?session_type=agenthttp://localhost:8001/session/<session_id>
From project root:
python extract_features.py --logs-dir logs --output features.csv{
"session_id": "human_20260404_153022_42ab9c",
"session_type": "human",
"start_time_ms": 0,
"end_time_ms": 123456,
"user_agent": "Mozilla/5.0 ...",
"viewport": { "width": 1280, "height": 800 },
"events": [
{
"event_id": 1,
"timestamp_ms": 0,
"type": "navigation",
"data": { "url": "...", "referrer": "" }
}
]
}Built for HackByte 4.0. Uses Playwright for browser automation and scikit‑learn for behavioural classification.