Back to Projects

Overview & Business Rules

The Trekking Management App is built around a strict, enforceable set of operational rules rather than just basic CRUD dashboards. It maps the complete, secure lifecycle of a trekking business, separating workspaces for administrators, guides, and trekkers.

Key logical rules integrated at the core database level ensure that:

  • Available slots can never drop below zero or exceed a trek's maximum capacity.
  • Guides (Staff profiles) are locked from reassignment once their assigned trek goes underway.
  • Cancellations are preserved non-destructively for historic ledger logs.

Technical Deep Dive

Architecture & Codebase Stats

  • Application Factory Pattern: Built using create_app() with 5 independently registered Blueprints (auth, main, admin, staff, user) for a clean separation of concerns.
  • Relational DB Design: 4 core models (User, StaffProfile (1:1), Trek, Booking) with proper foreign keys, relationships, and cascade deletes.
  • Custom Decorator-Based RBAC: admin_required, staff_required, and user_required decorators gate authentication status, roles, account status, and staff approval status.
  • Auto-Seeding & Reset: seed.py generates realistic demo data (24 users, 10 staff, 18 treks across 7 states, proportional bookings) and reset.py wipes data while preserving the main Admin account.
  • Substantial Codebase: ~2,800 lines of Python and ~4,250 lines of Jinja2/HTML templates across 27 views.

Core Engineering Highlights

  • Transactional Slot Integrity: Bookings and cancellations occur within SQL transactions that update trek slot counts in real-time, preventing overbooking.
  • Trek Lifecycle State Machine: Tracks 7 states (Pending → Approved → Bookings Open → Bookings Closed → Ongoing → Completed, with a Cancelled branch) and locks staff reassignment once underway.
  • Layered Staff Approvals: Differentiates account status (Active/Blacklisted) from approval state (Pending/Approved/Rejected) to ensure only authorized guides can access dashboard tasks.
  • Cascading Rules on Blacklist: Blacklisting a staff member instantly flags their approval status as Rejected and auto-unassigns them from all non-terminal treks.
  • Non-Destructive Ledger: Bookings are never hard-deleted; cancellation states are preserved for historic accounting and audit logs.
  • Guarded Deletion: Treks with any booking history are locked from deletion entirely to protect transactional audit trails.
  • Multi-Field Relational Search: Platform-wide search/filter using SQLAlchemy ilike and or_ query operators, correctly scoped by user role.

Role-Based Workspaces

Admin Portal

  • System Overview Dashboard: Monitor real-time metrics including total treks, registered users, staff guides, and total bookings with quick links.
  • Trek Inventory CRUD: Create, view, search, edit, or delete trekking routes. Guide assignments are locked once treks are underway.
  • Guide & Staff Gateway: Manage guide application workflows, approve pending profiles, and execute blacklist actions.
  • User & Booking Audits: View registered trekkers and access a non-destructive ledger recording every transaction and payment state.
Admin Dashboard Overview

Staff (Guide) Dashboard

  • Trek Operations: View assigned upcoming expeditions and monitor live participant list counts.
  • Participant Roster: Log payment receipts, request participant cancellations, and view traveler health/experience notes.
  • Row-Level Access Controls: Guides can only access and modify expeditions assigned to their specific profiles.
Guide Dashboard

User (Trekker) Workspace

  • Expedition Search: Search and filter available treks by location, difficulty level, cost, and date range.
  • Transaction-Safe Booking: Book spots in real-time with automatic double-booking blocks and maximum slot capacity guards.
  • Trip Ledgers: Monitor upcoming itineraries, download receipt statements, and process trip cancellations.
Trekker Dashboard Overview
// skills showcased

Key Technologies & Engineering Skills

Python Flask (App Factory) SQLAlchemy ORM RBAC (Role-Based Security) SQL Transactions State Machines Jinja2 Templating Bootstrap 5 & Icons Relational DB Design (SQLite)