- Create a new Book
- Read existing Books
- Update an existing Book
- Delete an existing Book
- Author (mandatory)
- Title (mandatory)
- ISBN (mandatory)
- Release Date
- Code must be covered with unit tests
- Clean, easy to understand and maintainable
- Be RESTful
- Validate inputs
- Avoid using frameworks (e.g. Laravel, Sprint Boot) -- we’d like to see all code written from the ground up to understand your abilities regardless of a framework
- Endpoints covered with system/functional tests
- API documented (OpenAPI)
- Dockerize your application, i.e. besides the GitHub code repo please also host it and give us a demo link [you can use a trial account of AWS/GCP/Azure to do this]
- You could choose to do this test preferably in NodeJS, 2nd preference Golang, or if neither is possible go with PHP.
- Provide a code you can be proud of, something that fully reflects your knowledge of development, unit testing, DevOps, scalability and security.
- We are not curious about if you know how to use existing frameworks, but we’d like to assess your real coding skills. If you feel the task takes too much time, implement only a part of it (like one or two endpoints only), but what you implement should meet every requirement from the must have list above.
-
Validation to stop multiple books of same isbn (done to database alone)
-
Remove Database credentials in version control
-
Make release date nullable on validation and DB schema
-
Create a setup guide
-
Explain thought process
-
Mention design patterns used across the application and links
-
How to execute test effectively
-
Make Database use test connection while testing
-
Add php.xml.dist configuration settings
The entire application is built around the MVC design pattern (partially, as the model class is missing in this context), the request first hits the
front controller represented by index.php
, then the front-controller bootstraps the
application by first auto-loading all the classes in their proper namespaces using composer, then loading
bootstrap.php
which binds the; config
, database connection
and validation rules
to the App container
.
For data access, I access the data though raw sql queries, without the need for a ORM, I store the queries in the repositories for reusability and abstraction of the data access on the data-access layer. Link on repository pattern
The business logic on the application layer is stored in the service classes for reusability accross the application and also to maintain a clean controller. Link on Service classes
For the validation the app uses the strategy pattern to use multiple algorithm implementing the same interface. Link to strategy pattern
For testing the app uses PHPUnit for running unit tests and DBunit for testing the data-access layer.
To run the test execute this code at the root directory of the app:
./vendor/bin/phpunit --testdox tests
(Make sure app is setup and running before running test)
Api is documented with swagger openApi documentation. To access the API in json format hit this route on tbe app
api/docs/json
To start up the application locally, follow these steps mentioned.
- You have a PHP environment set up
- You have a MySQL server setup
- You have PHP version ^7.4
- Clone application locally:
git clone git@github.com:Thirdwrist/shoppinpal.git
- Install composer on your system.
- Go to root of application and run
composer install
. - Create a project db.
- Create your own copy of
config.php.example
and name itconfig.php
, then fill it with the appropriate values. - Pick up all migrations from the migrations folder and run it on your created project db.
- Create your own copy of
phpunit.xml.dist
and name itphpunit.xml
then fill with the appropriate values. - Run app from project root on the terminal with:
php -S localhost:8000
.