Skip to content

KiOui/TOSTI

Repository files navigation

TOSTI - Tartarus Order System for Take-away Items

Docker Image CI Linting Testing License: MIT

TOSTI is a comprehensive web application designed for Tartarus to manage take-away orders and various other features for student associations at Radboud University.

πŸš€ Features

Core Features

  • Order Management System: Online ordering system for take-away items (such as tostis)
  • Financial Transactions: User balance tracking and transaction management
  • User Authentication: SAML-based SSO integration (with Radboud University via SURFconext)
  • Music Control: Spotify and Marietje integration for controlling music players
  • Room Reservations: Venue reservation system with calendar integration
  • Borrel Management: Event reservation system with inventory tracking
  • Age Verification: Yivi-based age verification system
  • Smart Fridge Access: Digital lock system for automated fridge access, using TOSTI-fridge-client
  • QR Code Identification: Token-based user identification system
  • Bookkeeping Integration: Synchronization with Silvasoft accounting system

Additional Features

  • Multi-venue support with separate canteens (North/South)
  • Real-time order status tracking
  • Statistics and analytics dashboard
  • OAuth2 API for third-party integrations
  • iCal feeds for reservations
  • Automated music scheduling

πŸ—οΈ Architecture

TOSTI is built using:

  • Backend: Django 5.1 (Python)
  • Frontend: Django templates with Bootstrap 5
  • Database: PostgreSQL (production) / SQLite (development)
  • Caching: File-based cache (production) / In-memory (development)
  • Authentication: SAML2 (via djangosaml2)
  • API: Django REST Framework with OAuth2
  • Task Scheduling: Custom cron implementation
  • Containerization: Docker & Docker Compose

πŸ“ Project Structure

website/
β”œβ”€β”€ age/                    # Age verification module
β”œβ”€β”€ announcements/          # System announcements
β”œβ”€β”€ associations/           # Student associations management
β”œβ”€β”€ borrel/                 # Event/borrel reservation system
β”œβ”€β”€ cron/                   # Custom cron job implementation
β”œβ”€β”€ fridges/                # Smart fridge access control
β”œβ”€β”€ orders/                 # Core ordering system
β”œβ”€β”€ qualifications/         # User qualifications (e.g., borrel brevet)
β”œβ”€β”€ silvasoft/              # Bookkeeping integration
β”œβ”€β”€ status_screen/          # Order status display
β”œβ”€β”€ thaliedje/              # Music player control
β”œβ”€β”€ tosti/                  # Main application settings
β”œβ”€β”€ transactions/           # Financial transactions
β”œβ”€β”€ users/                  # User management
β”œβ”€β”€ venues/                 # Venue reservation system
└── yivi/                   # Yivi integration for age verification

πŸ› οΈ Development Setup

Prerequisites

  • Python 3.13+ (recommended to use pyenv)
  • Poetry for dependency management
  • Git

Installation

  1. Clone the repository

    git clone https://github.com/KiOui/TOSTI.git
    cd TOSTI
  2. Install Poetry

    curl -sSL https://install.python-poetry.org | python3 -
  3. Set up Python environment

    poetry env use python3.13
    poetry install
  4. Activate virtual environment

    poetry shell
  5. Set up the database

    cd website
    ./manage.py migrate
  6. Create a superuser

    ./manage.py createsuperuser
  7. Load initial data (optional)

    ./manage.py loaddata tosti/fixtures/default.json
  8. Run the development server

    ./manage.py runserver

The application will be available at http://localhost:8000.

Development Notes

  • SAML authentication is disabled in development mode
  • Use /admin-login in production for local authentication
  • API documentation is available at /api/docs

🐳 Production Deployment

TOSTI is deployed using Docker and Docker Compose in the PGO environment at CNCZ (Radboud University IT department).

Docker Deployment

  1. Build and run with Docker Compose

    docker-compose up -d
  2. Environment Variables Create a .env file based on .env.example:

    YIVI_SERVER_TOKEN=your-yivi-token
    POSTGRES_PASSWORD=secure-password
    DJANGO_SECRET_KEY=your-secret-key
    SENTRY_DSN=your-sentry-dsn
    # ... other variables

PGO Deployment

For deployment on the CNCZ infrastructure:

# Deploy the application
pgoctl -i ~/.ssh/id_ed25519 -- dockervm02.science.ru.nl:tosti//up

# View logs
pgoctl -i ~/.ssh/id_ed25519 -- dockervm02.science.ru.nl:tosti//logs

# Stop the application
pgoctl -i ~/.ssh/id_ed25519 -- dockervm02.science.ru.nl:tosti//down

Note: You must be connected to the CNCZ VPN and have your SSH key in the ssh directory.

πŸ”§ Configuration

Specific configuration is managed through Django Constance for runtime settings:

  • General: Footer text, cleaning scheme URL
  • Email: Notification recipients for reservations
  • Shifts: Default maximum orders per shift
  • Music (Thaliedje): Start/stop times, holiday mode
  • Silvasoft: API credentials for bookkeeping
  • Fridges: Daily opening requirements

πŸ“‘ API

TOSTI provides a RESTful API with OAuth2 authentication.

Available Scopes

  • read: Read access to the API
  • write: Write access to the API
  • orders:order: Place orders
  • orders:manage: Manage all orders
  • thaliedje:request: Request songs
  • thaliedje:manage: Control music players
  • transactions:write: Create transactions

API Documentation

Interactive API documentation is available at /api/docs when running the application.

πŸ§ͺ Testing

Run the test suite:

cd website
poetry run python manage.py test

Run with coverage:

poetry run coverage run website/manage.py test website/
poetry run coverage report

πŸ” Code Quality

Linting

poetry run black website
poetry run flake8 website
poetry run pydocstyle website

Checks

The project uses GitHub Actions for automated testing and linting on every push.

🀝 Contributing

Contributions are welcome!

Development Workflow

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and linting
  5. Submit a pull request

Code Style

  • Follow PEP 8
  • Use Black for formatting
  • Write docstrings for all functions
  • Maximum line length: 119 characters

πŸ“§ Contact

πŸ”’ Security

For security vulnerabilities, please email [email protected] instead of creating a public issue.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Original developers: Lars van Rhijn, Job Doesburg
  • All contributors who have helped improve TOSTI
    • CNCZ for hosting infrastructure