Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
6eb59cd
Beginning
Maho-Yoshino Oct 24, 2026
2e2c9b0
Rename 'app' to 'src'
Maho-Yoshino Oct 24, 2026
6f65bc0
Finish AGENTS.md migration to new structure
Maho-Yoshino Oct 24, 2026
53f1345
Major dict helper rewrite
Maho-Yoshino Oct 24, 2026
c833b49
more dict util improvements
Maho-Yoshino Oct 25, 2026
c3f89ee
Hosting files improvements
Maho-Yoshino Oct 25, 2026
b74b104
Endpoints return data cleanup work
Maho-Yoshino Oct 26, 2026
4b647cc
Major news utility rework
Maho-Yoshino Oct 26, 2026
689c5db
A lot of fixes + cache module
Maho-Yoshino Oct 26, 2026
bf15585
Fix error between brackets on `/v1/clans/sqb/current`
Maho-Yoshino Oct 26, 2026
16c0800
implement cache into news module
Maho-Yoshino Oct 27, 2026
1aa8a2f
Fixes
Maho-Yoshino Oct 27, 2026
59d9d09
Marketplace endpoints improvements
Maho-Yoshino Oct 27, 2026
5e433f5
Fixes
Maho-Yoshino Oct 27, 2026
7da503d
Fix Swagger UI modify js
Maho-Yoshino Oct 27, 2026
e071dbc
Implement basis for automated testing
Maho-Yoshino Oct 27, 2026
35608b6
Create pyproject.toml
Maho-Yoshino Oct 27, 2026
c00f937
Update pyproject.toml
Maho-Yoshino Oct 27, 2026
69984ae
Add vehicleParser to ruff ignore
Maho-Yoshino Oct 27, 2026
47b4129
Ruff suggested fixes
Maho-Yoshino Oct 27, 2026
d331b04
Update const.py
Maho-Yoshino Oct 27, 2026
02d75d7
Fixing some pytest complaints
Maho-Yoshino Oct 29, 2026
ab29637
Bugfix and raising supported FastAPI version
Maho-Yoshino Oct 29, 2026
3057fbb
Add basic login tests
Maho-Yoshino Oct 29, 2026
e41d4d7
Fixing network return model
Maho-Yoshino Oct 29, 2026
a9df06f
Added github workflows
Maho-Yoshino Oct 29, 2026
06625bd
Testing newly added workflows
Maho-Yoshino Oct 29, 2026
98b0cfd
More testing
Maho-Yoshino Oct 29, 2026
b1ec748
style: apply ruff fixes
Maho-Yoshino Oct 29, 2026
e621120
Bugfixes
Maho-Yoshino Oct 29, 2026
68ad719
Fixing routing issue
Maho-Yoshino Oct 29, 2026
a808200
style: apply ruff fixes
Maho-Yoshino Oct 29, 2026
1701893
Remove redundant nonlocal declaration
Maho-Yoshino Oct 29, 2026
a6a8cb6
Merge branch 'cleanup-returns' of https://github.com/Order-Of-The-Bir…
Maho-Yoshino Oct 29, 2026
e1a591f
Fixing issues proposed by Deepseek
Maho-Yoshino Oct 29, 2026
47b7bc5
Cleanup
Maho-Yoshino Oct 29, 2026
e0e49e7
style: apply ruff fixes
Maho-Yoshino Oct 29, 2026
263551d
More fixes
Maho-Yoshino Oct 29, 2026
ada9133
Remove unused AuthenticationError import
Maho-Yoshino Oct 29, 2026
c19b1d6
style: apply ruff fixes
Maho-Yoshino Oct 29, 2026
b9b9ff3
A few more bugfixes
Maho-Yoshino Oct 29, 2026
8cf9961
Merge branch 'cleanup-returns' of https://github.com/Order-Of-The-Bir…
Maho-Yoshino Oct 29, 2026
a72f1bc
Fix return name of clan search
Maho-Yoshino Oct 30, 2026
ba27d80
style: apply ruff fixes
Maho-Yoshino Oct 30, 2026
318e4e9
Added returning the next bracket
Maho-Yoshino Oct 30, 2026
b3189ea
style: apply ruff fixes
Maho-Yoshino Oct 30, 2026
9a9c1f6
Improve localization + get endpoint
Maho-Yoshino Nov 6, 2026
637a7db
style: apply ruff fixes
Maho-Yoshino Nov 6, 2026
ee96123
Restructure
Maho-Yoshino Nov 7, 2026
4b33d9d
Linter fixes
Maho-Yoshino Nov 7, 2026
ac948ff
Marketplace backend restructuring
Maho-Yoshino Nov 11, 2026
b0f441c
Code fixes
Maho-Yoshino Nov 11, 2026
165fda7
Refactoring VehicleParser
Maho-Yoshino Nov 13, 2026
475aeb2
Update workflows to stop deprecation notices
Maho-Yoshino Nov 13, 2026
5e634e2
Attach HEAD to linting workflow
Maho-Yoshino Nov 13, 2026
7917a08
Make linter only run in PRs
Maho-Yoshino Nov 13, 2026
2638a00
Remove redundant list from linter
Maho-Yoshino Nov 13, 2026
fe8aad1
Make tests run on pull requests
Maho-Yoshino Nov 13, 2026
52eb145
Fixing issues
Maho-Yoshino Nov 14, 2026
89521e8
Improving testing response provider structure
Maho-Yoshino Nov 14, 2026
5d26c44
Improve network manager
Maho-Yoshino Nov 14, 2026
0dcfde1
Migrating replays logic to updated networkmanager
Maho-Yoshino Nov 14, 2026
a447320
style: apply ruff fixes
Maho-Yoshino Nov 14, 2026
0cf95f9
Major whitespace cleanup
Maho-Yoshino Nov 14, 2026
2f3138d
error fixing
Maho-Yoshino Nov 14, 2026
184c635
Added more linting checks
Maho-Yoshino Nov 15, 2026
e4bcca6
Fix test network manager reference
Maho-Yoshino Nov 15, 2026
48905c2
Deepseek proposed fixes
Maho-Yoshino Nov 15, 2026
2a5a4d9
Implementing fixes
Maho-Yoshino Nov 15, 2026
10ac0ec
style: apply ruff fixes
Maho-Yoshino Nov 15, 2026
4dda92e
Fixes
Maho-Yoshino Nov 15, 2026
d48a80b
Return type standardization
Maho-Yoshino Nov 15, 2026
9199955
style: apply ruff fixes
Maho-Yoshino Nov 15, 2026
a4d013d
Add return types to endpoints without one
Maho-Yoshino Nov 15, 2026
e69027e
Merge branch 'cleanup-returns' of https://github.com/Order-Of-The-Bir…
Maho-Yoshino Nov 15, 2026
f4fb147
style: apply ruff fixes
Maho-Yoshino Nov 15, 2026
33fbe43
Improve pytest harness
Maho-Yoshino Nov 15, 2026
515d5a7
Removed unused ServerBearer usage
Maho-Yoshino Nov 15, 2026
aecaa03
Fixes
Maho-Yoshino Nov 15, 2026
06b4032
Fixes pt.1
Maho-Yoshino Nov 18, 2026
a3a7876
style: apply ruff fixes
Maho-Yoshino Nov 18, 2026
cad0eae
Fixes pt.2
Maho-Yoshino Nov 19, 2026
c63ed48
style: apply ruff fixes
Maho-Yoshino Nov 19, 2026
2745485
Fixes pt. 3
Maho-Yoshino Nov 19, 2026
6611bfa
Merge branch 'cleanup-returns' of https://github.com/Order-Of-The-Bir…
Maho-Yoshino Nov 19, 2026
32870f1
Make code required parameter again for 2FA
Maho-Yoshino Nov 19, 2026
0ab3d59
Fixes pt.4
Maho-Yoshino Nov 20, 2026
e12337b
style: apply ruff fixes
Maho-Yoshino Nov 20, 2026
f7808f3
Fixes pt.5
Maho-Yoshino Nov 20, 2026
038c71b
Fixes pt.6
Maho-Yoshino Nov 20, 2026
6898a42
Fix forwarded IPs config
Maho-Yoshino Nov 20, 2026
48ba48d
style: apply ruff fixes
Maho-Yoshino Nov 20, 2026
7ee49f5
Improve contact info display
Maho-Yoshino Nov 20, 2026
71e82e0
style: apply ruff fixes
Maho-Yoshino Nov 20, 2026
4ff583b
Fix 2FA completion, token refresh, inventory, and news handling (#8)
MrMindBlow Nov 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
insert_final_newline = true
indent_style = tabs
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
indent_style = tab
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false # keep the two-space markdown line breaks
# keep the two-space markdown line breaks
trim_trailing_whitespace = false

[*.yaml]
indent_style = space
11 changes: 6 additions & 5 deletions .example.env
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# Hosting settings
PORT=8001
HOST=127.0.0.1

FORWARDED_ALLOW_IPS=

# Logging level (INFO recommended unless developing)
LOG_LEVEL=INFO

# IPs to trust for X-Forwarded-For (proxies like a Cloudflare tunnel). Use "*" to trust all,
# or a CIDR/subnet like "172.18.0.0/16" to only trust the Docker network.
FORWARDED_ALLOW_IPS=*

# Rate limiting
LOGIN_RATE_LIMIT=25/minute
REGULAR_RATE_LIMIT=100/minute
Expand All @@ -21,3 +17,8 @@ SERVER_PASS=
# Linux Systemd/Docker settings
UID=
GID=

# Contact details
CONTACT_NAME=
CONTACT_URL=
CONTACT_EMAIL=
32 changes: 32 additions & 0 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Ruff linter
on: pull_request

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.14"]
steps:
- uses: actions/checkout@v7
with:
ref: refs/pull/${{ github.event.pull_request.number }}/head
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install ruff
- name: Auto-fix with Ruff
if: github.event.pull_request.head.repo.full_name == github.repository
run: ruff check src/ --fix
Comment thread
Maho-Yoshino marked this conversation as resolved.
Resolved
- name: Check with Ruff (forks)
if: github.event.pull_request.head.repo.full_name != github.repository
run: ruff check src/
- name: Commit and push fixes
if: github.event.pull_request.head.repo.full_name == github.repository
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "style: apply ruff fixes"
permissions:
contents: write
22 changes: 22 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Pytest
on: pull_request

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.14"]
steps:
- uses: actions/checkout@v7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt pytest pytest-asyncio httpx
- name: Run Pytest
run: |
python -m pytest
160 changes: 80 additions & 80 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,88 @@
# AGENTS instructions
This repository contains a python application using FastAPI. This project acts as a "translation layer" between Gaijin Entertainment's proprietary `blk` format, and a usable `json` format. Due to the nature of this API it is very hard to automate testing, therefore all testing is to be done manually
# AGENTS instructions
This repository contains a python application using FastAPI. This project acts as a "translation layer" between Gaijin Entertainment's proprietary `blk` format, and a usable `json` format. Due to the nature of this API it is very hard to automate testing, therefore all testing is to be done manually

## Testing
Manual testing can be done through the Swagger UI interface found on `/` or `/docs`
The templates in `app/utils/connection/http/templates/` (and `app/utils/connection/tcp/templates/`) can NOT be used directly in curl requests, they are in a proprietary format
## Testing
Manual testing can be done through the Swagger UI interface found on `/` or `/docs`
The templates in `src/utils/connection/http/templates/` (and `src/utils/connection/tcp/templates/`) can NOT be used directly in curl requests, they are in a proprietary format

## Structure
The repository has the following directories at its root:
- `app` - The application source code:
- `api` - The FastAPI routers (`v1`, `backends/`, `models/`)
- `utils` - A set of utilities used in the code, like:
- `connection/` - Network + BLK conversion (`network.py`, `blk_utils.py`, `const.py`, `http/`, `tcp/`, `default_network_cfg.json`)
- `geo.py` - Geolocation utility
- `auth.py` - Database and authentication management utility
- `news.py` - News parsing
- `helper.py` - Shared helpers
- `websocket.py` - WebSocket handling
- `replayParser/` - Replay parsing
- `vehicleParser/` - Vehicle data parsing
- `main.py` - Main entry point of the code
- `config.py` - Configuration / path constants
- `tools` - External binaries (`wt_ext_cli`, `binBlk`) used for BLK conversion
- `dev_tools` - Development-only tooling, regular users will never trigger any code within this directory
- `data` - Runtime data (logs, users.db, news.json, GeoLite2 DB, vehicle cache)
The root directory also includes the following files:
- `gaijin_api_endpoints.md` - Documentation on Gaijin Entertainment's internal endpoints, their usage and response
- `app/main.py` - Main entry point of the code
- `requirements.txt` - PyPI package requirements for the server
- `Dockerfile` - Docker image definition
- `compose.yml` - Docker Compose definition (also referenced by `systemd.service`)
- `.example.env` - Example .env file, that can be copied. Includes the following variables:
- `PORT` - The port to run on
- `HOST` - The IP to be listening on
- `MACHINE_ID` - Value sent when logging in, doesn't matter much
- `TOKEN_ENC_KEY` - Encryption key used in the database. Do not lose this, as losing it will mean the code can't decrypt sensitive values used in the backend logic
- `WT_EXT_CLI_PATH` - wt_ext_cli path, if not found in `tools/` or is named differently
- `BINBLK_PATH` - binBlk path, if not found in `tools/` or is named differently
- `LOGIN_RATE_LIMIT` - Rate limit for the login endpoints
- `REGULAR_RATE_LIMIT` - Rate limit for the rest of the endpoints
- `LOG_LEVEL` - The log level of the logger. For hosting `WARNING` is fine, as it still shows issues that have to be handled
- `LICENSE` - The license the repository falls under
- `README.md` - The README of the repository, contains some extra context
- `app/swagger_ui_modify.css` / `app/swagger_ui_modify.js` - Content used to modify the Swagger UI interface, to support websockets
The following directories/files appear only after running the server at least once:
- `.env` - The .env file used by the code
- `data/logs/` - Logs directory
- `data/users.db` - Authentication database
- `data/news.json` - Last sent news storage
- `data/GeoLite2-City.*` - Geolocation database
## Structure
The repository has the following directories at its root:
- `src` - The application source code:
- `api` - The FastAPI routers (`v1`, `backends/`, `models/`)
- `utils` - A set of utilities used in the code, like:
- `connection/` - Network + BLK conversion (`network.py`, `blk_utils.py`, `const.py`, `http/`, `tcp/`, `default_network_cfg.json`)
- `geo.py` - Geolocation utility
- `auth.py` - Database and authentication management utility
- `news.py` - News parsing
- `helper.py` - Shared helpers
- `websocket.py` - WebSocket handling
- `replayParser/` - Replay parsing
- `vehicleParser/` - Vehicle data parsing
- `main.py` - Main entry point of the code
- `config.py` - Configuration / path constants
- `tools` - External binaries (`wt_ext_cli`, `binBlk`) used for BLK conversion
- `dev_tools` - Development-only tooling, regular users will never trigger any code within this directory
- `data` - Runtime data (logs, users.db, news.json, GeoLite2 DB, vehicle cache)
The root directory also includes the following files:
- `gaijin_api_endpoints.md` - Documentation on Gaijin Entertainment's internal endpoints, their usage and response
- `src/main.py` - Main entry point of the code
- `requirements.txt` - PyPI package requirements for the server
- `Dockerfile` - Docker image definition
- `compose.yml` - Docker Compose definition (also referenced by `systemd.service`)
- `.example.env` - Example .env file, that can be copied. Includes the following variables:
- `PORT` - The port to run on
- `HOST` - The IP to be listening on
- `MACHINE_ID` - Value sent when logging in, doesn't matter much
- `TOKEN_ENC_KEY` - Encryption key used in the database. Do not lose this, as losing it will mean the code can't decrypt sensitive values used in the backend logic
- `WT_EXT_CLI_PATH` - wt_ext_cli path, if not found in `tools/` or is named differently
- `BINBLK_PATH` - binBlk path, if not found in `tools/` or is named differently
- `LOGIN_RATE_LIMIT` - Rate limit for the login endpoints
- `REGULAR_RATE_LIMIT` - Rate limit for the rest of the endpoints
- `LOG_LEVEL` - The log level of the logger. For hosting `WARNING` is fine, as it still shows issues that have to be handled
- `LICENSE` - The license the repository falls under
- `README.md` - The README of the repository, contains some extra context
- `src/swagger_ui_modify.css` / `src/swagger_ui_modify.js` - Content used to modify the Swagger UI interface, to support websockets
The following directories/files appear only after running the server at least once:
- `.env` - The .env file used by the code
- `data/logs/` - Logs directory
- `data/users.db` - Authentication database
- `data/news.json` - Last sent news storage
- `data/GeoLite2-City.*` - Geolocation database

## External tools
This project uses the following external binaries:
- `wt_ext_cli`
- Autodiscovered in the `tools` directory
- If not in said directory, it will look at the `WT_EXT_CLI_PATH` environment variable
- The program will stop if this binary is not found at startup
- Found at `https://github.com/Warthunder-Open-Source-Foundation/wt_ext_cli`
- `binBlk`
- Gaijin Entertainment's uploaded `blk` tool
- Autodiscovered in the `tools` directory
- If not in said directory, it will look at the `BINBLK_PATH` environment variable
- The program will stop if this binary is not found at startup
- Found at `https://github.com/GaijinEntertainment/DagorEngine/releases/latest` release body, as `tools-prebuilt-${platform}-${arch}.7z`
## External tools
This project uses the following external binaries:
- `wt_ext_cli`
- Autodiscovered in the `tools` directory
- If not in said directory, it will look at the `WT_EXT_CLI_PATH` environment variable
- The program will stop if this binary is not found at startup
- Found at `https://github.com/Warthunder-Open-Source-Foundation/wt_ext_cli`
- `binBlk`
- Gaijin Entertainment's uploaded `blk` tool
- Autodiscovered in the `tools` directory
- If not in said directory, it will look at the `BINBLK_PATH` environment variable
- The program will stop if this binary is not found at startup
- Found at `https://github.com/GaijinEntertainment/DagorEngine/releases/latest` release body, as `tools-prebuilt-${platform}-${arch}.7z`

## Gaijin-imposed restrictions
- Tokens have to be refreshed once every hour. The refreshing is done by the code itself, the token just has to be used on any endpoint, and the backend handles the rest
## Gaijin-imposed restrictions
- Tokens have to be refreshed once every hour. The refreshing is done by the code itself, the token just has to be used on any endpoint, and the backend handles the rest

## File conventions
- Files use `tabs` for indentation, not spaces
- Importing is generally done with `from ... import ...`, to reduce the extra entries in IntelliSense
- Rate limiting via `app.api.shared.limiter`
- Use the module-level `logger` for logging
- In `app/utils/vehicleParser/`, trailing `pass` statements are intentional debug breakpoint anchors — do not remove them
## File conventions
- Files use `tabs` for indentation, not spaces
- Importing is generally done with `from ... import ...`, to reduce the extra entries in IntelliSense
- Rate limiting via `src.api.shared.limiter`
- Use the module-level `logger` for logging
- In `src/utils/vehicleParser/`, trailing `pass` statements are intentional debug breakpoint anchors — do not remove them

## Sensitive data
Sensitive data, like session tokens and emails are stored, see `README.md#privacy-policy`
## Sensitive data
Sensitive data, like session tokens and emails are stored, see `README.md#privacy-policy`

## Running the server
- Copy `.example.env` to `.env` (`cp ./.example.env ./.env`) and edit as needed
- `docker compose up -d` — builds and starts the server; API docs at `/` and `/docs`
- Or run directly: `python app/main.py`
## Running the server
- Copy `.example.env` to `.env` (`cp ./.example.env ./.env`) and edit as needed
- `docker compose up -d` — builds and starts the server; API docs at `/` and `/docs`
- Or run directly: `python src/main.py`

## Architecture
Request flow: `app/api/v1` router => `app/api/v1/backends/` => `app/utils/connection/blk_utils.py` (BLK <=> JSON) => Gaijin backend
- `app/api/v1/backends/` — per-domain backend logic (clans, general, marketplace, replay, users)
- `app/api/v1/models/` — Pydantic response/request models
- `app/utils/connection/blk_utils.py` — BLK fetch/conversion (depends on `wt_ext_cli` / `binBlk`)
## Architecture
Request flow: `src/api/v1` router => `src/api/v1/backends/` => `src/utils/connection/blk_utils.py` (BLK <=> JSON) => Gaijin backend
- `src/api/v1/backends/` — per-domain backend logic (clans, general, marketplace, replay, users)
- `src/api/v1/models/` — Pydantic response/request models
- `src/utils/connection/blk_utils.py` — BLK fetch/conversion (depends on `wt_ext_cli` / `binBlk`)
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FROM python:3.14-slim

WORKDIR /app
WORKDIR /src

COPY ./requirements.txt /app/requirements.txt
COPY ./requirements.txt /src/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

RUN apt-get update \
&& apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/*

COPY app/ ./app
COPY src/ ./src
COPY tools/ /opt/tools/

RUN chmod +x /opt/tools/wt_ext_cli /opt/tools/binBlk

CMD ["python", "app/main.py"]
CMD ["python", "src/main.py"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ docker compose build
docker compose up -d
```

If you set `SERVER_EMAIL` and `SERVER_PASS`, you can approve Gaijin Pass requests on your device while the server runs in the background. If the server account uses an email code, start the service with an interactive terminal and enter the code within 15 minutes.

## Contributions
Contributions are welcome.
Pull requests that improve ThunderAPI without breaking existing functionality are encouraged
Expand Down
16 changes: 0 additions & 16 deletions app/api/root.py

This file was deleted.

20 changes: 0 additions & 20 deletions app/api/v1/__init__.py

This file was deleted.

Loading
Loading