Compare commits

..

11 Commits

Author SHA1 Message Date
WGAVermeer
255cb9bc2f cleanup moving from windows to linux.
All checks were successful
Gitea Test. / tests (push) Successful in 12s
2026-04-10 18:27:35 +02:00
WGAVermeer
d8800daba3 created base gallery app, made start on documentation.
Some checks failed
Gitea Test. / tests (push) Has been cancelled
2026-04-09 10:35:28 +02:00
WGAVermeer
5fd943db85 cleaned up dockerfile, removed useless expose as the port is configured in the compose.yaml file. Moved standard ENV into buildfile as they should always be executed no matter the compose variant executed. 2026-04-09 10:34:37 +02:00
WGAVermeer
00db9182d9 added admindocs for automatic documentation. 2026-04-09 10:32:38 +02:00
WGAVermeer
3f52db35c2 added requirements for enforced linting. 2026-04-09 10:31:43 +02:00
WGAVermeer
16c1913e69 hardened makefile by referencing 'web' container as it is specified in the docker compose file. 2026-04-09 10:31:01 +02:00
WGAVermeer
5490593b94 added database healthcheck, removed old test profile, implemented network segregation for containers. 2026-04-09 10:29:53 +02:00
c4785455eb Merge pull request 'woutervermeer-patch-1' (#20) from woutervermeer-patch-1 into pre-prod
All checks were successful
Gitea Test. / tests (push) Successful in 6s
Reviewed-on: #20
2026-03-28 11:33:25 +00:00
b463e5b18b Merge branch 'pre-prod' into woutervermeer-patch-1
All checks were successful
Gitea Test. / tests (pull_request) Successful in 6s
2026-03-28 11:32:49 +00:00
74ee2f1965 Delete .gitea/workflows/build_test.yaml
All checks were successful
Gitea Test. / tests (pull_request) Successful in 6s
2026-03-26 10:12:42 +00:00
048828f2d2 Update .gitea/workflows/test.yaml 2026-03-26 10:12:10 +00:00
18 changed files with 307 additions and 44 deletions

View File

@@ -1,20 +0,0 @@
name: Gitea build & Test.
run-name: ${{ gitea.actor }}
on:
push:
branches:
- main
pull_request:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and test
run: make test
- name: Build
run: make prod

View File

@@ -3,6 +3,7 @@ run-name: ${{ gitea.actor }}
on:
push:
branches:
- main
- pre-prod
pull_request:

View File

@@ -1,15 +1,15 @@
FROM python:3.14-alpine
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
WORKDIR /src
COPY requirements.txt /src/
COPY gunicorn.conf.py /src/
COPY ./src/ /src/
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
EXPOSE 8000
COPY gunicorn.conf.py /src/
COPY ./src/ /src/
CMD ["gunicorn", "website.wsgi:application"]

View File

@@ -1,20 +1,22 @@
.SHELLFLAGS := -ec
prod:
docker compose down
docker compose --env-file .env -f ./compose.yaml -f ./.docker-compose-files/compose.prod.yaml up -d --build
docker exec quatsh-website-web-1 python manage.py collectstatic --noinput
docker exec quatsh-website-web-1 python manage.py check --deploy
docker exec quatsh-website-web-1 python manage.py migrate
docker compose exec web python manage.py collectstatic --noinput
docker compose exec web python manage.py check --deploy
docker compose exec web python manage.py migrate
dev:
docker compose down
docker compose -f ./compose.yaml -f ./.docker-compose-files/compose.dev.yaml up --build -d
docker exec quatsh-website-web-1 python manage.py collectstatic --noinput
docker exec -it quatsh-website-web-1 sh
docker compose exec web python manage.py collectstatic --noinput
docker compose exec -it web sh
dev_restart:
docker compose down
docker compose -f ./compose.yaml -f ./.docker-compose-files/compose.dev.yaml up -d
docker exec -it quatsh-website-web-1 sh
docker compose exec -it web sh
dev_restart_with_logs:
docker compose down

View File

@@ -3,11 +3,11 @@ services:
build: .
command: gunicorn website.wsgi:application
depends_on:
- db
db:
condition: service_healthy
environment:
ALLOWED_HOSTS: ${NGINX_HOSTNAME}
PYTHONDONTWRITEBYTECODE: 1
PYTHONUNBUFFERED: 1
DJANGO_SETTINGS_MODULE: ${DJANGO_SETTINGS_MODULE}
VIRTUAL_HOST: localhost
#VIRTUAL_PORT: 8000
@@ -15,6 +15,9 @@ services:
volumes:
- static_volume:/app/static
- media_volume:/app/media
networks:
- frontend
- backend
db:
@@ -26,6 +29,12 @@ services:
volumes:
- postgres_data:/var/lib/postgresql
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DBNAME}"]
interval: 5s
retries: 5
networks:
- backend
adminer:
image: adminer
@@ -33,7 +42,9 @@ services:
- db
restart: always
ports:
- 8080:8080
- 127.0.0.1:8080:8080
networks:
- backend
proxy:
image: nginx:stable
@@ -51,15 +62,12 @@ services:
- NGINX_SSL_PORT=443
depends_on:
- web
networks:
- frontend
test:
build: .
command: python manage.py test
depends_on:
- db
profiles:
- test
networks:
frontend:
backend:
volumes:
postgres_data:

View File

@@ -0,0 +1,177 @@
# Architectural Decision Records
This document records the major architectural decisions made during the development of the Quatsh website, including the context and reasoning behind each choice. Future maintainers should add to this document when making significant architectural decisions.
---
## ADR-001 — Move away from WordPress
**Date:** 2026
**Status:** Decided
### Context
The previous Quatsh website was built on WordPress, hosted on a shared webhosting service (cloud86). Over time, development had ground to a halt due to several compounding problems:
- WordPress stores page content in a serialised format inside a database, making it difficult to version control, diff, or reason about changes.
- The site relied heavily on third-party plugins, creating a fragile dependency chain where updating one plugin risked breaking others.
- PHP and the WordPress ecosystem were unfamiliar to the association's technically-minded members, narrowing the pool of people who could contribute.
- The shared webhosting service was more expensive and less flexible than a VPS for a project of this nature.
- The page-stucture made DRY development difficult leading to a lot of code duplication across different pages.
- Direct database access using Raw-SQL made it easy to make mistakes.
### Decision
Replace the WordPress site with a purpose-built web application on a VPS.
### Consequences
- Full control over the codebase, dependencies, and infrastructure.
- Performance issues can actually be debugged and fixed.
- Higher initial setup cost in developer time, offset by lower long-term maintenance friction and cheaper hosting.
- The association is no longer dependent on a third-party hosting provider's ecosystem.
---
## ADR-002 — Django as the web framework
**Date:** 2026
**Status:** Decided
### Context
Having decided to build a custom web application, a framework and language needed to be chosen. The primary constraints were:
- **Maintainability over time** — the project will be handed off to future developers. The current maintainer will only be a member for a limited number of years.
- **Familiarity within the target contributor pool** — a student sports association at a university. New contributors are likely to be students.
- **Batteries included** — the association does not have the capacity to assemble and maintain a bespoke stack of micro-libraries.
### Decision
Use Django with Python as the primary framework and language.
### Reasoning
- Python is the most commonly taught language at Dutch universities, maximising the pool of potential future contributors.
- Django is "batteries included" — authentication, admin interface, ORM, migrations, form handling, and email are all built in. This reduces the number of third-party dependencies and the surface area a new maintainer needs to learn.
- A single Django repository centralises the entire codebase (backend, templates, static files, configuration) making handoff to future maintainers straightforward.
- The Django admin interface provides board members with basic data management capabilities without requiring a custom-built admin panel from scratch.
### Alternatives considered
- **Flask / FastAPI** — too minimal; would require assembling many additional libraries, increasing long-term maintenance burden.
- **Node.js** — less common in the university curriculum than Python; splits frontend and backend concerns in a way that adds complexity for a small team.
- **Laravel (PHP)** — would have kept the PHP ecosystem from WordPress, but PHP is less familiar to the target contributor pool and does not solve the maintainability problem.
### Consequences
- New contributors with basic Python knowledge can get up to speed quickly.
- The project is well-positioned for handoff to future maintainers.
- Django's monolithic nature means the entire application is in one place, which is appropriate for a project of this scale.
---
## ADR-003 — Gunicorn + nginx as the serving stack
**Date:** 2026
**Status:** Decided
### Context
Django's built-in development server is not suitable for production. A production-grade serving stack was needed.
### Decision
Use Gunicorn as the WSGI application server behind nginx acting as a reverse proxy and static file server.
### Reasoning
- Gunicorn is the standard WSGI server for Django in production and is well documented alongside Django.
- nginx is significantly more efficient than Django/Gunicorn at serving static files and handling slow clients.
- nginx handles SSL termination, keeping TLS configuration out of the application layer.
- This is the most common Django deployment pattern, meaning future maintainers are likely to be familiar with it or find documentation easily.
### Consequences
- Static files must be collected via `manage.py collectstatic` before deployment (handled in the Makefile).
- nginx and the Django container share a read-only/read-write volume respectively for static and media files.
---
## ADR-004 — Docker Compose for container orchestration
**Date:** 2026
**Status:** Decided
### Context
The application consists of multiple services (Django, nginx, Postgres) that need to run together consistently across development and production environments.
### Decision
Use Docker with Docker Compose for local development and production deployment, with separate compose override files per environment.
### Reasoning
- Docker ensures the application runs identically regardless of the host machine, reducing "works on my machine" issues during handoff.
- Docker is an easier way of getting the full stack operational on a new contributors machine compared to making them do multiple different installs.
- Docker Compose is simple enough for a non-specialist maintainer to understand and operate.
- Separate override files (`compose.dev.yaml`, `compose.prod.yaml`, `compose.test.yaml`) allow environment-specific configuration without duplicating the base service definitions.
- A VPS with Docker is significantly cheaper than a managed hosting service while providing more control.
### Consequences
- New maintainers need minimal Docker literacy, but this is a reasonable baseline expectation.
- The Makefile wraps common Docker Compose commands to reduce the surface area a maintainer needs to know day-to-day.
- Data persistence is handled via named Docker volumes.
---
## ADR-005 — PostgreSQL as the database
**Date:** 2026
**Status:** Decided
### Context
Django supports multiple database backends. A production database needed to be chosen.
### Decision
Use PostgreSQL 18.
### Reasoning
- PostgreSQL is the recommended database for Django in production.
- It is robust, well-documented, and widely understood.
### Consequences
- The Postgres Docker volume must be mounted at `/var/lib/postgresql` (not `/data`) when using the official `postgres:18` image. See the note in `compose.yaml`.
---
## ADR-006 — PEP8 as style guide
**Date:** 2026/04/08
**Status:** Decided
### Context
Styleguides are used to ensure the long-term maintainability and readability of a codebase.
### Decision
Use PEP8 as the style guide with enforced type hinting. Enforced using 'ruff' and 'MyPy'.
### Reasoning
- PEP8 is the standard style guide for python development. It has great tooling to ensure enforcement of the style guide.
- Type hinting greatly improves the readability of code as you are better able to reason. It also helps keep variable names short as "picture_array" is instead written as "pictures: Sequence".
### Consequences
Linting checks have to integrated into the CI/CD pipeline.
'Contributing.md' needs to be created to make it clear how to contribute.
---
*When making a new architectural decision, copy the template below and append it to this file.*
---
## ADR-00X — [Title]
**Date:**
**Status:** Proposed / Decided / Superseded by ADR-00X
### Context
<!-- What is the situation that requires a decision? What constraints exist? -->
### Decision
<!-- What was decided? -->
### Reasoning
<!-- Why was this the right choice given the context? -->
### Alternatives considered
<!-- What else was evaluated and why was it not chosen? -->
### Consequences
<!-- What are the implications of this decision, positive and negative? -->

72
docs/templates/template.md vendored Normal file
View File

@@ -0,0 +1,72 @@
# Feature Name
> One sentence description of what this feature does and who it is for.
## Status
<!-- Delete all that do not apply -->
`Planned` `In Progress` `In Review` `Complete` `Deferred`
## Background
<!-- Why are we building this? What problem does it solve? Link to any relevant roadmap phase. -->
## Scope
<!-- What is included in this feature. Be explicit about what is out of scope too. -->
**In scope:**
-
**Out of scope:**
-
## User Stories
<!-- Who interacts with this feature and what do they want to achieve? -->
- As a **[member / board member / anonymous visitor]**, I want to **[action]** so that **[outcome]**.
## Data Model
<!-- What models are created or modified? List fields and their types. -->
```python
class ExampleModel(models.Model):
pass
```
**Related models:**
- `User`
## GDPR Considerations
<!-- See docs/gdpr/ for shared policies. Only document what is specific to this feature. -->
| Question | Answer |
|---|---|
| Personal data collected | |
| Legal basis | Legitimate interest / Consent / Legal obligation |
| Retention period | See `docs/gdpr/retention-policy.md` / [custom policy] |
| Erasure behaviour | Cascade delete / Anonymise / Transfer ownership |
| Visible to non-members | Yes / No |
## Open Questions
<!-- Unresolved decisions that are blocking or will affect implementation. -->
- [ ]
## Decisions Log
<!-- Record decisions made during development so future contributors understand why things are the way they are. -->
| Date | Decision | Reasoning |
|---|---|---|
| YYYY-MM-DD | | |
## Tasks
<!-- Break the feature down into concrete implementation steps. -->
### Backend
- [ ]
### Frontend
- [ ]
### Tests
- [ ]
## Related
<!-- Links to related feature files, external docs, or GitHub issues. -->
-

View File

@@ -3,3 +3,7 @@ gunicorn==25.1.0
psycopg [binary] ==3.3.3
django-browser-reload
django-watchfiles
docutils==0.22.4
ruff==0.15.9
Mypy==1.20
django-stubs==5.0.2

0
src/gallery/__init__.py Normal file
View File

3
src/gallery/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
src/gallery/apps.py Normal file
View File

@@ -0,0 +1,5 @@
from django.apps import AppConfig
class GalleryConfig(AppConfig):
name = 'gallery'

View File

3
src/gallery/models.py Normal file
View File

@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
src/gallery/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
src/gallery/views.py Normal file
View File

@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View File

@@ -40,6 +40,7 @@ INSTALLED_APPS = [
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.admindocs",
"django_browser_reload",
"django_watchfiles",
]

View File

@@ -19,7 +19,8 @@ from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("__reload__/", include("django_browser_reload.urls")),
path("polls/", include("polls.urls")),
path("admin/doc/", include("django.contrib.admindocs.urls")),
path("admin/", admin.site.urls),
path("__reload__/", include("django_browser_reload.urls")),
]