Educational project (OpenClassrooms) — improve a legacy Python web application by adding automated tests, fixing bugs, and hardening code quality & observability.
- ✅ Identify and fix functional/technical bugs
- ✅ Add unit/integration tests to secure the main flows
- ✅ Raise coverage and enforce style checks
- ✅ Improve observability (structured logging, basic error monitoring)
- ✅ Document setup, decisions, and known limitations
This repository is intended for learning and portfolio demonstration — not production‑ready as‑is.
- Python 3.10+
- Django 4.x (typical stack; adapt if your app uses Flask/FastAPI)
- pytest + pytest‑django for tests
- coverage for code coverage
- black + ruff for formatting/linting
- Optional: django‑debug‑toolbar, Sentry (or similar) for error tracking
.
├─ manage.py
├─ requirements.txt
├─ app_name/ # main Django app(s)
│ ├─ models.py
│ ├─ views.py
│ ├─ urls.py
│ ├─ forms.py
│ ├─ templates/
│ └─ tests/ # pytest-style tests live here
├─ config/ (optional) # settings module if split
│ ├─ settings.py
│ ├─ urls.py
│ └─ wsgi.py/asgi.py
└─ .github/workflows/ci.yml # GitHub Actions (optional)
Your exact layout may differ; this README focuses on the testing & debugging work.
git clone <REPO_URL>
cd <REPO_DIR>
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txtCreate a .env file (or export env vars) as needed by your settings:
DEBUG=True
SECRET_KEY=change-me
ALLOWED_HOSTS=127.0.0.1,localhost
DATABASE_URL=sqlite:///./db.sqlite3 # or standard Django DB varsDo not commit real secrets. In production, set
DEBUG=Falseand proper hosts.
python manage.py migrate
python manage.py runserver 0.0.0.0:8000Run tests:
pytest -qRun coverage:
pytest --cov=. --cov-report=term-missingGenerate HTML report:
coverage html && open htmlcov/index.html # macOSIf the app uses Django’s test runner, you can also run:
python manage.py test.
Format:
black .Lint:
ruff check .Type checks (optional):
mypy .You can wire these into a pre‑commit hook:
pip install pre-commit
pre-commit install- Logging: use Python’s
loggingwith module‑level loggers; log exceptions with context - Debug toolbar:
django-debug-toolbarin dev to inspect queries and timings - Error tracking: Sentry (or equivalent) for crash reports in staging/prod
- DB inspections: enable
connection.queriesin dev only; add select‑related/prefetch to cut N+1s
- Fix CSRF issues on POST routes
- Normalize URL patterns; add missing redirects
- Harden forms/serializers validation
- Replace raw SQL with ORM queries; parameterize to avoid injections
- Add 404/500 custom handlers and friendly error pages
- Optimize slow views (query counts, pagination)
See commit history and issue tracker for the concrete changes applied in this repo.
- Use a managed SQL DB (PostgreSQL recommended)
- Set
DEBUG=False,ALLOWED_HOSTS, properSECURE_*headers via proxy (Nginx/Traefik) - Run with
gunicorn+ reverse proxy; collect static files if needed:
python manage.py collectstatic --noinput- Configure logging to stdout/stderr; aggregate with your platform (CloudWatch, ELK)
- Test strategy & coverage targets
- Known limitations / TODOs
- How to reproduce fixed bugs
- Architecture notes (settings, apps, URLs, templates)
You can keep these in /docs or extend this README.
Mathieu Vieillefont
LinkedIn: https://www.linkedin.com/in/mathieu-vieillefont/
Email: mathieu.vieillefont@gmail.com
Provided for educational purposes (OpenClassrooms). Add a license (e.g., MIT) if you plan to reuse.