The API is minimal and simple on purpose to focus on the main task, refer to the endpoints section for more details.
Consider to checkout the todos section.
- PHP 8.2.6
- Composer 2.5.5
- Postgres 14.7
git clone https://github.com/omarabdelaz1z/bus-booking
cd bus-booking
composer install
- Copy the
.env.example
file to.env
and update the database credentials. - Generate the application key.
cp .env.example .env
php artisan key:generate
- Run the database migrations.
- Or use the dump file schema.sql to import the database.
php artisan migrate --seed
php artisan serve
php artisan test
Method | Endpoint | Token | Description | Payload |
---|---|---|---|---|
POST | /api/auth/login | Login | {email, password} |
|
POST | /api/auth/register | Register | {name, email, password} |
|
DELETE | /api/auth/logout | Yes | Logout | |
GET | /api/me | Yes | Get current user info | |
GET | /api/trips/{id}?source=&destination | Yes | List available trips | |
POST | /api/users/{id}/bookings | Yes | Book a trip | {trip, seat, source, destination} |
I used ERDPlus to design the database schema.
User Roles and Permissions.
- Since the API is minimal, I didn't implement roles and permissions.
Partial Overlap Constraints
- The algorithm fails when the requested trip is part of the booked entries not the other way around.
Dockerize The App
- I know what docker is in general but I didn't have the time to explore it and implement it.