This is a web scraping application built with the Phoenix web framework for Koombea.
Here are some design choices and considerations made during development.
To implement auth logic Phoenix offers a powerful code generator (mix phx.gen.auth), but I opted for a manual, minimalist implementation for clarity and readability. The phx.gen.auth generator is excellent for production applications, but it adds a considerable amount of code (controllers, views, contexts, emails) that is not necessary for the specific requirements of this test. By implementing it manually, the authentication code is concise and focuses exclusively on registration and login.
For handling background jobs, I am using a manually created GenServer background job process. In a production environment, I would use a more robust solution like Oban, which provides better queuing, retries, and visibility into job execution.
For test fixtures, I've created manual helper functions. In a larger-scale project, I would use a library like ExMachina to streamline the creation of test data and improve the maintainability of the test suite.
I update the migration files for simplicity, but the correct way to do it is to create new migration files.
The backend logic handles params to perform queries with pagination, but a proper pagination UI was not implemented as the instructions indicated it was not a priority.
Dependencies
This project requires no additional dependencies beyond the default tools for a Phoenix application. I primarily used generators to create views, schemas, and other necessary components.
- asdf: A command-line tool to manage multiple language runtime versions.
- Docker: To run a PostgreSQL database.
Once asdf is installed, add the Elixir and Erlang plugins:
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.gitNow, install the Elixir and Erlang versions specified in the .tool-versions file:
asdf installTo run the application, you need a PostgreSQL database. You can easily start one using Docker:
docker run -d --name koombea_scraper_db -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgresThis command will start a PostgreSQL container named koombea_scraper_db with the password postgres, and it will be accessible on port 5432.o
Install dependencies:
mix deps.getCreate and migrate the database:
mix ecto.resetStart the Phoenix server:
mix phx.serverNow you can visit localhost:4000 from your browser.
There is a docker compose with the db and the app server. You can start using
Start the Phoenix server:
docker-compose up --build