About This Project

What is MYRN?

MYRN is a self-hosted home lab built to support an ongoing Pathfinder 2e tabletop campaign. What started as a way to run Foundry VTT for a group of friends became an exercise in building a full production-grade system from scratch, on consumer hardware, with no cloud spend beyond a single domain name.

Everything on this site, the dice statistics, the campaign pages, the Discord authentication, runs on a repurposed laptop sitting on a shelf, managed entirely via SSH.

By the Numbers

5,764 Player dice rolls tracked
10.55 Average roll
617.5 Player Hours Logged
36 Campaign journal entries
25 Discord slash commands
5 Services running 24/7
$0 Monthly cloud cost
Days Uptime

Technical Stack

Python / Flask SQLite discord.py Discord OAuth2 Chart.js Ubuntu Server systemd Cloudflare Tunnel Foundry VTT LevelDB / plyvel Cloudflare Workers AI Llama 3.3 70B Ollama (fallback) FTS5 HTML / CSS / JS PowerShell SSH / SCP UFW cron aiohttp requests

How It Was Built

System architecture

myrn.netLanding · Journal · Dice stats
vtt.myrn.netFoundry VTT
DiscordBot commands · OAuth2
↕ Cloudflare Tunnel
Experience
Worm nav
JournalEntries · audio
Dice stats
Application
Flask · OAuth2
pf2e-bot
Dice ingest
MYRN RAG · CF AI
Data
dice.db
pf2e_bot.db
Foundry LevelDB
nethys.db
myrn_training.db
Infrastructure
Ubuntu Server
systemd
Cloudflare Tunnel
UFW · SCP

Build order

01
Foundry VTT on bare metalInfrastructure

Repurposed laptop running Ubuntu Server. Foundry installed and configured for a Pathfinder 2e campaign on bare metal.

Requires: nothing — start here
02
Public access via Cloudflare TunnelInfrastructure

Named tunnel routes myrn.net and vtt.myrn.net to local services. No static IP, port forwarding, or firewall exposure.

Requires: 01
03
Discord botApplication

pf2e-bot built with discord.py. Its 25 slash commands cover roll tracking, character management, session logging, and campaign utilities.

Requires: 01
04
Flask + Discord OAuth2Application

Replaced http.server with Flask, dynamic routing, Jinja2 templates, and a shared design system. Discord guild membership maps directly to the active character.

Requires: 02, 03
05
Dice data pipelineData

Nightly extraction reads Foundry's LevelDB store through a safe snapshot-and-parse flow. Rolls are normalised into SQLite idempotently.

Requires: 01, 03
06
Backup systemInfrastructure

PowerShell scripts pull six server components over SCP to a local drive. Wired gigabit networking improved transfer speed 2,600x over WiFi.

Requires: 01
07
Eldritch worm navigationExperience

Three independently timed fixed CSS layers create the worm descent animation. The paginated button grid supports campaign routing, Discord auth gating, and mobile layouts.

Requires: 04
08
Campaign journal systemExperience

Player-authored entries are tied to Discord identity. The journal includes localStorage unread tracking, unique-IP view counts, author-scoped editing, generated narration, a persistent audio player, and Discord history ingestion.

Requires: 04, 05
09
MYRN Knowledge EngineApplication

Self-hosted RAG powers the MYRN chest chatbox. It pulls 43,415 PF2e rules entries from Archives of Nethys into a local SQLite FTS5 database, refreshed monthly.

Each query runs through local retrieval and ranking before Cloudflare Workers AI inference, with local Ollama retained as fallback.

Requires: 04
10
MYRN IntelligenceApplication

Inference moved from local CPU (Llama 3.1 8B via Ollama, 35–74s cold start) to Cloudflare Workers AI with Llama 3.3 70B as primary. First token is under 2.5 seconds on the free tier, with daily neuron usage well within the 10,000 neuron cap; the agentic query rewriter normalises questions before multi-term retrieval.

Requires: 09
11
Security HardeningInfrastructure

A full-stack audit found SQLite connection leaks exhausting the OS file descriptor limit and resolved all 19 connection sites. Additional fixes hardened sessions, media uploads, origin gating, and the AI endpoint concurrency cap.

Requires: 04, 09
12
MYRN Training PipelineApplication

Every distinct query submitted to MYRN is captured in a training database. A seed set of 50 hand-verified question/answer pairs covering rules, conditions, spells, items, and build advice serves as the evaluation baseline. A key-fact comparison harness tests live model responses against the seed set, identifying retrieval gaps and model errors. Findings feed directly back into retrieval tuning — improving spell/condition disambiguation, class feature matching, and multi-word entry detection.

Requires: 09, 10

Built and maintained by Alexander Bates Turriff.