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.
- Requirements Doc: REQUIREMENTS.md
- API Doc: document_verification_api.md
- Refactoring or Improvement Plan: ROADMAP.md
- Technical documentations: in
docs/
Sequence Diagram.png
Verification Flowchart.png
Architecture Comparison Table.png
- Git
- If you are using Sail for local development: Docker Desktop
- If you are not using Docker: PHP, Composer and a database
-
Clone this repository:
git clone https://github.com/sittimunirahar/document-verification-api.git
-
Navigate to the Project Directory:
cd document-verification-api
-
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.
- Rename the
-
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.
-
-
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
-
-
Access the application:
Sail
- The application should now be accessible at http://localhost or http://127.0.0.1 in your browser.
Without Sail
- Visit the configured URL for your local development server (e.g., http://localhost or http://127.0.0.1) in your browser.
-
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
- Add
-
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
-
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