Skip to content

πŸ’¬πŸ³ Rin Minase's AniDB API Service utilizing Laravel 10 and deployed to Heroku

License

Notifications You must be signed in to change notification settings

RinMinase/anidb-be

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Rin Minase's Anime Database
(Back-end API Service)

Laravel PHP

Introduction

Add info here

Getting Started

Environmental variables setup

Note: You can disable specific modules

This is done by setting these specific ENV flags to true, to disable them.

DISABLE_SCRAPER  - Disables WebScraper
  1. Database (PostgreSQL)

    • These are the configuration options for the database:

      DB_CONNECTION=pgsql       <the database configuration being used by Laravel>
      DATABASE_URL=             <this is populated whenever an online database is being used>
      DB_HOST=anidb-pgsql       <docker **container name** of the database>
      DB_PORT=5432              <port used by the database>
      DB_DATABASE=anidb         <database name>
      DB_USERNAME=postgres      <database username>
      DB_PASSWORD=postgres      <database password>
      

      Notes : DB_HOST should use docker container name of db, by default this is 'anidb-pgsql', but yours could be different. You can check this by running docker ps then check the container name of the postgres container.

  2. Cloudinary

    • Fire up your browser and login your Cloudinary Account. If you have no account yet, you can create one for free.
    • After logging in, navigate to the Cloudinary Console to retrieve your Cloudinary URL
    • Copy the value of API Environment variable to CLOUDINARY_URL of your ENV file

Running the project

  1. Download and install Docker for Windows.

  2. Clone the project, then install the dependencies

    git clone https://github.com/RinMinase/anidb-be.git
    cd anidb-be
    
  3. Run the necessary docker containers

    docker-compose up -d
    docker-compose exec php sh
    
  4. Inside the docker image, copy the env file, install the necessary dependencies and generate the API Key

    cp .env.example .env
    composer install
    php artisan key:generate
    
  5. Modify the ENV file with the necessary configuration values

  6. Clear the Laravel config cache, then run the database migrations

    php artisan config:clear
    php artisan migrate:fresh --seed
    
  7. Fire up your browser and go to localhost.

Note: If you need to access the container run, docker-compose exec php bash

Re-running the project

  1. Navigate to the project foler root then run docker-compose up -d

  2. Run the migrations when necessary, then install the dependencies also when necessary

    php artisan migrate
    composer install
    
  3. Fire up your browser and go to localhost.

Running the Swagger Generator / API Documentation Generator

  1. Navigate to the project foler root then run docker-compose up -d

  2. Run the command below:

    composer docs
    
  3. Fire up your browser and go to localhost/docs to open Swagger UI.

Running the Unit Tests

  1. Navigate to the project foler root then run docker-compose up -d

  2. Run the command below:

    php artisan test
    

    or if you want to run a specific test

    php artisan test --filter <Class Name of Test File>
    

Project shorthands / aliases inside the PHP Docker container

This shortcuts were created to reduce the need to keep typing the same long commands over and over again.

Shortcut Long version
pa or artisan php artisan
docs composer docs
dump or da composer dumpautoload

Project Structure

.
β”œβ”€β”€ app/                     # Application source code
β”‚   β”œβ”€β”€ docs.blade.php       # Swagger page template
β”‚   β”œβ”€β”€ index.blade.php      # Landing page template
β”‚   └── ...                  # Other application-related files
β”œβ”€β”€ bootstrap/               # Project initializers
β”‚   β”œβ”€β”€ app.php              # Framework bootstrapper
β”‚   β”œβ”€β”€ helpers.php          # Helper functions
β”‚   └── routes.php           # Route definitions
β”œβ”€β”€ config/                  # Laravel configuration files
β”œβ”€β”€ database/                # Database migrations and seeders
β”œβ”€β”€ docker/                  # Docker functions
β”‚   β”œβ”€β”€ php-config/          # PHP settings for docker
β”‚   β”œβ”€β”€ sites/               # Nginx sites for docker
β”‚   β”œβ”€β”€ nginx.dockerfile     # Nginx container docker file
β”‚   β”œβ”€β”€ php.dockerfile       # PHP container docker file
β”‚   └── ...                  # Other docker files
β”œβ”€β”€ public/                  # Project entry point
β”œβ”€β”€ tests/                   # Project test files
β”œβ”€β”€ .czrc                    # Commitizen configuration file
β”œβ”€β”€ docker-compose.yml       # Main docker file
β”œβ”€β”€ phpunit.xml              # Unit test configuration file
β”œβ”€β”€ Procfile                 # Heroku process file
└── ...                      # Other project files

Built with

Deployed to