-
Notifications
You must be signed in to change notification settings - Fork 2
Development guide
10Books is built on top of Phoenix, some parts of the app are using react and redux.
In order to launch the dev version, you need to have Elixir, Node.js and PostgresSQL installed on your OS. Then, run following:
-
mix deps.get
to install Elixir dependencies -
cd assets && yarn && cd ..
to install JavaScript dependencies -
mix ecto.create
to create database -
psql -U postgres -d lib_ten_dev < priv/repo/postgres_dump.sql
to load seed data -
mix ecto.migrate
to apply latest db migrations -
mix phx.server
to start local server
Done with phoenix router. Because of this, we have a mix of back-end and react rendered html. Therefore, CSS is written using SCSS and BEM naming convention (instead of CSS-in-JS commonly used with React apps).
We use ueberauth
package with phoenix html views. User can sign in only with a valid google account (domain must match one of allowed_google_auth_domains
)
There are 2 types of users:
-
default
- can do everything in "Library" section and suggest/vote for books in "Orders" section. -
Admin
- default + can edit books, manage categories or assign new admins.
React components rendered inside phoenix layout. When component is initialised, it will join related phoenix channel and start receiving information in real time.
Each time there's INSERT
, UPDATE
or DELETE
on related tables, PostgreSQL will trigger NOTIFY
command with category_updated, category_id
or product_updated, product_id
. postgres_listener.ex
is listening for those events and forwards information to related channels. Channel then will fetch required data and push new message to the client.
Only user with is_admin: true
flag can access. Fully done with phoenix controllers and views.
- Run
docker-compose up
to boot the app. It will spawn on http://localhost:4000 - Run
cat priv/repo/postgres_dump.sql | docker exec -i YOUR_CONTAINER_ID psql -U postgres
to upload seed data. WhereYOUR_CONTAINER_ID
is a container id fromdocker ps