- PostgreSQL 15.2
- Ruby 3.1.3
docker pull postgres:15.2
docker volume create elearnio_challenge_db
docker container create --name elearnio_challenge_db --publish 5432:5432 --env POSTGRES_USER=postgres --env POSTGRES_PASSWORD=password --volume elearnio_challenge:/var/lib/postgresql/data postgres:15.2
docker start elearnio_challenge_db
cp .env.example .env
bin/rake db:create db:schema:load
bin/rspec
bin/rubocop
bin/rails zeitwerk:check
- The REST API is built on Grape because:
- It has a handy serialization layer
- Routes are assembled based on class definitions
- Basic Swagger documentation for free
- The project follows DDD-like approach:
- The data layer is represented by immutable entities and value objects. They can not be instantiated or transformed into an invalid state.
- The persistance layer and its constraints is handled by repositories based on ActiveRecord
- Services are "bridges" between layers
- Communication between layer are done through specific error classes
app
├── entities # Immutable business entities that ensure in-memory business rules
├── gateways
│ └── rest
│ ├── api
│ │ ├── helpers # Helpers for easier dealing with other layers(exception handling, data fetching)
│ ├── serialization # Output data serialization
│ └── validation # HTTP-specific data validation
├── repositories # Retrieving information from the database and storing it back, while enforcing some unique constraints
├── services # More complex business operations
├── types # Value-objects
- Courses and learning paths can be either in
draft
orpublished
mode - Only
published
courses and learning paths can be assigned to talents - Only
published
courses can be used in a learning path published
entities can neiter bechanged
nordeleted
- Talent emails are unique
- Courses names are unique
- Learning path names are unique
- Courses can not be assigned to their authors
- Learning paths can not be assigned ot their authors
- All the course authors of a learning path are considered co-authors
- A learning path can not be assigned to its co-authors
- A talent, who has an assigned learning path/course, can not be used as their new author, when deleting their current author
You can get all the available endpoints by generation swagger docs
- Run the server localy
- Visit
/api/swagger
- Grab the response JSON and paste it into
editor.swagger.io
- Relationship between courses/learning paths and talents could have done through a table
learning_material_id, talent_id, role
with a unique constraint onlearning_material_id, talent_id
so that a talent can be either an author of or be assigned with a material. Such the approach would decrease the amount of checks on the application level.