This is a solution for the Swivel coding challenge, implementing a Ruby on Rails API with OAuth authentication, Elasticsearch integration, and nested resource management.
Before you begin, ensure you have the following installed on your machine:
- Docker
- Docker Compose
- Clone the repository
- Run
docker compose up --build
- OAuth 2.0 authentication using Doorkeeper
- Elasticsearch integration for efficient searching
- Nested resource management (Verticals -> Categories -> Courses)
- PostgreSQL database with seed data
- Object serialization with active_model_serializers
- Pagination with Kaminari
- Docker and Docker Compose setup for easy setup
The application implements OAuth resource owner credentials grant for authentication.
-
A user must be created first to access API endpoints.
-
The seed data creates a user with the following credentials:
- Email:
[email protected] - Password:
secret
- Email:
-
To obtain an access token, send a
POSTrequest tohttp://localhost:3000/oauth/token -
Use the obtained token as a
Bearertoken to access any API endpoint.
curl --location 'http://localhost:3000/oauth/token' \
--header 'Content-Type: application/json' \
--data-raw '{
"grant_type": "password",
"email": "[email protected]",
"password": "secret"
}'- /api/v1/verticals: CRUD operations for Verticals
- /api/v1/categories: CRUD operations for Categories
- /api/v1/courses: CRUD operations for Courses
- /api/v1/users: User creation
- Each resource (Verticals, Categories, Courses) also has a /search endpoint for Elasticsearch-powered searching.
A Postman collection for API endpoints is available at: https://elements.getpostman.com/redirect?entityId=15829895-39101ab2-0842-49ec-8503-fcd4fa6c4255&entityType=collection
To run the test suite,
- Open a shell inside the container
docker compose exec -it web bash- Run test suite setting RAILS_ENV=test explicitly
RAILS_ENV=test bundle exec rspec