AI RPG Map Generator

Inspiration

As a long-time tabletop RPG player , I’ve always dreamed of a tool that could help both new and veteran Game Masters generate immersive visual assets (maps & tokens) on the fly.

Many GMs don’t have access to illustrators or expensive assets.

I wanted to democratize RPG content creation through AI. This project is the result of years of TTRPG experience and weeks of intensive development and experimentation.

What it does

This web application allows users to:

  • Generate AI-powered fantasy/Sci-fi maps based on terrain name and description.
  • Generate 5 unique RPG tokens (Roll20-compatible) for encounters defined in a given terrain (stored in MongoDB).

  • Enhance the output using Nova via Amazon Bedrock, applying style consistency (circular format, transparent background, terrain-specific border).

  • Store the result securely on AWS S3 and share or download via signed URLs.

All image generation is 100% automated and uses Bedrock models with creative prompting and post-processing (Pillow, image compositing).

Ravenloft Map

How we built it

Backend

  • FastAPI serves as the main API.
  • Flask serves the frontend (form + result rendering).
  • MongoDB Atlas stores terrain templates (description, encounter types).
  • AWS Bedrock (Stability AI + Titan) powers the image generation via Nova (customized prompts).
  • Pillow (PIL) processes the images (cropping, padding, borders).
  • S3 stores generated assets with presigned URLs.

Infrastructure

  • NGINX reverse proxy for production.
  • Deployed on an EC2 instance with SSL (Let’s Encrypt).
  • CI/CD with GitHub Actions for backend services.

Key Features

This app delivers two core AI-powered capabilities for tabletop role-playing game creators:

AI Map Generation

Game Masters start with a terrain name and an atmospheric description. That’s all it takes.

Behind the scenes, the backend builds a prompt for a full overhead map, fitting for worldbuilding or VTT play. The app calls Amazon Bedrock (Stability AI via Nova) to produce high-resolution, fantasy- or sci-fi-style images.

Once generated:

• The map is styled with fantasy textures (forests, deserts, etc.).
• It’s stored in AWS S3 with a signed URL for secure download.
• No manual editing is required — the user receives a ready-to-use, immersive map in seconds.

Highlights:

• Terrain & description transformed into coherent maps via AI
• Generated in high-res, suitable for grid overlays
• Hosted on AWS S3 and served via signed URLs
• Preview carousel on frontend (Flask/HTML + lightbox)
prompt = f"A fantasy world map of terrain '{terrain_name}' with '{description}'. Highly detailed, top-down view..."

images = generate_map_with_nova_canvas(prompt)
upload_to_s3(images[0], f"maps/{terrain_name}/map.png")

AI Token Generation

Once the terrain is selected, the app queries MongoDB for its encounter types (e.g., monsters, spirits, cyber-creatures). It picks 5 at random, then:

• Crafts a prompt per encounter, incorporating the terrain theme and user description
• Sends the prompts to Bedrock/Nova for image generation
• Post-processes each image:
• Ensures transparent background
• Centers subject and resizes to 512x512
• Applies circular crop and colored border (based on terrain type)
• Stores tokens in S3, generates secure presigned URLs
• Renders them on the frontend in a fantasy-styled token gallery with download buttons

Highlights:

• 5 auto-selected encounters per terrain
• Prompt engineering for detailed, RPG-compatible token generation
• Circular format + biome-colored border
• Hosted securely via AWS S3
• Roll20-compatible assets
# Build prompt
prompt = (
    f"Theme: A high-resolution fantasy RPG token of a {encounter} from terrain '{terrain_name}' "
    f"with '{description}'. ({terrain_type} biome)..."
)

# Generate image and process
image = generate_token_with_nova_canvas(prompt)[0]
token = format_token_for_roll20(image)
token = apply_circular_border(token, get_token_border_color(terrain_type))

# Upload & return
upload_to_s3(token, s3_path)
token_urls.append({"encounter": encounter, "url": generate_presigned_url(...)})

But the long-term goal is to make this experience more accessible, especially for users who aren’t familiar with writing creative prompts for image generation.

Steampunk Pilot Token

Planescape - Ethereal Watchers Token

Why These Two Features Matter

Many GMs lack visual assets or time to prepare them. This tool solves that:

• Maps help set the stage — deserts, ruins, alien colonies, or dreamworlds.
• Tokens bring characters to life — animated undead, sci-fi rebels, swamp horrors.

Together, these features form a full AI-driven asset creation pipeline for immersive gameplay.

Frontend UX:

  • Fully responsive HTML/CSS UI.
  • Styled with parchment/fantasy theme.
  • Display tokens in horizontal rows with animations and download buttons.

Challenges I ran into

  • Prompt engineering for AI token generation:
    One of the biggest challenges was crafting prompts that yield both visually consistent and creative tokens. For example, I needed the resulting images to:

    • Be usable as RPG tokens (transparent background, centered subject)
    • Match the terrain theme (Swamp, Ravenloft, Cthulhu, etc.)
    • Incorporate user descriptions for added depth (e.g., “ancient demon cloaked in storm”)

But giving too little or too much information could lead to distorted results. I iterated over dozens of prompt templates until i found a robust structure.

  prompt = (
      f"Theme: A high-resolution fantasy RPG token of a {encounter} "
      f"from the terrain '{terrain_name}' with '{description}'. "
      f"({terrain_type} biome). "
      "The token should feature the main creature or element described, centered in the frame. "
      "PNG format, no background scenery, clean transparent background, sharp outlines. "
      "Sized for Roll20 use, circular if possible, and visually striking."
  )
  • Guiding users to write better prompts:

I realized that non-technical users struggled with describing tokens effectively. I plan to implement future UI/UX improvements to help guide their input through examples, tooltips, or even AI-assisted prompt rewriting.

For now, the frontend accepts a free-text description:

  <textarea id="description" name="description"
            placeholder="e.g., Fiery demon with lava eyes and scorched skin..."></textarea>

Cyberpunk Mystic Token

  • Image post-processing: making tokens transparent, centered, and clean for Roll20 with borders.
  • CORS / NGINX issues between Flask (port 5002) and FastAPI (port 8001).
  • Payload handling for long user descriptions and API input validation.
  • MongoDB structure evolution: migrating terrain templates with dynamic encounters and biome types.

Accomplishments that I'm proud of

  • Successfully leveraged Amazon Bedrock to generate consistent, high-quality RPG tokens tailored for tabletop platforms like Roll20.
  • Built a fully functional application within a tight deadline, including frontend, backend, image processing pipeline, and deployment.
  • Implemented a precise image formatting system: transparent background, centered subject, circular mask, and colored borders based on terrain type.
  • Developed a modular terrain and encounter system using MongoDB, allowing dynamic generation of varied RPG scenarios.
  • Deployed the full stack in a production-ready environment using NGINX, Certbot SSL, S3 for asset storage, and Redis for queuing.
  • Achieved fast and reliable token generation: from user prompt to downloadable assets in under 15 seconds.
  • Designed the UI/UX to be accessible and immersive, even for non-technical users, with a fantasy-themed interface.
  • Ensured secure, time-limited downloads through AWS S3 presigned URLs to prevent abuse or unauthorized access. Swamp Map

What I learned

  • How to fine-tune prompts for image generation in Amazon Bedrock.
  • How to optimize token visual quality using Pillow and transparent backgrounds.
  • How to handle asynchronous job queuing for generation latency.
  • Working with Flask + FastAPI in tandem to separate UI and API responsibilities.
  • Deepened understanding of AWS Bedrock orchestration, presigned S3 workflows, and deployment via reverse proxies.

What's next for AI RPG Map Generator

  • Add audio / ambient SFX generation per terrain using Bedrock + ElevenLabs API.
Share this project:

Updates