This is a proof of concept web app for managing books in a library.
It would be improved by implementing some interesting features in the nearest future (search by title, category, author or by ISBN).
The project consists of two main parts:
- Backend: Elixir/Phoenix API + PostgreSQL
- Frontend: Svelte
A simple Books REST API with database persistence using PostgreSQL.
The requirements are to have a single endpoint on /api/books
that allows CRUD operations over the books resource with the following fields:
- id - This is the table Primary Key (UUID type)
- title - String containing the book title
- authors - String containing a comma-separated list of authors
- isbn - Book ISBN
- description - Text specifying the book description or abstract
- category - String containing a comma-separated list of tags
- cover - String containing an image url for displaying the cover
- inserted_at - Datetime defining when the record was created
- updated_at - Datetime defining when the record was updated
The endpoints for the Books resource are listed here:
To create a book you need to complete a post request with the following parameters:
While developing the following stack was used:
Technology | Version |
---|---|
Elixir | 1.12.2-otp-24 |
Phoenix | 1.6.2 |
Node JS | 14.15.4 |
PostgreSQL | 14.1 |
docker-compose | 1.26.0 |
Svelte | 3.0.0 |
Rollup JS | 2.3.4 |
- Execute
mix deps.get
to install Phoenix dependencies. - You need a postgresql database to proceed.
You can use docker:docker-compose -f docker/docker-compose.yml up -d
to get up the database.
If this command fails then you're using PostgreSQL locally. Stop it:sudo service postgresql stop
and repeat docker-compose command. - When the database is up and running:
mix ecto.create
and thenmix ecto.migrate
- Start Phoenix:
mix phx.server
- Now we need to launch frontend. Enter
/assets
directory from another tab of your terminal and run:npm i
oryarn
if you prefer it over npm. - Execute
npm run dev
and navigate tohttp://localhost:5000
At beginning there's no book data. You can use some mock data from /assets/src/mockups/booksMock
file and use Postman for testing
Run mix test
for API tests
You could also visit endpoint in the browser http://localhost:4000/api/books
and investigate api responses.
The BooksCat now looks like this, but there are a lot of ideas worth mentioning
With the next iterations I'd like to add:
- The most important feature searcher with filters
- Authorization/authentication for backend (different roles for DB) and frontend (sign in new users, user roles).
- Add more fields for Book Entity like 'pages', 'subtitle', 'publisher'.
- More validation cases (pop up for errores, etc.)
- More tests
- Extra integration -> add bar code ISBN scanner for faster adding new books to the library.