60 minutes, Advanced, Start Building
Loom is a thread based chat server, where users can send messages to one or more threads via hashtags (ex. "I'm heading to the park at noon #family #friends #frisbee_club" ). Users can subscribe to new threads they see by clicking them and start new threads but just adding a new hashtag to a message.
How this works
The app demonstrates working with DataStax Astra, Elixir, and Phoenix Liveviews together. The project attempts to make the best use of this stack. Messages histories are saved and loaded in Astra, while new messages are shared via Phoenix channels between all active users in a "thread". The goal is a fast, scalable, and durable chat/messaging application.
To build and play with this app, follow the build instructions that are located here: https://github.com/DataStax-Examples/astra-loom
Running Astra Loom
Follow the instructions below to get started.
Let's do some initial setup by creating a serverless(!) database.
- Create a DataStax Astra account if you don't already have one:
- On the home page. Locate the button
- Locate the
Get Startedbutton to continue
- Define a database name, keyspace name and select a database region, then click create database.
- Your Astra DB will be ready when the status will change from
- After your database is provisioned, we need to generate an Application Token for our App. Go to the
Settingstab in the database home screen.
Admin Userfor the role for this Sample App and then generate the token. Download the CSV so that we can use the credentials we need later.
- After you have your Application Token, head to the database connect screen and copy the connection information that we'll need later. We'll replace
Tokenvalue that is part of your Application Token.
Use this templateat the top of the GitHub Repository:
- Enter a repository name and click 'Create repository from template':
- Clone the repository:
🚀 Getting Started Paths:
Make sure you've completed the prerequisites before starting this step
Running on your local machine (Docker)
See https://hub.docker.com/repository/docker/omnifroodle/astra-loom for information about launching the astra-loom docker container.
.envand update it with your Astra and Google credentials.
Run the following to setup your environment:
source .env mix deps.get cd assets && npm install mix loom.init
- To start the server
source .env mix phx.server
Running on Gitpod
NOTE: You can skip any Google auth setup on gitpod.io, setting up Google auth on gitpod is beyond the scope of this document.
- Click the 'Open in Gitpod' link:
- You will be prompted for the following:
- "ASTRA_ID" - This is your Astra database ID, you can find this on the Astra web dashboard
- "ASTRA_REGION" - The region where your Astra database is hosted, this is also on the Astra web dashboard
- "ASTRA_USERNAME" - The username for you Astra database
- "ASTRA_PASSWORD" - The password for your Astra username
The webserver should start automatically in a new window or tab of your brower.
Open a terminal and initialize your Astra db schema with the following command:
- Click "Random Dev User" to login with a random identity and look around.