This part of the project is dedicated to the API, which provides the data for our website. If you're looking to edit the data within the API (especially books and movies), check out the db/data folder. For making changes to the API itself, read on.
The API is powered by the following technologies:
Before you begin, please ensure you have the necessary programs and tools installed.
You can setup the project using either Ruby or Docker. Choose the option that fits you the best. Therefore make sure to install the required dependencies before diving into development.
To contribute to our API, follow these simple steps:
git clone git@github.com:danielschuster-muc/potter-db.git
cd potter-db/backend
Ensure you have Docker on your system. You can check your Docker version by running:
docker -v
If not, install docker on your system:
https://www.docker.com/get-started/
Run the following command in your terminal
docker compose up --build
docker compose exec web /bin/sh -c "rails db:create && rails db:migrate && rails db:seed"
You can start the rails server using the command given below:
docker compose exec web /bin/sh -c "rails server -b 0.0.0.0"
The development server is accessible at http://localhost:3000. It's recommended to read the documentation to get a better understanding of the API.
Feel free to explore and contribute to our project's backend. Happy coding 🎉!
For any code changes, ensure that the backend tests are running successfully. You can run the API tests using the following command:
docker compose exec web rspec
We use Rubocop to lint our code. To run the linter, use the following command:
docker compose exec web bundle exec rubocop
Our API is documented using OpenAPI. To update the documentation, make your changes in rspec/request folder and run the following command afterwards:
docker compose exec web rails rswag:specs:swaggerize
You can now visit the documentation on http://localhost:3000/v1/openapi or in app/documentation/v1/openapi.yml.
To validate the documentation, run the following command:
spectral lint app/documentation/v1/openapi.yml
We also provide a GraphQL API. To update the GraphQL schema, make your changes in app/graphql and run the following command afterwards:
docker compose exec web rails graphql:schema:dump
You can now find the schema dump in app/graphql/schema.graphql.