Skip to content

ridhorobby50/restaurant-management

Repository files navigation

Restaurant Menu Management API Service

This is Service to handle Restaurant Menu Management Functionallity, This service made with Laravel 12

Tech Stack

This service is using Laravel 12 base on PHP as Rest API and MySQL as Database

Structure Class Design

  • Request : Focus on handle validation for every module/table
  • Resource : Focus on Formatting Output
  • Controller : Focus in Input Validation and Output
  • Service : Focus on logical process
  • Repository : Focus on integration with Model, like custom query, custom logical in model. something that related into database will focus in repository

Table Name Format

  • Table name have some format :

    • m_{table_name} for Master Table
    • mt_{table_name} for Master Transaction Table
    • trx_{table_name} for Transaction Table
  • But for this case, just showing mt_{table_name} and m_{table_name} to simplify the scope

Important Decision

  • Menu list still not grouped by category because there is not requested. But its possible and better if grouped by category. Right now to just make it simple to speed up development
  • Category is separated from menu table. Its because I think it will more controlled if its separated. Because it can reused for all menu in 1 restaurant. Category also have relation with Restaurant Table because i think all Restaurant have their own category of menu.
  • This service use Soft Delete to handle if we still need data as a statistic or something like historical or make some submission offering to that restaurant in the future

Setup Instruction

  1. Before installation is required to install this :
  • Composer
  • MySQL
  1. Duplicate .env.example and make adjustments in several parts especially database connections
DB_CONNECTION=mysql
DB_HOST={your_host}
DB_PORT={yout_port}
DB_DATABASE={your_db_name}
DB_USERNAME={your_db_username}
DB_PASSWORD={your_db_password}
  1. After that, please run :
composer install
  1. After that, please run :
php artisan migrate --seed
  1. After that, to make simple auth, we will use static API KEY, please run:
php artisan app:generate-api-key

it will generate static api key and add into .env

Running the Service

You can run this service with this command

php artisan serve

default port is 8000 If you need to custom the port you can add --port={your_port}

php artisan serve --port=8001

Testing Instruction

  • Before Doing a Test, please check or make adjustments in phpunit.xml to change DB_CONNECTION value into mysql, because this service using fulltext index that support in mySQL and not in SQLite, and make sure already make DB with name 'restaurant_management_test'
  • After make sure the phpunit.xml, please run:
php artisan test
  • That command will show some test and the result (passed / failed)

Additional Information

to make a sort in endpoint we can use this format

http://localhost:8000/api/restaurants?order=name // to sort by name asc
http://localhost:8000/api/restaurants?order=-name // to sort by name desc

and just some column will allowed used as a sort column (whitelist)

all endpoint exclude get, is required use x-api-key

  • please follow instruction in readme.md for how to make x-api-key, and copy paste the x-api-key into header in the request create, update, or delete
  • endpoint for get detail or get all still public endpoint

filtering endpoint available for get all restaurant / menu

  • page
  • limit
  • sort
  • keyword (for restaurant)
  • category (for menu)
  • example
http://localhost:8000/api/restaurants?keyword=pizza&page=1&limit=10&order=name
http://localhost:8000/api/restaurants/1/menu_items?category=dessert&page=1&limit=10&order=-name

About

Take-Home Assignment: Restaurant Menu Management API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages