Built for Data Analytics · Django · DRF · Celery · PostgreSQL
Kruxova MSDAT API
The REST API of MSDAT, a multi-sectoral data analytics tool, built with Django and Django REST Framework. It stores indicators, locations, data sources and the data values that connect them, serves them to dashboards as JSON with public reads and token-protected writes, and keeps file caches of the large data sets that a Celery task refreshes. Swagger UI and ReDoc document every route. The code was rebuilt from a Django 3.0 project that exposed its user table and carried two copies of itself.
REST Clients → DRF Routes → SQL Database → Celery Cache

Role
Backend Developer
Duration
Since July 2022
Tech Stack
The Problem
A data API that serves dashboards has to be trustworthy in two ways: what it returns must be what was stored, and what it exposes must be what was meant to be public.
The starting point was a Django 3.0 project with 2020 pins and two copies of the same code, a live one and a superseded 2022 copy of 120 files. Each environment had its own settings file with a hard-coded database password, the secret key was a literal, and the event log stored the whole request including the Authorization token and cookies. The user endpoint let an anonymous visitor read every account including its password hash, and writing a user stored the password as clear text. Several routes returned a 500 error for ordinary mistakes such as a missing query parameter, an empty database or a stopped message broker.
My Approach
- One codebase. The superseded copy was diffed against the live apps and then deleted, and the three per-environment settings files became one module driven by environment variables; the secret key must be supplied unless debug is on, and hosts, trusted origins, database, CORS and the Celery broker are configuration.
- Accounts. The user endpoints are staff-only, passwords are write-only and hashed, a token holder can no longer overwrite another user's record, and the login answer no longer carries a hash.
- Audit trail. The event trail records only a safe subset of headers and the names of submitted form fields, never the token, cookies or values.
- Honest errors. A missing or non-integer offset or limit is a 400 with a message, an empty database answers 404 for the latest-data route, a stopped broker makes the cache refresh answer 503 with BROKER_UNAVAILABLE, and a malformed login body is a 400.
- Data. The eight fixture files could not be loaded by Django because their model labels were wrong; they are fixed, so all 1,015 reference objects load.
- Upgrade. Django 3.0 to 5.2 LTS, Celery 4 to 5, DRF 3.11 to 3.18, about 137 unused imports removed, and a Celery start script that named an invalid module corrected.
- Delivery. 56 tests, a CI workflow that lints, checks formatting and migration drift and runs the suite on SQLite and on PostgreSQL 17, an .env.example, and a README, development guide and changelog that match the code.
Results & Impact
Re-run on 2026-11-14 in a scratch copy: ruff check and ruff format --check pass on 119 files, 56 tests pass, makemigrations --check detects no changes, and uv audit finds no known vulnerabilities in 51 packages.
The real app was also run locally that day on SQLite with the repository's own reference data: all 1,015 fixture objects loaded (7 value types, 4 factors, 17 data sources, 5 hierarchy levels, 33 indicators, 925 locations and two more small sets). Swagger UI and ReDoc rendered, a public read returned a location, a write without a token was refused with 401 and with a token created a record with 201, an invalid offset returned 400, an anonymous read of the user list returned 401, a login with an empty body returned 400, and the cache refresh without Redis returned 503 BROKER_UNAVAILABLE. For the data routes, 35 rows with artificial test values (10.0, 20.0 and so on) were posted through the API's own authenticated endpoint; they are not statistics.
Recorded in the repository's work-done.md (2026-10-30): the 49 tests that existed before the account-security fix also passed on PostgreSQL 17, and a production-style deploy check raised only the two optional HSTS warnings.
Not verified: a Celery worker against a real Redis (the refresh task is tested with the broker mocked), memcached, production-sized data, and any speed or capacity claim.