Skip to content

Thirdwrist/shoppinpal

Repository files navigation

Shoppinpal Test

Requirements

Create a RESTful web service for a Library. The service must have the following API endpoints

  • Create a new Book
  • Read existing Books
  • Update an existing Book
  • Delete an existing Book

A Book entity has the following properties

  • Author (mandatory)
  • Title (mandatory)
  • ISBN (mandatory)
  • Release Date

MUST HAVE Requirements (we will not consider your submission if these are not met)

  • 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

Bonus / Nice to have

  • 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]

Please Note Footnote

  • 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.

Todo

  • 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


ShoppinPal App Solution description

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.

Data Access

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

Business Logic

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

Request validation

For the validation the app uses the strategy pattern to use multiple algorithm implementing the same interface. Link to strategy pattern

Testing

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 Documentation

Api is documented with swagger openApi documentation. To access the API in json format hit this route on tbe app api/docs/json

Setup Guide

To start up the application locally, follow these steps mentioned.

Assumptions

  1. You have a PHP environment set up
  2. You have a MySQL server setup
  3. You have PHP version ^7.4

Guide

  1. Clone application locally: git clone git@github.com:Thirdwrist/shoppinpal.git
  2. Install composer on your system.
  3. Go to root of application and run composer install.
  4. Create a project db.
  5. Create your own copy of config.php.example and name it config.php, then fill it with the appropriate values.
  6. Pick up all migrations from the migrations folder and run it on your created project db.
  7. Create your own copy of phpunit.xml.dist and name it phpunit.xml then fill with the appropriate values.
  8. Run app from project root on the terminal with: php -S localhost:8000.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages