/laraHolidaysAPI

This repository contains the backend codebase for a REST API that manages holiday plans, users, and related entities. It provides API endpoints for CRUD operations on holiday plans, users, holiday plan logs, participants groups.

Primary LanguagePHP

laraHolidaysAPI 🌴

Laravel Sail Postgres Redis Docker

This repository contains the backend codebase for a REST API that manages holiday plans, users, and related entities. It provides API endpoints for CRUD operations on holiday plans, users, holiday plan logs, participants groups.

Features

  • CRUD operations on holiday plans, users, holiday plan logs, and participants groups.
  • Generation of PDF for holiday plans.
  • Sending emails when a holiday plan is created.
  • Authentication using OAuth tokens.
  • Error handling and logging.

Entities

The main entities in this project are:

  • HolidayPlan: Manages the holiday plans.
  • HolidayPlanLog: Logs actions related to holiday plans.
  • ParticipantsGroup: Manages participants groups for holiday plans.
  • User: Stores user information.

Dependencies

This project uses several technologies:

  • Laravel: A PHP framework for web application development.
  • Postgres: A relational database for storing application data.
  • Redis: An in-memory data structure store, used as a database, cache, and message broker. Redis is used for caching and speeding up responses.
  • Docker: A platform to develop, ship, and run applications inside containers. Docker ensures that the application runs the same way in every environment.
  • Laravel Sail: A light-weight command-line interface for interacting with Laravel's default Docker environment.

You will need Docker installed on your machine. You can see how to install it on your OS here.

Get Started

Follow these steps to set up the project:

  1. Install dependencies using a composer from a Laravel Sail image in Dockerhub:

    docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v "$(pwd):/var/www/html" \
    -w /var/www/html \
    laravelsail/php83-composer:latest \
    composer install --ignore-platform-reqs
  2. Create a .env:

    cp .env.example .env
  3. Up the Docker environment:

    ./vendor/bin/sail up
  4. Generate a api key:

    ./vendor/bin/sail artisan key:generate
  5. Run tests (optional):

    ./vendor/bin/sail artisan test
  6. Populate the database:

    ./vendor/bin/sail artisan migrate:fresh --seed
  7. (Optional) You can create a connection in a SGBD Manager, like DBeaver or Datagrip:

  • Create the connection with the '.env' db variables:

    DB_CONNECTION=pgsql
    DB_HOST=pgsql
    DB_PORT=5432
    DB_DATABASE=laravel
    DB_USERNAME=sail
    DB_PASSWORD=password
    

Example when create a HolidayPlan and recive a email

img email pdf

Example when create a HolidayPlan and recive a pdf

img about pdf

Database Tables

The project uses the following database tables:

  • failed_jobs: Records failed queue jobs.
  • holiday_plan_logs: Logs actions related to holiday plans.
  • holiday_plans: Stores information about holiday plans.
  • migrations: Tracks database migrations.
  • oauth_*: Tables for OAuth authentication.
  • participants_groups: Manages participants groups for holiday plans.
  • password_reset_tokens: Stores password reset tokens.
  • personal_access_tokens: Manages personal access tokens for authentication.
  • users: Stores user information.

Databse Schema

img database schema

Notes

  • Remember if you run test it will refresh the database.