In December 2024, I was a final-year student in the middle of exams when someone I respected asked me for a favor: build a working prototype, fast, to pitch a project to decision-makers.
The idea was HydroPortail: a web app that maps fuel stations, depots and retailers across the Democratic Republic of the Congo, filterable by province, territory and sector. The goal wasn't to ship a product. It was to make a concept tangible enough to win a project: a real map, real filters, something you can click on in a meeting.
The plan was one week. Between exams, it took about a month. But it worked: the prototype was built, deployed, and did its job.
Prototypes are supposed to be thrown away. This one wasn't. Two years later, with a lot more experience behind me, I wanted to publish it as a clean open-source project. And I knew that "built in a rush between two exams" probably meant "not ready to be public".
So before touching anything, I asked an AI coding assistant (Claude Code) to spin up eight specialized agents and audit the codebase, each from its own angle:
- a senior Django developer
- a database optimization expert
- an ethical hacker
- a security & compliance auditor
- a web designer
- a DevOps engineer
- a UI/UX & accessibility expert
- a software architect focused on clean code
Here is what they found, what I changed, and what I learned.
To be clear about what follows: most of these issues are the normal price of a prototype built in days. Speed was the right priority back then. The problem was never that the code was quick and dirty. It was that it was about to become public.
What the audit found
🔴 Security: the scary part
- The
SECRET_KEYwas hardcoded insettings.pysince the very first commit. Anyone with the repo could forge password-reset links or signed cookies on the live server. -
db.sqlite3was committed in 17 commits, including a superuser password hash and session keys. -
DEBUG = Truein production, with the server's public IP inALLOWED_HOSTS. Any 500 error displayed a full debug page, and the signup form POST data (password included) along with it. - A stored XSS on the map. Station names coming from the API were injected with
insertAdjacentHTML. A crafted CSV import in the admin could run JavaScript for every user who clicked a marker. - No brute-force protection on the login page, and an API endpoint without
@login_required.
🟠 Django: the "it works for the demo" part
The signup view never called form.is_valid():
# before user = User.objects.create_user( username=request.POST['username'], password=request.POST['password'], ... ) A missing field raised a KeyError (500), a duplicate username raised an IntegrityError (500), and the password validators configured in settings.py were never applied. Perfectly fine for a scripted demo, not for real users. My custom 404 page never showed up either, because I had written handler = ... instead of handler404 = ....
🟡 Database & architecture
- SQLite in production, coordinates stored as
FloatField(max_length=20, default="")(neither option means anything for a float). -
on_delete=CASCADEeverywhere: deleting a province would silently delete every territory, sector and station inside it. - Each station stored its sector, territory and province, with nothing guaranteeing they matched.
- Four nearly identical API views, N+1 queries, models named
provinces,stationand…type.
⚫ Repo hygiene
Committing straight from a deadline shows. Out of 269 tracked files: 70 .pyc files, 135 files from collectstatic, .DS_Store, Vim swap files, a carte copie.html… and an empty .gitignore. No requirements.txt, no tests.
The rebuild
1. A brand-new repository
You can't delete a secret from git history by committing a fix. I could have rewritten history with git filter-repo, but forks, clones and caches would still keep the old commits. So I started a new repository with a clean history, made the old one private, and rotated everything that had leaked.
2. A fictional country instead of real data
I wasn't sure I had the right to publish the real station data, or even the geographic reference data. So the repo ships with the "République démocratique de Drissu": an entirely fictional country whose shape mixes the DRC (a corridor to the ocean) and France (a hexagonal body). It has 12 provinces, 50 territories, 172 sectors and 48 stations, generated by a deterministic script and placed in an empty part of the South Atlantic, so the coordinates are real WGS 84 but never land on real ground.
3. The new stack
- Django 6.1 + GeoDjango + PostgreSQL/PostGIS: real geometries (
MultiPolygonField,PointField),PROTECTforeign keys, a station only linked to its sector. - Everything in Docker: no GDAL to install on your laptop, the same environment in dev, CI and production.
- A read-only GeoJSON API with django-ninja: one filterable
/api/stationsendpoint instead of four copy-pasted views, all filtering logic in a singleselectors.py, and a test asserting the list endpoint runs one SQL query. - Email-based custom user, a validated signup asking only for name and email (no more gender, birthdate and job title), django-axes to lock accounts after 5 failed logins, and POST-only logout.
- A new Leaflet map: cascading filters, marker clustering, a legend, and an accessible station card (focus management, Escape to close, a mobile drawer). Every piece of data goes through
textContent, neverinnerHTML:
// after: data is never parsed as HTML el("dd", { text: station.operator }) 4. Quality as a safety net
- 79 tests running on a real PostGIS database, 99% coverage (the CI fails below 95%)
- mypy with django-stubs, ruff for lint and formatting
- pre-commit hooks, including gitleaks to make sure no secret ever gets committed again
- GitHub Actions: lint and secrets,
pip-audit, typing and tests,check --deployin strict mode, and a build of the production image with a health check - Dependabot, a single-server deployment example with Caddy (automatic HTTPS, HSTS, CSP),
CONTRIBUTING,SECURITY, anAGENTS.mdfor coding assistants and anllms.txt
The CI was green on its first run on GitHub.
What I learned
- A secret in git history is public forever. Use
.gitignoreand environment variables from the first commit, even for a three-day prototype. It costs five minutes. - Never trust request data: not in
request.POST, not ininnerHTML. - Testing in production-like conditions catches real bugs. While testing the production stack locally, we found that the production Docker image no longer built at all:
leaflet.jsreferenced a source map I hadn't copied, and Django's manifest static storage refused to continue. Unit tests would never have caught it. The CI now builds that image on every push. - An AI audit is a great starting point, not a verdict. The agents were fast and thorough, but every finding still had to be checked against the code, and the big decisions (a new repo, fictional data, which Django version to target) were mine.
- Prototype code has a habit of surviving. Building fast was the right call for a pitch. But the moment a prototype outlives its purpose, its shortcuts become real risks. Revisiting it with today's standards, and showing how you fix your past shortcuts, says more about you as a developer than pretending you never took any.
The project
hache231 / django-hydroportail
Géoportail Django + PostGIS + Leaflet pour cartographier stations et dépôts d'hydrocarbures. Projet de 2024, refondu et ré-audité avec l'IA.
HydroPortail
Français · English
Géoportail de visualisation des stations-service, dépôts et points de vente d'hydrocarbures à l'échelle d'un pays, avec filtrage par province, territoire et secteur. Conçu à l'origine pour la RDC, il est livré avec un pays fictif pour la démonstration.
Fonctionnalités
- Carte interactive (Leaflet) : marqueurs regroupés, légende, contours des zones.
- Filtres en cascade province › territoire › secteur, recherche (nom, adresse, exploitant), types de point avec compteurs, statut.
- Fiche détaillée de chaque point : exploitant, adresse, horaires, capacité, produits, services.
- Interface en français, utilisable au clavier et sur mobile (panneau en tiroir).
- Comptes utilisateurs (connexion par email), protection contre le brute force.
- API JSON / GeoJSON documentée (OpenAPI).
À propos du projet
Ce projet a été développé initialement entre décembre 2024 et janvier 2025 (dernier commit de la version d'origine : 13 janvier 2025).
En décembre 2026, il a été ré-audité avec l'aide de l'IA (sécurité, base…
Getting it running takes three commands:
docker compose up -d docker compose exec web python manage.py migrate docker compose exec web python manage.py load_demo_data Feedback, issues and stars are very welcome ⭐ And if you've ever revisited a prototype you built under pressure, I'd love to hear what you found in the comments.


