A demo app to create ideas and discuss them with other users. This app is built using Elixir and Phoenix to learn websockets, authentication and psql in Phoenix.
What does the app do?
This app allows a user to view ideas.
The user can log in using github and access more functionality. Logged in users can:
- create ideas
- edit or delete their own idea
- comment on anyone idea in realtime
The app is built in Phoenix 1.2, a web-framework for Elixir.
Ueberauth is used to authenticate the user with Oauth, and in this case github. The user has a token set that provides access to restricted parts of the app that only logged in users should use. This token also identifies the user so that only that specific user can edit their own ideas and no one can touch and idea that they have not created.
The app uses a PostgreSQL database. Writing to the database is quite different in Phoenix and does not employ creating any SQL statements. You create models of the database in phoenix to configure how the tables will work and then add rows by making them match a template changeset which is sent to the database.
Websockets allow a permanent connection so that data displayed to the user can be updated live without the user needing to reload. Making the comments with websockets means that they become a live feature and the user will see new comments from any other user as they add them and they can be used as a real-time conversation.
Note - the app is currently configured to run on the heroku server. You will need to set up local environment variables and create your own github Oauth app keys to make it run. (and install erlang, elixir and phoenix)
To start a Phoenix app:
- Install dependencies with
- Create and migrate your database with
mix ecto.create && mix ecto.migrate
- Install Node.js dependencies with
- Start Phoenix endpoint with
Now you can visit
localhost:4000 from your browser.
Ready to run in production? Please check our deployment guides.