# GEMINI.md - Context for AI Agents ## Project Overview **Name:** Trekking Packliste **Type:** PHP Web Application (Native) **Purpose:** A modern, web-based application for managing packing lists for hiking, trekking, and travel. It focuses on weight optimization, hierarchical packing (containers/nesting), and household collaboration. ## Architecture & Technology - **Backend:** Native PHP 8.2 (No framework). - **Frontend:** HTML5, CSS3 (Custom Theme), Bootstrap 5, Vanilla JavaScript. - **Database:** MariaDB / MySQL. - **Containerization:** Docker (Apache image). - **CI/CD:** Gitea Actions (`.gitea/workflows/build-push.yaml`). ## Directory Structure - `/src/`: Source code root. - `*.php`: Application logic and views. - `assets/`: CSS, JS, and static images. - `uploads/`: User-uploaded images (mounted volume in Docker). - `Dockerfile`: Defines the application environment. - `packliste.sql`: Database schema and initial data. - `.gitea/`: Gitea-specific configurations (workflows). ## Key Files - `src/db_connect.php`: Handles database connection. Prioritizes environment variables (`DB_HOST`, etc.) over `config.ini`. - `src/index.php`: Application dashboard. - `src/api_packing_list_handler.php`: AJAX handler for packing list operations. - `README.md`: Comprehensive documentation on features and usage. ## Database Schema (Key Tables) - `articles`: Inventory items (weight, category, image). - `backpacks`: Transport containers (weight, volume). - `backpack_compartments`: Sub-sections of backpacks (e.g., "Lid", "Main"). - `packing_lists`: The main lists. - `packing_list_items`: Link between lists and articles (supports nesting/hierarchy). - `users` & `households`: User management and sharing scope. ## Development & Deployment ### Local Development (Docker) 1. **Build:** `docker build -t packliste-app .` 2. **Run:** ```bash docker run -d \ -p 8080:80 \ -e DB_HOST="host.docker.internal" \ -e DB_USER="root" \ -e DB_PASSWORD="password" \ -e DB_NAME="packliste" \ -v $(pwd)/src/uploads:/var/www/html/uploads \ packliste-app ``` ### Manual Installation - Configure `config.ini` in the parent directory of the web root (or use env vars). - Import `packliste.sql` into the database. ### Conventions - **Code Style:** Native PHP, procedural/functional mix. - **Frontend:** Bootstrap 5 classes for layout. Custom CSS in `assets/css/style.css`. - **Database:** Use `mysqli` with prepared statements for security. - **Security:** Always validate user input. Passwords hashed with `password_hash()`. ## Core Features - **Weight Calculation:** Real-time summation of weights in lists. - **Households:** Shared inventory and lists between users. - **Drag & Drop:** `Sortable.js` used for organizing packing lists.