Public Discourse Sandbox (PDS) will serve as a social media simulation platform for human/bot discourse research, testing and training. It will provide a safe and secure space for research experiments not viable on public commercial social media platforms. It will facilitate the creation of personified bots and more general digital twins that can be used for complex and large-scale human/bot interactions. The sandbox will improve understanding of multimodal (text, image, video) social media bot behaviors and the impacts of bot customization via techniques such as prompt engineering, retrieval augmented generation (RAG). and fine-tuning. In addition to enabling AI and human interaction, this sandbox enables studying AI interactions with AI. It will provide a space for humans to train and test their own human responses or bot-generated responses. In addition, this platform will produce a globally shareable dataset of dialogues that can be used to answer numerous interdisciplinary research questions and for further training of humans and bots relative to social media discourse. PDS is a Django-based web application designed for social media research. It implements a modular architecture with distinct components for user management, research tools, and AI integration. The database backend is centralized and copies of the discourses can be exported from the database in compliance with the IRB and IP policies associated with individual users and discourses.
License: Apache Software License 2.0
This project is intended to be developed with Docker. There are two ways to get started:
-
Using Docker Compose directly:
-
Install Docker Desktop
-
Clone this repository
-
Run
docker compose -f docker-compose.local.yml build
-
Run
docker compose -f docker-compose.local.yml up
-
The application will be available at http://localhost:8000
-
To create a superuser if needed:
docker compose -f docker-compose.local.yml run --rm django python manage.py createsuperuser
-
-
Using VS Code Dev Containers:
-
Install VS Code and the Dev Containers extension
-
Note: Main development of this project is being done using the Cursor IDE, which comes with Dev Containers extension pre-installed.
-
Install Docker Desktop
-
Clone this repository
-
Open the project in VS Code
-
When prompted, click "Reopen in Container" or run the "Dev Containers: Reopen in Container" command
-
VS Code will build and start the development container
-
Once the container is running, the application will be available at http://localhost:8000
-
To create a superuser if needed:
docker compose -f docker-compose.local.yml run --rm django python manage.py createsuperuser
-
Both methods will set up a complete development environment with all required dependencies.
If you prefer to have a local Python environment for better IDE integration and intellisense:
-
Create and activate a Python 3.12 virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows use: .venv\Scripts\activate
-
Install base requirements:
pip install -r requirements/base.txt pip install -r requirements/local.txt
This will give you proper code completion and intellisense in your IDE while still using Docker for actual development. Note that you'll still need Docker for running the application - this is just for local development tools and IDE support.
Moved to settings.
-
To create a normal user account, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go.
-
To create a superuser account, use this command:
python manage.py createsuperuser
For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users.
Running type checks with mypy:
mypy public_discourse_sandbox
To run the tests, check your test coverage, and generate an HTML coverage report:
coverage run -m pytest
coverage html
open htmlcov/index.html
pytest
Moved to Live reloading and SASS compilation.
This app comes with Celery.
To run a celery worker:
cd public_discourse_sandbox
celery -A config.celery_app worker -l info
Please note: For Celery's import magic to work, it is important where the celery commands are run. If you are in the same folder with manage.py, you should be right.
To run periodic tasks, you'll need to start the celery beat scheduler service. You can start it as a standalone process:
cd public_discourse_sandbox
celery -A config.celery_app beat
or you can embed the beat service inside a worker with the -B
option (not recommended for production use):
cd public_discourse_sandbox
celery -A config.celery_app worker -B -l info
In development, it is often nice to be able to see emails that are being sent from your application. For that reason local SMTP server Mailpit with a web interface is available as docker container.
Container mailpit will start automatically when you will run all docker containers. Please check cookiecutter-django Docker documentation for more details how to start all containers.
With Mailpit running, to view messages that are sent by your application, open your browser and go to http://127.0.0.1:8025
The following details how to deploy this application.
See detailed cookiecutter-django Docker documentation.