- Sjenk - Booking System Specification
Name: Sjenk Description: A web-based booking system for managing time slots at various locations (e.g., football fields, gyms). Technology Stack:
-
Backend: FastAPI (Python)
-
Database: SQLite
-
Frontend: Jinja2 (server-rendered) or JavaScript (dynamic frontend)
-
Authentication: OAuth2 with JWT (JSON Web Tokens) or session-based authentication
-
Hosting:
- Frontend: Raspberry Pi
- Backend: Raspberry Pi
- Database: SQLite on Raspberry Pi
sjenk/
├── backend/ # FastAPI backend
│ ├── app/ # FastAPI app
│ ├── db/ # SQLite database
│ ├── tests/ # Unit tests
│ └── main.py # Main FastAPI app
├── frontend/ # Frontend (Jinja2/JS)
│ ├── static/ # Static files (CSS, JS)
│ ├── templates/ # Jinja2 templates
│ └── main.py # Main Flask app
└── README.md # Project overview
Branching strategy: main (production), staging (testing), dev (development), feature/* (feature branches)
graph TD
A[main] --> B[staging]
B --> C[dev]
C --> D[feature/1]
C --> E[feature/2]
| Column | Type | Description |
|---|---|---|
id |
PK, int, autoincrement | Unique user ID |
username |
str, unique | Username |
password_hash |
str | Hashed password |
role |
enum(admin, leader, organizer, user) |
User role |
| Column | Type | Description |
|---|---|---|
id |
PK, int, autoincrement | Unique place ID |
name |
str, unique | Name of the place (e.g., "Football Field") |
allow_partial_booking |
bool | Whether partial booking is allowed |
| Column | Type | Description |
|---|---|---|
id |
PK, int, autoincrement | Unique booking ID |
user_id |
FK, int, references users.id |
User who made the booking |
place_id |
FK, int, references places.id |
The booked location |
start_time |
datetime | Start time |
end_time |
datetime | End time |
booked_area |
enum(full, half, quarter) |
Amount of space booked |
status |
enum(confirmed, pending, canceled) |
Booking status |
erDiagram
USERS {
int id
string username
string password_hash
enum role
}
PLACES {
int id
string name
bool allow_partial_booking
}
BOOKINGS {
int id
int user_id
int place_id
datetime start_time
datetime end_time
enum booked_area
enum status
}
USERS ||--o{ BOOKINGS : "made"
PLACES ||--o{ BOOKINGS : "booked"
- If full field is booked → No other bookings allowed
- If half field is booked → Only the other half or two quarters can be booked
- If quarter field is booked → Three other quarters can still be booked
| Method | Endpoint | Description | Access |
|---|---|---|---|
| POST | /auth/login |
Returns JWT token or sets session | All |
| POST | /auth/register |
Registers a new user (admin only) | Admin |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| GET | /places |
Fetch list of places | All |
| POST | /places |
Create a new place | Admin |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| GET | /bookings |
Fetch all bookings | All |
| POST | /bookings |
Create a new booking (validates availability) | Organizer, Leader, Admin |
| DELETE | /bookings/{id} |
Delete a booking | Leader, Admin |
| PATCH | /bookings/{id} |
Modify (override) a booking | Leader, Admin |
- Backend serves HTML templates using Jinja2
- AJAX with JavaScript for dynamic updates
Pages:
index.html→ Overview of placeslogin.html→ Login pagedashboard.html→ User dashboard
- Frontend built with Vanilla JS / React / Vue
- Communication via REST API (fetch/Axios)
- JWT-based authentication
- Role logs in (JWT/session)
- Role selects location to interact with
- Role views bookings for the selected location
- Role creates a booking (if allowed)
- Role modifies/deletes a booking (if allowed)
- Administrator manages users, places, and bookings
- Conflict management ensures no overlapping bookings
- Role logs out
This document serves as the technical specification for the Sjenk booking system.