https://hn-top-stories.herokuapp.com/
I've designed it based on Clean Architecture ideas.
I tried to not get too far from Rails regular architecture to not difficult the onboarding of a seasoned Rails developer.
I've added new layers, restricted some Rails "magic" (like Active Record API) and reduced Rails' Model responsibilities (splitting into Presenters, Forms and Repositories).
- Models: acts like Entities or Value Objects, describes the behavior and express business rules.
- Repositories: responsible for retrieving and storing models from the persistence layer, ex: in a database or a file.
- Presenters: define presentation logic, contains the formatting rules according to the view, ex: page view or JSON response
- Interactors: aka use-cases, encapsulates and describes functionalities of the system. Coordinates Repositories and other Interactors to execute business tasks.
Install dependencies
bundle install
Setup database
rake db:setup
Create app
heroku apps:create
Add buildpacks
heroku buildpacks:add heroku/nodejs --index 1
heroku buildpacks:add heroku/ruby --index 2
Task | Description |
---|---|
rake start |
Starts application API and client |
rake spec |
Run all specs |
rake spec:unit |
Run unit tests (Models, Presenters) |
rake spec:integration |
Run integration tests (APIs, Interactors, Repositories) |
rake spec:acceptance |
Run acceptance tests (Features) |
rake spec:client |
Run all client specs |
rake build:client |
Builds client |
git push heroku master
Endpoint | Description |
---|---|
/api/stories |
Hacker News top stories |
/api/stories/:id/comments |
List relevant story comments |
/api/stories/search?term= |
Search through stored stories |
/health |
Health check endpoint |
- Story json response publishedAt timezone
- Console is printing warning messages because of Pry issues with current Ruby version
- API endpoints are exposed
- improve search with pg full-text and include comments content
- make item_id as primary keys
- extract api fetch interactors
- rename /stories endpoint to /top-stories
- rename /comments endpoint to /relevant-comments
- sanitize comment content before persist into database
- optimize VCR cassettes configurations
- create CSS variables for colors, fonts sizes, etc
- add a CSS preprocessor