1. legacy
Itinera API
  • ✈ Itinera API Documentation
  • Docs
    • legacy
      • Itinera — System Overview
      • Technology Stack & Architecture
      • Getting Started Guide
      • Infrastructure
      • Frontend Application
      • Architecture Overview
      • API Reference
      • Backend Services
      • Development Guidelines
    • phases
      • 01. Architecture Overview & Checkout Idempotency
      • Phase 2: Commerce & Checkout Engine
      • Phase 3: Webhooks & Asynchronous Fulfillment
      • Phase 4: Security Perimeter & Authentication
      • Phase 5: Database Schema & Entity Relationships
      • Phase 6: AI Quota & Telemetry Subsystems
      • Phase 7: API Route Matrix & FormRequests
      • Phase 8: Global Exception & Error Handling
      • Phase 9: Frontend Ecosystem & State Management
      • Phase 10: Design System & Component Library
      • Phase 11: Interactive GSAP Animations
      • Phase 12: Deployment & CI/CD Pipeline
      • Phase 13: Testing Strategies
      • Phase 14: Performance & Optimization
      • Phase 15: Developer Onboarding & Runbooks
      • 15-Phase Comprehensive Wiki & Documentation Plan
  • APIs
    • Auth
      • Register a new user
      • Log in a user
      • Log out user
      • Refresh JWT token
      • Forgot password request
      • Reset password verification
      • Get current user profile
      • Update user profile
      • Redirect to Google OAuth
      • Google OAuth Callback
      • Verify email via signed URL
    • Catalog
      • List all countries
      • Get country details
      • List all cities
      • List all regions
      • List all destinations
      • Get destination details
      • Get hotels by destination
      • List all hotels
      • Get hotel details
      • Get reviews for a hotel
      • List all flights
      • Get flight details
      • List all restaurants
      • Get restaurant details
      • List all attractions
      • Get current weather
      • Submit review for an entity
      • Delete review
      • Toggle favourite status for entity
      • List my submitted reviews
    • Bookings
      • Book a tour destination
    • V1 Aliases
      • V1 List all countries
      • V1 Get country details
      • V1 List all cities
      • V1 List all destinations
      • V1 Get destination details
      • V1 Get hotels by destination
      • V1 List all hotels
      • V1 Get hotel details
      • V1 Get reviews for a hotel
      • V1 List all flights
      • V1 Get flight details
      • V1 List all restaurants
      • V1 Get restaurant details
      • V1 List all attractions
      • V1 Get attraction details
      • V1 List all regions
      • V1 Get weather details
    • Trips
      • List user trips
      • Create a new trip
      • Get trip details
      • Update trip details
      • Delete a trip
      • Get creation metadata
      • Attach items to a trip
      • Update trip item
      • Detach items from a trip
      • Fork a trip
    • Conversations
      • List user conversations
      • Start a new conversation
      • Get conversation details
      • List messages in conversation
      • Send message to conversation
      • Mark conversation as read
    • Commerce Plans
      • List public plans
      • Get public plan details
    • Commerce Subscriptions
      • Subscribe to a plan
      • Upgrade active plan
      • Get active subscription info
      • Cancel active subscription
    • Commerce Checkout
      • Initiate Paymob payment checkout
    • Integrations
      • Paymob status webhook callback
      • Paymob redirect return callback
    • System Settings & Support
      • Submit public contact message
      • Subscribe to system newsletter
      • Get list of my reports
      • List all notifications
      • Mark single notification as read
      • List available surveys
      • Submit answers for survey
      • Get survey details
      • Update survey details
      • Delete survey response
    • AI Tools
      • Enhance itinerary details using AI
      • Request AI review of itinerary
      • Plan route using AI assistance
      • Get AI quota remaining details
      • Chat with AI Concierge assistant
      • Get AI Review progress by ID
    • Agency Integration
      • Request agency assignment
      • List agency active tasks
      • List agency managed trips
      • Get agency total earnings
      • Get agency profile details
      • Update agency profile details
    • Admin User Management
      • List users inside admin dashboard
      • Get user profile
      • Set user active status
      • Block user profile
    • Admin Catalog Moderation
      • Create new catalog category
      • Create new catalog destination
      • Create new hotel catalog record
      • Create new flight catalog record
      • Create new restaurant catalog record
      • Create new attraction catalog record
  • Schemas
    • User
    • ErrorResponse
    • Trip
    • Destination
    • Hotel
    • Flight
    • Restaurant
    • Attraction
    • Booking
    • Review
    • Agency
    • Survey
  1. legacy

Development Guidelines

Table of Contents#

1.
Ground Rules
2.
Backend Conventions
3.
Validation & Responses
4.
Authorization Checklist
5.
Testing Standards
6.
Frontend Conventions
7.
Git & CI Workflow
8.
Definition Of Done

Ground Rules#

1.
Spec before code for features spanning more than one module.
2.
Thin controllers: FormRequest in → Service call → Resource out. No Eloquent in controllers.
3.
Interfaces for anything swappable (gateways, repositories); bindings centralized in AppServiceProvider.
4.
Enums over magic strings — see app/Enums and app/Support/Enums (CheckoutType, OrderStatus, BudgetTier, …).
5.
Never write credentials into code or docs; everything flows through .env.

Backend Conventions#

Namespace mirrors domain: App\{Module}\... with modules Account / Catalog / Trips / Commerce / Chat / System.
Repositories implement app/Interfaces/<Module>/*RepositoryInterface; keep queries (filters, eager loads) there.
Domain state machines (orders, subscriptions, agency assignments) throw InvalidStateTransitionException instead of silent no-ops.
Side effects belong in listeners/jobs, not inline in services: payment fulfilment, mails, notifications, report generation.
Scheduled housekeeping lives as console commands under app/Console/Commands.

Validation & Responses#

One FormRequest per write action (StoreHotelRequest, InitiateCheckoutRequest, AiTripRequest, …) — reuse across alias routes rather than duplicating rules.
Always return API Resources; wrap envelopes with Support/ApiResponse; use Support/Constants/StatusCode for codes.
Error shape unified by ApiExceptionHandler (maps InvalidStateTransitionException, auth, throttle cases).

Authorization Checklist#

For every new route confirm:
Public by design? else auth:api
Needs verified email? add verified
Blocked users handled? EnsureUserIsActive
Permission string exists in RoleAndPermissionSeeder? add if missing + audit doc row
Fine-grained ownership? Policy (TripPolicy, ConversationPolicy, …)
Rate limiter for abuse-prone endpoints (weather/maps/AI/contact patterns)
Update docs/ROUTES-PERMISSIONS-AUDIT.md when the matrix changes.

Testing Standards#

Feature tests per capability area mirroring module dirs (tests/Feature/{Account,Catalog,Commerce,System,Trips}).
Name tests after behaviour (PaymentSensitiveDataTest, ForkAuthorizationTest, SubscriptionUniquenessTest) — read like a spec index.
Abuse/security cases are first-class: throttling, blocked users, mass-assignment, concurrency (ConcurrencyTest).
Run locally with php artisan test; CI enforces Pint style first.

Frontend Conventions#

One HTML page = one JS module; shared behaviour goes through js/common.js helpers (apiFetch, toasts, session guard).
No new frameworks/bundlers; ES5-safe syntax preferred for maximum browser reach.
Style with existing tokens/classes from css/common.css before adding new CSS.
Auth token key is canonical: itinera_token via window.Itinera.

Git & CI Workflow#

Branches: main, develop, feature branches; CI triggers on pushes to main/develop/community-hub and PRs into main/develop (ci.yml).
Commit style follows conventional commits (feat:, fix:, phase prefixes historically used).
Pint must pass (vendor/bin/pint --test) before PR merge.

Definition Of Done#

1.
Feature tests green locally and in CI.
2.
Routes added to audit matrix + Postman export refreshed (php artisan export:postman) when endpoints change.
3.
Scramble docs accurate (docblocks updated).
4.
No direct DB writes from controllers; side effects evented/queued.
5.
Frontend pages keyboard-reachable and functional without JS where core content is concerned.
Modified at 2026-08-25 22:41:45
Previous
Backend Services
Next
01. Architecture Overview &amp; Checkout Idempotency
Built with