Skip to content

Phase 2: MVP Backend Development (4-6 Weeks)

Objective:
Develop a robust and scalable backend system that supports the core workflows of Whiskers and Wheels, including booking management, user authentication, payment processing, and notifications. This phase establishes the foundation for seamless communication between the backend and frontend, ensuring the MVP is both functional and scalable.


Goals

  1. Scalable Backend Architecture:
    Build a backend using Laravel that supports critical workflows, ensuring flexibility for future feature expansions.
  2. Relational Database Design:
    Create an optimized database schema to store and manage user, pet, ride, and transaction data securely and efficiently.
  3. RESTful API Development:
    Develop secure and modular APIs for user, booking, ride, and payment functionalities.
  4. Secure Payment Integration:
    Implement payment processing workflows with Stripe or PayPal for bookings and subscriptions.
  5. Automated Notification System:
    Build a notification system for real-time updates via SMS and email.

Deliverables

  1. Laravel Project Scaffold
  2. Initial Laravel setup with configured environment files (.env) for database, mail, and payment gateways.
  3. Version control integration with Git and a shared repository (e.g., GitHub or GitLab).
  4. Basic authentication system with user roles (Admin, Customer, Driver).

  5. Database Schema

  6. A relational database with tables for Users, Pets, Rides, Transactions, and Notifications.
  7. Relationships between tables (e.g., Users to Rides, Rides to Pets).
  8. Indexing for frequently queried columns to optimize performance.

  9. RESTful APIs

  10. Fully functional APIs for user registration, booking management, and ride status updates.
  11. Middleware for role-based access control and token authentication (e.g., JWT).

  12. Payment Integration

  13. Secure payment workflows via Stripe or PayPal with transaction logging.
  14. Support for one-time payments and pre-authorizations for bookings.

  15. Notification System

  16. SMS and email notification workflows for booking confirmations, reminders, and ride updates.
  17. Queue-based system to handle notifications asynchronously for scalability.

Tasks

1. Database Setup

Schema Design

  1. Users Table:
  2. id, name, email, password, role, phone_number, timestamps.
  3. Relationships: Admin, Customer, and Driver roles.

  4. Pets Table:

  5. id, user_id (FK), name, type, breed, age, special_needs, timestamps.
  6. Relationship: belongsTo user.

  7. Rides Table:

  8. id, user_id (FK), pet_id (FK), driver_id (nullable, FK), pickup_address, dropoff_address, status, scheduled_time, timestamps.
  9. Relationship: belongsTo user, pet, and driver.

  10. Transactions Table:

  11. id, ride_id (FK), amount, status, payment_method, timestamps.
  12. Relationship: belongsTo ride.

  13. Notifications Table:

  14. id, user_id (FK), ride_id (nullable, FK), type, message, status, timestamps.
  15. Notification types: SMS, Email.

Performance Optimization

  • Index columns frequently used for searching (email, status, scheduled_time).
  • Enforce foreign key constraints to maintain data integrity.

2. API Development

Core Endpoints

  1. User Management:
  2. POST /register: Register new users (role-specific fields validated).
  3. POST /login: Authenticate user and generate JWT.
  4. GET /profile: Retrieve authenticated user details.
  5. PUT /profile: Update user information (e.g., contact details).

  6. Booking Management:

  7. POST /bookings: Create a new booking with pickup/drop-off details and pet information.
  8. GET /bookings: Retrieve bookings for authenticated users with filters (e.g., status).
  9. GET /bookings/{id}: Retrieve booking details.
  10. PUT /bookings/{id}: Update booking (e.g., reschedule).
  11. DELETE /bookings/{id}: Cancel booking.

  12. Ride Status:

  13. GET /rides/assigned: Fetch all rides assigned to a driver.
  14. PUT /rides/{id}/status: Update ride status (e.g., In Progress, Completed).

Middleware

  • Implement JWT-based authentication.
  • Role-based permissions:
  • Customers: Access booking-related endpoints.
  • Admins: Manage all system entities (users, rides, payments).
  • Drivers: Update ride statuses and view assigned bookings.

3. Payment Integration

Stripe Workflow

  • Pre-Authorization: Capture payment details at booking creation.
  • Charge Processing: Automatically process payments after ride completion.
  • Refunds and Adjustments: Allow partial or full refunds as needed.

Endpoints

  • POST /payments: Process payments securely for bookings.
  • GET /payments/{id}: Retrieve payment details.

Security Measures

  • HTTPS encryption for all payment-related transactions.
  • Transaction logging for auditing and error tracking.

4. Notifications System

Implementation

  1. SMS Notifications:
  2. Integrate Twilio for real-time ride updates and confirmations.
  3. SMS triggers:

    • Booking confirmation.
    • Ride start and completion notifications.
  4. Email Notifications:

  5. Use Laravel Mail or third-party services like SendGrid.
  6. Email templates for receipts and booking reminders.

Queue Management

  • Use Laravel Queues for asynchronous notification processing.
  • Configure workers to handle notification jobs efficiently.

Outcomes of Phase 2

  1. Backend System: A robust backend capable of handling core workflows (user management, bookings, payments, notifications).
  2. Database Design: A secure and scalable database schema with optimized queries.
  3. API Readiness: Fully functional APIs ready for frontend and mobile app integration.
  4. Payment Workflow: Secure payment processing with support for refunds and pre-authorizations.
  5. Notifications: Automated, real-time communication via SMS and email.