s. shaboobalaLet’s talk
← All writing

Creating Auto DM (Anansi)

Jerry Gaines · From the Shaboobala archive

I began creating Auto DM(Anansi) when my normal D&D group had trouble meeting up. I came up with the idea since we didn’t want to continue our main campaign if everyone could not show up. I envisioned a tool that could first help dungeon masters spin up a scenario and create small campaigns. Then I realized why stop there? Being a DM is fun but NO ONE wants to be a forever DM. Why not make it so it offloads this responsibility to AI who can then be the narrator!

I started to imagine groups of players coming together jumping in and out of unique worlds. A design that allows for busy everyday people who would not be able to carve out hours to play to now be able to play at their own pace. A tool that can allow for flexibility to all types of players, min-maxers who would like to decimate, people looking for a journey of a century, those who want to make a name for themselves, and those who just want to goof around.

I fired up a chat window and began “Vibe coding” the prototype of the project only took me 2 days to complete I learned all the technologies what their purpose is and how to configure each application. I have been slowly refining it and believe it will soon be a marketable product.

TECH STACK MUMBO JUMBO:

Below is a comprehensive technical document detailing Auto Dungeon Master (DM) web application project, covering the gameplay experience, underlying mechanics, system architecture, technology stack, deployment considerations, and potential future enhancements.

D&D DM WEB APPLICATION TECHNICAL DOCUMENTATION

1. PROJECT OVERVIEW

This project is an interactive Dungeons & Dragons DM web application that leverages AI-driven dynamic narrative responses. Players set up a custom adventure scenario, create characters (with a separation between their login username and their in-game character name), and interact with the DM through chat. The DM, generates immersive story updates in real time that follow a style reminiscent of popular DMs, Persistent data is stored in AWS S3.

2. GAMEPLAY AND MECHANICS

2.1. USER FLOW & GAME PLAY

  1. Login Screen:
    • URL: /projects/auto-dm/
    • Inputs: Username and world code.
    • Logic:
      • The system verifies whether the world (scenario) exists.
      • If the world is new, the user is directed to the Scenario Setup page.
      • If the world exists, the system checks for the existence of the character corresponding to the logged‑in username.
      • Depending on the result, the user is redirected either to character creation or to the Chat screen.
  2. Scenario Setup:
    • URL: /projects/auto-dm/
    • Purpose: For a new world, the user defines the adventure scenario.
    • Inputs:
      • Setting (e.g., "Ancient Ruins in a Forgotten Jungle")
      • Theme (e.g., "Mystery and Exploration with hints of dark magic")
      • Challenge level (e.g., "Moderate", "High")
    • Outcome:
      • The scenario is stored persistently (in S3) and an initial story file is created.
      • Once saved, the user is then redirected to the Character Creation screen.
  3. Character Creation:
    • URL: /projects/auto-dm/
    • Purpose: To create a new character for an existing world.
    • Inputs:
      • Character Name (in-game name; separate from the login username)
      • Race
      • Class
      • Level
      • Additional details (stats, abilities, background)
    • Ability Scores:
      • The form provides a section for the six abilities (STR, DEX, CON, INT, WIS, CHA) arranged in two rows of three small, read-only input fields.
      • Two dice-rolling mechanisms are available:
        • Roll Stats: Rolls 4d6 dropping the lowest for all abilities at once.
        • Roll for a Single Ability: Lets the user choose one ability and roll 4d6, displaying the individual dice results and the dropped die for transparency.
    • Persistence:
      • Character data is stored in a JSON file on S3
    • DM Greeting:
      • If the world already exists, a DM greeting message is automatically appended to the story log, welcoming the new character and providing narrative context.
  4. Chat Room:
    • URL: /projects/auto-dm/
    • Purpose: The interactive chat interface where players and the DM interact.
    • Features:
      • Chat History:
        • Loads previously saved messages (player messages, DM responses, dice rolls) in chronological order.
        • Each message contains a timestamp.
        • Users can scroll through the conversation without auto-scrolling if they are viewing older messages.
      • Message Submission:
        • Players type messages which are persisted to S3 via the backend.
        • A toggle option allows players to direct messages to the DM (indicated by an asterisk next to their name) which then trigger a AI-generated narrative from the DM.
      • Dice Roller:
        • A built-in dice roller allows users to roll dice for game actions (e.g., d4, d8, d10, d12, d20, d100).
        • The results of the dice roll (including individual dice values, the total, etc.) are appended as chat messages and persisted.

3. SYSTEM ARCHITECTURE

3.1. COMPONENTS

3.2. DATA FLOW OVERVIEW

  1. User Interaction:
    • Users interact with the front end hosted on Squarespace.
    • The application uses localStorage to retain session context.
  2. API Communication:
    • The frontend communicates with API endpoints deployed on AWS Lambda (public API Gateway URL).
    • These endpoints handle creation, updating, and retrieval of game data.
  3. S3 for Data Persistence:
    • All game-related data is stored as text or JSON files in S3.
    • Periodic polling on the front end reads the chat file from S3 and updates the chat area.
  4. DM Integration via LLM API:
    • When messages are directed to DM (via the DM toggle), the backend calls API.
    • The DM endpoint uses the API prompt with the current story context and character data.
    • The generated narrative is then appended to logs in S3.

4. TECHNOLOGY STACK

5. API ENDPOINTS

5.1. SCENARIO AND WORLD MANAGEMENT

5.2. CHARACTER MANAGEMENT

5.3. CHAT AND DM INTERACTION

6. FRONTEND PAGES

6.1. LOGIN (LOGIN.HTML)

6.2. SCENARIO SETUP (SCENARIO.HTML)

6.3. CHARACTER CREATION (CHARACTER.HTML)

6.4. CHAT (CHAT.HTML)

7. DEPLOYMENT AND FUTURE ENHANCEMENTS

7.1. DEPLOYMENT

7.2. FUTURE ENHANCEMENTS

CONCLUSION

This document outlines the project’s functionality, architecture, and the technical choices made in building an auto DM web application for D&D. The application integrates a AI-driven DM with dynamic scenario creation, character creation (with dice-rolling mechanics), and a chat interface that uses AWS Lambda, API Gateway, and S3 for persistence. With planned future enhancements, this project can scale to provide a rich interactive D&D experience for players around the globe.