BBReplay is a website to host and serve replay data from the game BlazBlue Central Fiction. Replays can be uploaded to the site to be served and displayed. They can be filtered on the site through creation date, player names, or characters used. Replays can be automatically uploaded through the BBCF Improvement Mod fork. This site was created as a personal project but can be used by others. The site also exposes a public API for managing replays.
Docker Setup
This project uses Docker for containerization. Follow the steps below to set up the project:
Build the Docker Image:
docker build -t bbreplay .
Run Docker Compose:
docker-compose -f compose.yaml up
Docker Compose File
The `compose.yaml` file defines the services required for the application:
services:
db:
image: postgres:latest
container_name: postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: AuraKingdom1
POSTGRES_DB: replaydb
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- my_network
api:
build:
dockerfile: Dockerfile
context: .
ports:
- "5000:5000"
depends_on:
- db
networks:
- my_network
restart: "always"
memcached:
container_name: memcached
image: memcached:latest
networks:
- my_network
ports:
- "11211:11211"
restart: "always"
volumes:
postgres_data:
networks:
my_network:
The `Dockerfile` specifies how the Docker image for the application is built:
FROM python:3.9-slim
RUN apt-get update
ENV DATABASE_URL=postgresql+asyncpg://postgres:AuraKingdom1@db:5432/replaydb
ENV API_KEY=thunderiscute
ENV SECRET_KEY=API_KEY
COPY requirements.txt /tmp/requirements.txt
RUN python -m pip install --upgrade pip && pip install -r /tmp/requirements.txt
COPY . .
CMD ["python", "manage.py", "init-db"]
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app.wsgi:create_app()"]
The `manage.py` file uses Flask CLI commands for application management. Here are the commands:
To initialize the database, run:
python manage.py init_db
- Dockerized web application
- Replay management system with binary data handling
- Public API for retrieving replays
The following dependencies are specified for this project:
asyncpg==0.29.0
Flask[async]==3.0.3
Flask_Limiter==3.7.0
flask_wtf==1.2.1
pydantic==2.7.1
pydantic_settings==2.2.1
python-dotenv==1.0.1
python_dateutil==2.9.0.post0
pytz==2024.1
SQLAlchemy==2.0.30
WTForms==3.1.2
gunicorn==22.0.0
pymemcache==4.0.0
Configuration details can be managed through environment variables as defined in the Dockerfile
:
- `DATABASE_URL`: The URL for the PostgreSQL database
- `API_KEY`: An API key for application use
- `SECRET_KEY`: A secret key for security purposes
The routes are defined in routes/replay_routes.py
- Description: Retrieve a list of all replays or filter replays based on query parameters.
- Parameters:
- query_params (optional):
query_params | Type | Description |
---|---|---|
replay_id |
Integer | Unique identifier for each replay. |
p1 |
String | Player 1's name. |
p1_character_id |
Integer | Character ID for Player 1, must be within the specified range. (0-35) |
p2 |
String | Player 2's name. |
p2_character_id |
Integer | Character ID for Player 2, must be within the specified range. (0-35) |
recorder |
String | Name of the person who recorded the replay. |
p1_steamid64 |
Integer | Steam ID for Player 1. |
p2_steamid64 |
Integer | Steam ID for Player 2. |
recorder_steamid64 |
Integer | Steam ID for the recorder. |
Include |
Boolean | A flag for including replay binary. |
- Response: Returns a JSON array containing replay data.
- Description: Create a new replay.
- Request Body:
- Binary data of the replay file.
- Response:
- Returns JSON data of the created replay.
- Description: Retrieve a specific replay by its ID.
- Parameters:
- replay_id: ID of the replay to retrieve.
- Response:
- Returns JSON data of the specified replay.
- Description: Update an existing replay.
- Parameters:
- replay_id: ID of the replay to update.
- Request Body:
- JSON data containing attributes to update.
- Response:
- Returns JSON data of the updated replay.
- Description: Delete a specific replay by its ID.
- Parameters:
- replay_id: ID of the replay to delete.
- Response:
- Returns a success message upon successful deletion.
- Description: Download a specific replay file by its ID.
- Parameters:
- replay_id: ID of the replay to download.
- Response:
- Returns the replay file as a downloadable attachment.
- Description: Download multiple replays as a compressed ZIP file.
- Request Body:
- JSON array of replay IDs to download.
- Response:
- Returns a compressed ZIP file containing the requested replays.
Usage:
Make HTTP requests to the respective endpoints using the appropriate HTTP methods (GET, POST, PUT, DELETE).
Ensure that request parameters and body payloads adhere to the specified formats.
Handle responses as per HTTP status codes returned by the API.
Note:
Proper authentication and authorization mechanisms are implemented to secure access to UPDATE, DELETE API endpoints.
Troubleshooting
Contributors
License