D&D toolkit.
A web companion for tabletop D&D 5e Dungeon Masters and players. It holds a reference library, create and edit tools for spells, feats and rules, campaign tools, interactive maps, a fantasy calendar, a challenge rating calculator and an AI import of book pages.
- Year
- 2024
- Personal project
- My part
- Sole developer
- Website
- tes-mundus.vercel.app
My role
I built the whole product alone and am still developing it, including a rewrite as a second chapter.
Capabilities
Reference library
- Spells, creatures, items, feats, rules, backgrounds, races, classes and sources, each with filters, detail pages and bookmarks
- Create and edit dialogs for spells, feats and rules, with a text-to-fields converter
- Text and AI converters that turn pasted text or photos of book pages into structured entries
DM tools
- Challenge rating calculator with 34 traits and a shareable link
- Interactive maps with tiling for large images, markers, regions and distance measuring
- Fantasy calendar with moons, events, eras and seeded weather
- VTT token editor with borders, masks and batch export
- Weather, economy and alchemy calculators, name generators, dice roller and random tables
Patterns and decisions
- I built the whole product alone. The first version is a single Next.js app that is both front and back end, with 80+ pages, 250+ oRPC procedures and 20 kinds of shareable content, on PostgreSQL with Prisma. The second chapter is a rewrite on Drizzle and Base UI, with a stricter layout and a smaller, deeper slice of the product.
- Every feature is a folder with its own procedures, components and logic. Each procedure validates its input and output with Zod, and shared concerns such as authentication, rate limits, per-role creation limits and signed webhooks sit in middleware.
- Accounts use Better Auth with passwordless sign-in, two-factor and Google. Roles are Player, Master and Admin, and each role has its own creation quotas per content type.
- Pure logic stays out of the framework. The rating engine, the calendar maths and the economy formulas are plain typed functions, and 190+ test files cover them.
- Photos of book pages go through a Gemini model with a typed output schema and fallback models. The result is shown for review before anything is saved.
Cases
A challenge rating calculator as plain functions. A monster's rating averages an offensive and a defensive rating from reference tables, then adjusts for dozens of special traits. I wrote the method as a pure function with no framework and no database. Each of the 34 traits is a small typed function that returns a change to hit points, armor class, damage per round or attack bonus. The engine takes a validated input and returns the final rating, both halves, experience and hit dice. The judgement calls are written down and pinned by tests: resistances count only from three damage types, one-shot traits are divided by three because damage per round is a three-round average, and when a creature has both an attack roll and a save the harder one decides. All state lives in the address, so every build is a link.
Maps of any size. A campaign map can be a 100 MB image. Serving it whole is unusable, tiling it inside a serverless function times out, and a failed run must not leave half-built maps behind. The browser uploads straight to object storage. A medium image is converted to WebP in the app. A large one starts a Python job on Google Cloud Run Jobs, or a local container in development, which downloads the source, builds a tile pyramid and checks that the map still exists before uploading. The job then calls the app back with a signed request and retries with growing delays. The map moves through uploading, processing, ready and failed, and a failed map can be retried. The callback emails the uploader. A nightly job removes files of deleted maps and uploads stuck for a day.
One sharing system for twenty kinds of content. Every kind of content needs private or public, a share link, named members with view or edit roles, and email invites for people without an account. Writing that twenty times would drift. I built one polymorphic access table and one invite table keyed by content type, plus a registry that builds the per-type setup with a small factory. Permission rules are generated from database conditions that are type-checked against the schema, so renaming a column breaks the build instead of silently breaking a rule. A shared map brings its markers and regions with it. In the rewrite I rebuilt the same idea as a single SQL predicate that every list query embeds, so access costs no extra queries.
A calendar that follows an existing format. Fantasy worlds need odd week lengths, layered leap rules, several moons and events such as the third Friday of every second month, and users already hold such calendars in a common file format. I kept the format and built the rules to follow it. Year length and date conversion are pure functions. Events are condition trees evaluated right to left with no operator precedence, including NAND, XOR and at-least-N groups. Moons and weather come from a seed and the day number, so a date always gives the same weather. 24 test files cover the rules.