Skip to content

Simple RESTful API for a library management system.

Notifications You must be signed in to change notification settings

abela-a/library-management-system-api

Repository files navigation

📚 Library Management API

Technical test for backend developer position at PT. Altech Omega Andalan. Simple RESTful API for a library management system. This repository contains a simple RESTful API for a library management system. The API manages authors and books, allowing operations such as creation, retrieval, update, and deletion of records. This project demonstrates clean code design, database schema implementation, unit testing, and performance tuning techniques.


📑 About this Project

This project showcases my backend development expertise, with a focus on designing and implementing robust, scalable, and maintainable APIs. I chose PHP (Laravel) to complete this technical test. Laravel is a highly popular framework widely adopted in production environments. It offers numerous built-in features that simplify handling a variety of use cases. Another reason for choosing Laravel is my extensive experience with it—I have been using the framework for over four years. This familiarity allows me to efficiently apply its best practices to deliver high-quality solutions.

Tech Stack

  • Language: PHP
  • Framework: Laravel
  • Database: MySQL/Postgresql/SQLite
  • Documentation: Swagger
  • Testing: PHPUnit

Design Pattern

I use the Repository Design Pattern in this project. The Repository Design Pattern in Laravel is utilized to separate data access logic from the business logic of the application. This approach offers benefits such as more structured code, easier testing, and flexibility to accommodate changes. By using a repository, you can replace or modify the data source (e.g., switching from a database to an external API) without altering the business logic in controllers or services. Additionally, this pattern facilitates the implementation of SOLID principles, particularly the Dependency Inversion Principle, as controllers or services depend only on contracts (interfaces) rather than direct implementations. This makes the application easier to maintain and extend.

Database Design

Table: authors

Column Name Data Type Attributes Description
id bigint Primary Key, Auto Increment Unique identifier for the author
name string Indexed, Not Null Name of the author
bio text Nullable Short biography of the author
birth_date date Nullable Birth date of the author
created_at timestamp Auto-managed by Laravel Record creation timestamp
updated_at timestamp Auto-managed by Laravel Record update timestamp

Indexes

Index Name Columns Description
authors_name_index name Index for optimizing queries on the name column

Table: books

Column Name Data Type Attributes Description
id bigint Primary Key, Auto Increment Unique identifier for the book
title string Indexed, Not Null Title of the book
description text Nullable Description of the book
publish_date date Indexed, Not Null Publication date of the book
author_id bigint Foreign Key, Not Null References id in the authors table
created_at timestamp Auto-managed by Laravel Record creation timestamp
updated_at timestamp Auto-managed by Laravel Record update timestamp

Foreign Keys

Foreign Key Name Column References Action on Delete Description
books_author_id_foreign author_id authors.id Cascade Deletes book records when the associated author is deleted

Indexes

Index Name Columns Description
books_title_index title Index for optimizing queries on the title column
books_publish_date_index publish_date Index for optimizing queries on the publish_date column

Performance Tuning

To optimize the performance of this project, I implemented several tuning strategies.


⚡ Getting Started

Requirements

  • PHP >= 8.0
  • Composer
  • MySQL/Postgresql/SQLite (preferable)

Installation

  1. Clone the repository:

    git clone https://github.com/abela-a/library-management-system-api.git
  2. Navigate to the project directory:

    cd library-management-system-api
  3. Install dependencies:

    composer install
  4. Set up the environment file:

    cp .env.example .env

    Configure the database and other environment variables as needed.

    DB_CONNECTION=sqlite/mysql/postgresql
    # DB_HOST=127.0.0.1
    # DB_PORT=3306
    # DB_DATABASE=technical_test_altech_omega
    # DB_USERNAME=root
    # DB_PASSWORD=
  5. Generate app key for encryption:

    php artisan key:generate
  6. Run migrations and seed the database:

    php artisan migrate --seed

Running the Project

To start the project locally, use the following command:

php artisan serve

🔖 API Documentation

The API documentation is available via Swagger. Once the project is running, visit the following URL to explore the endpoints:

http://localhost:8000/api/documentation

📝 Testing

Unit and feature tests are implemented using PHPUnit to ensure the reliability of the API. Run tests using:

php artisan test
# or
./vendor/bin/phpunit

📧 Contact

I would greatly appreciate any feedback on my work, as it will help me improve and grow as a developer. If you have any comments, suggestions, or questions regarding this project, please feel free to reach out:

Thank you for taking the time to review this project!

About

Simple RESTful API for a library management system.

Topics

Resources

Stars

Watchers

Forks

Languages