The coding challenge requires the development of a Laravel backend and a Vue.js frontend for a tour booking system. The task involves creating a RESTful API with CRUD operations, consuming those APIs on the frontend, and ensuring proper state management and authentication.
As a user, you should be able to:
- View Available Tours: See a list of tours with destinations, pricing, and descriptions.
- Book a Tour: Select a tour and book it.
- Generate a Ticket: After booking, generate and view the ticket.
As an admin, you should be able to:
- Create Tours: Add new tours with available slots, pricing, descriptions, and destinations.
- View All Bookings: Access a list of all bookings made by users.
- View All Tickets: Access all tickets generated from bookings.
Clone the project
git clone https://github.com/vamuigua/tours_booking_app.git
Go to the project directory
cd tours_booking_app
From here you will see two folders: backend
and frontend
.The backend
is the laravel app that servers the APIs to thefrontend
which is a Vue JS application.
We shall first install and configure the backend then afterwards the frontend:
Go to the backend
directory
cd backend
Install dependencies
composer install
Change directory permissison
chmod -R 777 storage bootstrap/cache
Create an .env
file
touch .env
cp .env.example .env
Update the following environment variables in the .env
file:
APP_URL=http://localhost:8000
FRONTEND_URL=http://localhost:5173
SESSION_DOMAIN=localhost
SANCTUM_STATEFUL_DOMAINS=localhost:5173
Generate an Application Key
php artisan key:generate
Migrate the Database
PS: Ensure you have created a database e.g tours_booking_app
before running the migrate command
php artisan migrate
Start the app by running the server
php artisan serve
The backend
app will be served on the URL http://localhost:8000/
Now we can move to configuring the frontend
Go to the frontend
directory
cd frontend
Install dependencies
npm install
Create an .env
file
touch .env
Add the following environment variable in the .env
file:
VITE_BASE_URL=http://localhost:5173/
VITE_TOURS_BOOKING_BACKEND_API=http://localhost:8000
http://localhost:8000 is the URL serving the laravel application.
Start the app server
npm run dev
The frontend
app will be served on the URL http://localhost:5173/
✅ Start using Tours Booking app: Once the app is running, you can start by creating an account by visiting the registration page and explore the app's features.
Some of the APIs you can find include:
POST api/v1/login
Parameter | Type | Description |
---|---|---|
email |
email |
Required. |
password |
string |
Required. |
remember |
bool |
Determines whether the Token will expire at a defined time or not. |
GET api/v1/tours
Authorization | Type | Description |
---|---|---|
Bearer Token |
string |
Required. |