Skip to content

REST API that verifies JSON file based on 3 conditions: valid issuer, recipient and signature

Notifications You must be signed in to change notification settings

sittimunirahar/document-verification-api

Repository files navigation

Document Verification API


About

The feature demonstrates a document verification API where an authenticated user sends a JSON file and receives a verification result as a response.

The document is verified based on 3 conditions: valid issuer, recipient and signature.

Tech Stack: PHP 8, Laravel 10, MySQL, Docker: Laravel Sail, PHP Pest.

Prerequisites

  • Git
  • If you are using Sail for local development: Docker Desktop
  • If you are not using Docker: PHP, Composer and a database

Installation

  1. Clone this repository:

     git clone https://github.com/sittimunirahar/document-verification-api.git
    
  2. Navigate to the Project Directory:

     cd document-verification-api
    
  3. Create and configure .env File:

    • Rename the .env.example file in the project root directory to .env
    • Update the necessary environment variables in the .env file, such as database credentials, app key, etc.
  4. Build and Run the project:

    Sail

    Build and Run the Docker Containers:

    • Run the following command to start Sail: ./vendor/bin/sail up

    • Sail will build and run the necessary Docker containers based on the project's docker-compose.yml configuration.

    Without Sail

    As mentioned in the Prerequisites, ensure that you have the required dependencies (PHP, Composer, and a database) installed locally.

    • Run the following command to install project dependencies: composer install
    • Start your local development server (e.g., Apache, Nginx) and configure it to point to the project's public directory.
  5. Run Database Migrations:

    Sail

    • Run the following command to access the application container: ./vendor/bin/sail shell

    • Run the migrations: php artisan migrate

    • You can also directly run without running the ./vendor/bin/sail shell command:

      sail artisan migrate

    Without Sail

    • Create your database

    • Configure it in the .env

    • Run the migrations:

      php artisan migrate

  6. Access the application:

    Sail

    Without Sail


Running Test

  1. Running Test

    Sail (Without application container access):

     ./vendor/bin/sail test --filter "<TestName>"
    

    or

     sail artisan test --filter <TestName>
    

    Sail (with application container access) or Without Sail:

     php artisan test --filter <TestName> 
    

    Optional

    • Add --coverage to run coverage
    • Remove TestName to run all test
  2. Feature test (covers the end-to-end document verification process)

    Test name: DocumentVerificationTest

    Test covers:

    • authorized user is able to verify document
    • authorized user is able to verify document with incomplete data
    • authorized user is not allowed to upload file bigger than 2MB
    • authorized user is only allowed to upload file in json
    • unauthorized user is not allowed to verify document
    • stores verification result in database
  3. Unit tests

    Test name: DocumentVerificationServiceTest

    Test covers:

    • transforms file content to JSON
    • verifies document
    • formats verification data
    • stores verification results

    Test name: DocumentValidationServiceTest

    Test covers: Tests\Unit\DocumentValidatorServiceTest

    • validates document with complete data
    • validates recipient with missing data
    • validates issuer with missing data
    • validates signature with missing data

About

REST API that verifies JSON file based on 3 conditions: valid issuer, recipient and signature

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages