An AI-powered interactive text adventure game with dynamic story generation using local LLM models.
FastAPIAdventureInAI/ # repo root
โโโ .env.example
โโโ README.md
โโโ requirements.txt
โโโ SETUP.md
โโโ SETUP_database.py
โโโ FastAPIAdventureInAI.sln
โโโ FastAPIAdventureInAI.pyproj
โโโ quick_setup.bat
โโโ quick_setup.sh
โโโ tools/ # utility scripts
โ โโโ run_extractor.py
โ โโโ scan_site_dumps.py
โ โโโ scan_site_dumps_fixed.py
โ โโโ generate_dom_json.py
โ โโโ analyze_hosts.py
โโโ ai_main.py # helper entry that runs the AI server (runs `ai_server:app`)
โโโ FastAPIAdventureInAI/ # backend package
โโโ __init__.py
โโโ aiadventureinpythonconstants.py
โโโ config.py
โโโ data_server.py # FastAPI app wiring (includes routers)
โโโ main.py # helper entry that runs the backend (runs `data_server:app`)
โโโ ai_server.py # standalone AI inference server (optional separate process)
โโโ seed_data.py
โโโ setup_database.py
โโโ api/
โ โโโ __init__.py
โ โโโ ai_client_requests.py
โ โโโ routers/
โ โ โโโ __init__.py
โ โ โโโ auth_router.py
โ โ โโโ users_router.py
โ โ โโโ worlds_router.py
โ โ โโโ game_ratings_router.py
โ โ โโโ history_router.py
โ โ โโโ saved_games_router.py
โ โ โโโ tokenized_history_router.py
โ โ โโโ deep_memory_router.py
โ โโโ services/
โ โโโ __init__.py
โ โโโ data_api_auth_service.py
โ โโโ users_service.py
โ โโโ worlds_service.py
โ โโโ history_service.py
โ โโโ tokenized_history_service.py
โ โโโ deep_memory_service.py
โ โโโ saved_games_service.py
โโโ ai/
โ โโโ __init__.py
โ โโโ schemas_ai_server.py
โ โโโ routers/
โ โ โโโ __init__.py
โ โ โโโ root_router.py
โ โ โโโ tokens_router.py
โ โ โโโ lore_router.py
โ โโโ services/
โ โ โโโ __init__.py
โ โ โโโ ai_api_service.py
โ โ โโโ ai_modeler_service.py
โ โ โโโ lookup_ai_service.py
โ โ โโโ http_service.py
โ โ โโโ ddgs_service.py
โ โ โโโ extractors/
โ โ โโโ __init__.py
โ โ โโโ common.py
โ โ โโโ generic_extractor.py
โ โโโ lookup_ai/
โ โโโ __init__.py
โ โโโ fetch_sources.py
โ โโโ section_selector.py
โ โโโ query_terms.py
โ โโโ services/
โ โโโ __init__.py
โ โโโ wikipedia_service.py
โ โโโ fandom_service.py
โ โโโ lol_wiki_service.py
โ โโโ leagueoflegends_service.py
โ โโโ product_page_service.py
โ โโโ fanlore_service.py
โ โโโ gluwee_service.py
โ โโโ halloweencostumes_service.py
โ โโโ costumerealm_service.py
โ โโโ animecharacters_service.py
โโโ business/
โ โโโ __init__.py
โ โโโ converters/
โ โ โโโ __init__.py
โ โ โโโ converters.py
โ โโโ dtos/
โ โ โโโ __init__.py
โ โ โโโ dtos.py
โ โโโ models/
โ โ โโโ __init__.py
โ โ โโโ models.py
โ โโโ schemas/
โ โโโ __init__.py
โ โโโ schemas_api.py
โโโ shared/
โ โโโ __init__.py
โ โโโ helpers/
โ โ โโโ __init__.py
โ โ โโโ ai_settings.py
โ โ โโโ memory_helper.py
โ โโโ services/
โ โโโ __init__.py
โ โโโ auth_service.py
โ โโโ orm_service.py
โโโ tools/
โโโ (project-specific helpers and scripts)
adventure-client/ # React frontend
โโโ package.json
โโโ package-lock.json
โโโ public/
โ โโโ index.html
โ โโโ manifest.json
โ โโโ robots.txt
โโโ src/
โโโ index.js
โโโ index.css
โโโ App.js
โโโ App.css
โโโ Login.js
โโโ NewGame.js
โโโ CreateWorld.js
โโโ Game.js
โโโ LoadGame.js
โโโ ManageWorlds.js
โโโ ManageWorlds.js
โโโ config.js
โโโ tests/
โโโ (react tests)
###1. Clone the Repository
git clone https://github.com/VersacheX/FastAPIAdventureInAI.git
cd FastAPIAdventureInAI
###2. Backend Setup
cd FastAPIAdventureInAI
python -m venv env
Windows (PowerShell):
.\\env\\Scripts\\Activate.ps1
Windows (CMD):
.\\env\\Scripts\\activate.bat
Linux/Mac:
source env/bin/activate
pip install -r requirements.txt
If you have CUDA/PyTorch compatibility issues, install PyTorch separately using the instructions from the PyTorch website for your CUDA version.
Edit FastAPIAdventureInAI/config.py to set your database connection (default is SQLite):
DATABASE_URL = "sqlite:///./adventure.db"
python -c "from dependencies import engine; from business.models import Base; Base.metadata.create_all(bind=engine)"
python seed_data.py
This will create default game ratings, pre-built worlds, AI directive settings, account levels, and an admin user.
The project uses a local GPTQ-compatible model. The active model constant is defined in FastAPIAdventureInAI/ai/services/ai_modeler_service.py as AI_MODEL.
Recommended model: TheBloke/MythoMax-L2-13B-GPTQ (or another compatible GPTQ model). Update AI_MODEL in ai/services/ai_modeler_service.py if you place the model locally or want to switch models.
You typically run two processes (three if you run the frontend locally):
You can start the AI server either by running ai_server.py directly or using ai_main.py which launches the same app with Uvicorn.
Run the standalone AI server which loads the local model and serves inference on port9000:
cd FastAPIAdventureInAI
.\\env\\Scripts\\Activate.ps1 # or activate your venv
python ai_main.py
This starts the AI model server on http://localhost:9000.
Note:
ai_server.pyand the model loader inai/services/ai_modeler_service.pyare responsible for loading the local GPTQ model. If you prefer the backend to directly load the model into FastAPI app state, the code already supports loading the model intoapp.state.
Start the backend API (uses data_server.py via main.py):
cd FastAPIAdventureInAI
.\\env\\Scripts\\Activate.ps1
python main.py
This starts the API server (default host 0.0.0.0) on port8080 by default.
Alternatively you can run:
python data_server.py
cd adventure-client
npm install
npm start
This starts the frontend development server on http://localhost:3000.
http://localhost:3000FastAPIAdventureInAI/config.py)SECRET_KEY = "your-secret-key-here" # Change in production!
DATABASE_URL = "sqlite:///./adventure.db"
AI_SERVER_URL = "http://127.0.0.1:9000"
CORS_ORIGINS = ["http://localhost:3000"]
Token budgets and memory limits can be adjusted in the AI helpers and settings files under ai/ and shared/helpers/.
The application uses a three-tier memory compression system:
This keeps prompts within model context windows while preserving key story information.
api/routers/ or ai/routers/ for AI-specific endpointsdata_server.py (or main wiring)When changing models:
business/models/main.py or ai_server.pyOnce running backend, visit:
http://localhost:8080/docshttp://localhost:8080/redocSECRET_KEY and default passwords before productionAdd your license here.
22 commits
Python
73.5%
JavaScript
18.6%
CSS
6.6%
An AI-powered interactive text adventure game with dynamic story generation using local LLM models.
FastAPIAdventureInAI/ # repo root
โโโ .env.example
โโโ README.md
โโโ requirements.txt
โโโ SETUP.md
โโโ SETUP_database.py
โโโ FastAPIAdventureInAI.sln
โโโ FastAPIAdventureInAI.pyproj
โโโ quick_setup.bat
โโโ quick_setup.sh
โโโ tools/ # utility scripts
โ โโโ run_extractor.py
โ โโโ scan_site_dumps.py
โ โโโ scan_site_dumps_fixed.py
โ โโโ generate_dom_json.py
โ โโโ analyze_hosts.py
โโโ ai_main.py # helper entry that runs the AI server (runs `ai_server:app`)
โโโ FastAPIAdventureInAI/ # backend package
โโโ __init__.py
โโโ aiadventureinpythonconstants.py
โโโ config.py
โโโ data_server.py # FastAPI app wiring (includes routers)
โโโ main.py # helper entry that runs the backend (runs `data_server:app`)
โโโ ai_server.py # standalone AI inference server (optional separate process)
โโโ seed_data.py
โโโ setup_database.py
โโโ api/
โ โโโ __init__.py
โ โโโ ai_client_requests.py
โ โโโ routers/
โ โ โโโ __init__.py
โ โ โโโ auth_router.py
โ โ โโโ users_router.py
โ โ โโโ worlds_router.py
โ โ โโโ game_ratings_router.py
โ โ โโโ history_router.py
โ โ โโโ saved_games_router.py
โ โ โโโ tokenized_history_router.py
โ โ โโโ deep_memory_router.py
โ โโโ services/
โ โโโ __init__.py
โ โโโ data_api_auth_service.py
โ โโโ users_service.py
โ โโโ worlds_service.py
โ โโโ history_service.py
โ โโโ tokenized_history_service.py
โ โโโ deep_memory_service.py
โ โโโ saved_games_service.py
โโโ ai/
โ โโโ __init__.py
โ โโโ schemas_ai_server.py
โ โโโ routers/
โ โ โโโ __init__.py
โ โ โโโ root_router.py
โ โ โโโ tokens_router.py
โ โ โโโ lore_router.py
โ โโโ services/
โ โ โโโ __init__.py
โ โ โโโ ai_api_service.py
โ โ โโโ ai_modeler_service.py
โ โ โโโ lookup_ai_service.py
โ โ โโโ http_service.py
โ โ โโโ ddgs_service.py
โ โ โโโ extractors/
โ โ โโโ __init__.py
โ โ โโโ common.py
โ โ โโโ generic_extractor.py
โ โโโ lookup_ai/
โ โโโ __init__.py
โ โโโ fetch_sources.py
โ โโโ section_selector.py
โ โโโ query_terms.py
โ โโโ services/
โ โโโ __init__.py
โ โโโ wikipedia_service.py
โ โโโ fandom_service.py
โ โโโ lol_wiki_service.py
โ โโโ leagueoflegends_service.py
โ โโโ product_page_service.py
โ โโโ fanlore_service.py
โ โโโ gluwee_service.py
โ โโโ halloweencostumes_service.py
โ โโโ costumerealm_service.py
โ โโโ animecharacters_service.py
โโโ business/
โ โโโ __init__.py
โ โโโ converters/
โ โ โโโ __init__.py
โ โ โโโ converters.py
โ โโโ dtos/
โ โ โโโ __init__.py
โ โ โโโ dtos.py
โ โโโ models/
โ โ โโโ __init__.py
โ โ โโโ models.py
โ โโโ schemas/
โ โโโ __init__.py
โ โโโ schemas_api.py
โโโ shared/
โ โโโ __init__.py
โ โโโ helpers/
โ โ โโโ __init__.py
โ โ โโโ ai_settings.py
โ โ โโโ memory_helper.py
โ โโโ services/
โ โโโ __init__.py
โ โโโ auth_service.py
โ โโโ orm_service.py
โโโ tools/
โโโ (project-specific helpers and scripts)
adventure-client/ # React frontend
โโโ package.json
โโโ package-lock.json
โโโ public/
โ โโโ index.html
โ โโโ manifest.json
โ โโโ robots.txt
โโโ src/
โโโ index.js
โโโ index.css
โโโ App.js
โโโ App.css
โโโ Login.js
โโโ NewGame.js
โโโ CreateWorld.js
โโโ Game.js
โโโ LoadGame.js
โโโ ManageWorlds.js
โโโ ManageWorlds.js
โโโ config.js
โโโ tests/
โโโ (react tests)
###1. Clone the Repository
git clone https://github.com/VersacheX/FastAPIAdventureInAI.git
cd FastAPIAdventureInAI
###2. Backend Setup
cd FastAPIAdventureInAI
python -m venv env
Windows (PowerShell):
.\\env\\Scripts\\Activate.ps1
Windows (CMD):
.\\env\\Scripts\\activate.bat
Linux/Mac:
source env/bin/activate
pip install -r requirements.txt
If you have CUDA/PyTorch compatibility issues, install PyTorch separately using the instructions from the PyTorch website for your CUDA version.
Edit FastAPIAdventureInAI/config.py to set your database connection (default is SQLite):
DATABASE_URL = "sqlite:///./adventure.db"
python -c "from dependencies import engine; from business.models import Base; Base.metadata.create_all(bind=engine)"
python seed_data.py
This will create default game ratings, pre-built worlds, AI directive settings, account levels, and an admin user.
The project uses a local GPTQ-compatible model. The active model constant is defined in FastAPIAdventureInAI/ai/services/ai_modeler_service.py as AI_MODEL.
Recommended model: TheBloke/MythoMax-L2-13B-GPTQ (or another compatible GPTQ model). Update AI_MODEL in ai/services/ai_modeler_service.py if you place the model locally or want to switch models.
You typically run two processes (three if you run the frontend locally):
You can start the AI server either by running ai_server.py directly or using ai_main.py which launches the same app with Uvicorn.
Run the standalone AI server which loads the local model and serves inference on port9000:
cd FastAPIAdventureInAI
.\\env\\Scripts\\Activate.ps1 # or activate your venv
python ai_main.py
This starts the AI model server on http://localhost:9000.
Note:
ai_server.pyand the model loader inai/services/ai_modeler_service.pyare responsible for loading the local GPTQ model. If you prefer the backend to directly load the model into FastAPI app state, the code already supports loading the model intoapp.state.
Start the backend API (uses data_server.py via main.py):
cd FastAPIAdventureInAI
.\\env\\Scripts\\Activate.ps1
python main.py
This starts the API server (default host 0.0.0.0) on port8080 by default.
Alternatively you can run:
python data_server.py
cd adventure-client
npm install
npm start
This starts the frontend development server on http://localhost:3000.
http://localhost:3000FastAPIAdventureInAI/config.py)SECRET_KEY = "your-secret-key-here" # Change in production!
DATABASE_URL = "sqlite:///./adventure.db"
AI_SERVER_URL = "http://127.0.0.1:9000"
CORS_ORIGINS = ["http://localhost:3000"]
Token budgets and memory limits can be adjusted in the AI helpers and settings files under ai/ and shared/helpers/.
The application uses a three-tier memory compression system:
This keeps prompts within model context windows while preserving key story information.
api/routers/ or ai/routers/ for AI-specific endpointsdata_server.py (or main wiring)When changing models:
business/models/main.py or ai_server.pyOnce running backend, visit:
http://localhost:8080/docshttp://localhost:8080/redocSECRET_KEY and default passwords before productionAdd your license here.
22 commits
Python
73.5%
JavaScript
18.6%
CSS
6.6%