The API for the website
Find a file
2026-03-25 22:04:57 +01:00
app Initial Deployment 2026-03-25 22:04:57 +01:00
controller Initial Deployment 2026-03-25 22:04:57 +01:00
docs Initial Deployment 2026-03-25 22:04:57 +01:00
integration Initial Deployment 2026-03-25 22:04:57 +01:00
mapper Initial Deployment 2026-03-25 22:04:57 +01:00
repository Initial Deployment 2026-03-25 22:04:57 +01:00
service Initial Deployment 2026-03-25 22:04:57 +01:00
tests Initial Deployment 2026-03-25 22:04:57 +01:00
.dockerignore Initial Deployment 2026-03-25 22:04:57 +01:00
.env Initial Deployment 2026-03-25 22:04:57 +01:00
.env.example Initial Deployment 2026-03-25 22:04:57 +01:00
AGENTS.md Initial Deployment 2026-03-25 22:04:57 +01:00
database.sql Initial Deployment 2026-03-25 22:04:57 +01:00
docker-compose.yml Initial Deployment 2026-03-25 22:04:57 +01:00
Dockerfile Initial Deployment 2026-03-25 22:04:57 +01:00
ERROR_CODES.md Initial Deployment 2026-03-25 22:04:57 +01:00
README.md first commit 2026-03-25 22:04:38 +01:00
requirements.txt Initial Deployment 2026-03-25 22:04:57 +01:00
run.bat Initial Deployment 2026-03-25 22:04:57 +01:00
TODO.md Initial Deployment 2026-03-25 22:04:57 +01:00

Motorsport Moments API

FastAPI project met PostgreSQL (extern) en Docker.

Structuur

  • repository/: data access functies
  • service/: business logica en orkestratie
  • controller/: API endpoints
  • mapper/: response mapping
  • app/: app bootstrap, database dependency, schemas

Starten met Docker

docker compose up --build

API beschikbaar op http://localhost:8000.

Lokaal Starten (1 klik)

Start alleen:

run.bat

run.bat doet automatisch:

  • .venv aanmaken (indien nodig)
  • dependencies installeren
  • environment defaults zetten
  • Uvicorn starten op http://localhost:8000

Voor eigen settings kun je een .env maken op basis van .env.example.

Belangrijke endpoints

  • GET /health
  • GET /users (admin role vereist)
  • POST /users
  • GET /users/me (ingelogde gebruiker)
  • GET /admin/ping (admin role vereist)

JWT authenticatie

JWT wordt verwacht via de Authorization header:

Authorization: Bearer <token>

Token claims die gebruikt worden:

  • sub: gebruiker identificatie
  • email: gebruiker e-mail (optioneel)
  • roles: array met rollen, bijvoorbeeld ["admin", "organizer"]

Configuratie via environment variables:

  • JWT_SECRET_KEY (standaard: change-me)
  • JWT_ALGORITHM (standaard: HS256)
  • JWT_AUDIENCE (optioneel)
  • JWT_ISSUER (optioneel)

Voorbeeld payload:

{
  "sub": "7c5b9f20-c911-4f18-9a7d-7a8dcf17aaf2",
  "email": "admin@example.com",
  "roles": ["admin"]
}

Voorbeeld body POST /users:

{
  "email": "max@example.com",
  "password_hash": "securehash123",
  "given_name": "Max",
  "family_name": "Verstappen"
}

#<23> <20>m<EFBFBD>o<EFBFBD>t<EFBFBD>o<EFBFBD>r<EFBFBD>s<EFBFBD>p<EFBFBD>o<EFBFBD>r<EFBFBD>t<EFBFBD>M<EFBFBD>o<EFBFBD>m<EFBFBD>e<EFBFBD>n<EFBFBD>t<EFBFBD>s<EFBFBD>A<EFBFBD>p<EFBFBD>i<EFBFBD> <0A> <0A>