Single-player, story-driven DnD campaigns with a Gemini-powered Dungeon Master, Supabase storage, and a fully editable admin console.
- Campaign creation wizard with races, classes, stats, backstory, and starting gear.
- AI Dungeon Master via Supabase Edge Functions (Gemini API).
- Campaign UI with quests, rumors, bounties, NPCs, inventory, journal, spellbook, and dice tools.
- Leaderboard on the home page.
- Admin console to edit campaigns and game data (classes, races, abilities, loot tables).
- Optional background music from Supabase Storage.
- Vite + React
- Tailwind CSS
- Supabase (Postgres, Auth, Storage, Edge Functions)
- Gemini API
- Install dependencies
npm install
- Create Supabase tables and policies
- Create a Supabase project.
- Run
supabase.sqlin the Supabase SQL editor. - This creates
campaigns,admin_emails, andgame_dataplus RLS policies.
-
Connect Google AI Studio
-
Configure environment
cp .env.example .env
Fill:
VITE_SUPABASE_URLVITE_SUPABASE_ANON_KEY
(local Edge Functions or custom tooling):
SUPABASE_URLSERVICE_ROLE_KEYGEMINI_API_KEYGEMINI_MODEL(defaults togemini-2.0-flash)
- Start dev server
npm run dev
supabase.sqlcurrently allows public read/write oncampaignsand public read ongame_data.- The
dm-chatEdge Function runs withverify_jwt = falseby default. - Lock these down before production if you need authenticated or private data access.
/Home. Enter a campaign UID to continue or create a new campaign./createCharacter creation wizard./campaign/:idCampaign view (acceptsaccess_keyUID or UUID)./adminAdmin console (Supabase Auth + allow list).
- Add your email to the allow list:
insert into public.admin_emails (email) values ('you@example.com');
- Enable email auth in Supabase.
- Sign in at
/adminusing password or magic link.
The admin console can:
- Edit campaign data directly.
- Override
classes,races,abilities,skills_by_ability, andloot_configvia thegame_datatable. - When no rows exist in
game_data, the app falls back tosrc/data/*.
- Deploy the edge function in
supabase/functions/dm-chat:
supabase functions deploy dm-chat --no-verify-jwt
- Deploy through CLI if there is any changes towards the dm chat by doing below in supabase CLI
supabase functions deploy dm-chat --no-verify-jwt
- Set these function secrets in Supabase:
- GEMINI_API_KEY (from Google AI Studio)
- SERVICE_ROLE_KEY (service_role key from Supabase)
- Optional: GEMINI_MODEL (defaults to gemini-2.0-flash)
Notes:
- Supabase injects
SUPABASE_URLautomatically inside Edge Functions. dm-chatis configured withverify_jwt = falseto allow UID-only access. Adjust if you want authenticated access only.
- Create a public bucket named
dnd-bucket. - Upload audio files under
music/(e.g.music/TavernMusic.mp3). - The campaign page auto-loads tracks from that folder and falls back to
music/TavernMusic.mp3.
npm run devRun Vite dev servernpm run buildProduction buildnpm run previewPreview build locally
| Rarity | Weight | Probability |
|---|---|---|
| Common | 500 | 50% |
| Uncommon | 300 | 30% |
| Rare | 140 | 14% |
| Epic | 50 | 5% |
| Legendary | 9 | 0.9% |
| Unique (Backstory) | 0 | 0% |
| Divine / Hellforged | 1 | 0.1% |
| Rarity | Weapon Bonus (Damage increase) | Damage Die Scaling | Armor Class (AC) |
|---|---|---|---|
| Common | +0 | Base Die | Base AC |
| Uncommon | +1 | Base Die | Base AC |
| Rare | +1 | +1d4 | +1 AC |
| Epic | +2 | +1d8 | +2 AC |
| Legendary | +3 | Double Base Die | +3 AC |
| Divine / Hell | +3 | Double Die + 2d10 | +4 AC |
| Rarity | HP Recovery | XP Granted | Skill XP (Training) | Duration |
|---|---|---|---|---|
| Common | 2d4 + 2 | — | — | Instant |
| Uncommon | 4d4 + 4 | — | — | Instant |
| Rare | 8d4 + 8 | — | +1 Skill Point | Instant |
| Epic | 10d4 + 20 | 2 XP | +2 Skill Points | Instant |
| Legendary | Full Heal | 5 XP | +5 Skill Points | Instant |
| Divine/Hell | Full + 25 Temp | 10 XP | Instant Mastery | Instant |
| Rarity | Ability Check Buff | Skill Performance | Duration |
|---|---|---|---|
| Uncommon | +1d4 to checks | — | 1 Turns |
| Rare | +1d6 to checks | Advantage on Skill | 1 Turns |
| Epic | +1d8 to checks | Advantage + 1d4 | 2 Turns |
| Legendary | +1d10 to checks | Advantage + 1d8 | 4 Turns |
| Divine/Hell | +1d12 to checks | Auto-Success (1/turn) | Until DM said so |