Skip to main content
@kneeraazon
Client WorkWeb Apps & SaaSCase Study

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.

OUTCOME.0156Automated tests passing
OUTCOME.021,015Reference objects loaded from fixtures
OUTCOME.030Known vulnerabilities in 51 packages
2D SYSTEM TOPOLOGY // END-TO-END REQUEST PIPELINE4-STAGE DATA FLOW

REST Clients → DRF Routes → SQL Database → Celery Cache

FIG.01 // INTERFACE & SYSTEM CAPTURE1 / 7
The Swagger UI for the MSDAT API (CARD schema v1.2.0): the title with v1 and OAS 2.0 badges, the base URL, a note that POST, PATCH, DELETE and PUT routes are token protected, Django Login and Authorize buttons, a tag filter and the first account operations.
The Swagger UI for the MSDAT API (CARD schema v1.2.0): the title with v1 and OAS 2.0 badges, the base URL, a note that POST, PATCH, DELETE and PUT routes are token protected, Django Login and Authorize buttons, a tag filter and the first account operations.

Role

Backend Developer

Duration

Since July 2022

Tech Stack

Python 3.13Django 5.2 LTSDjango REST Framework 3.18Celery 5.6 (Redis broker)drf-yasg (Swagger UI and ReDoc)PostgreSQL or SQLiteWhiteNoise and GunicornpytestRuffuv
SECTION 01 // PROBLEM STATEMENT

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.

SECTION 02 // SYSTEM ARCHITECTURE & EXECUTION

My Approach

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
SECTION 03 // VERIFIED OUTCOMES

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.