GithubHelp home page GithubHelp logo

ssaunderss / coffee-chat Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 58 KB

chat server implemented in elixir

License: GNU General Public License v3.0

Dockerfile 1.12% Elixir 73.32% CSS 18.80% JavaScript 2.53% HTML 4.24%

coffee-chat's Introduction

coffee-chat

chat server implemented in elixir

Design overview

Backend Database

Using CockroachDB's serverless database as the backend for this project. It's pretty easy to setup, and it takes a lot of the burden off of scalability which is a big consideration for build chat apps.

There are some other cool features of CockroachDB that make it nice for this project:

  1. Hash sharded indices (low-latency retrieval for ranged data - e.g. retrieving messages)
  2. Highly available, if one of our nodes goes down the chat app will continue to function as expected (Cockroach has a minimum of 3 replicas)
  3. Cockroach serverless takes the burden off of having to think about how the app scales - and there's a pretty generous free tier

Setting up the database

If you want to set this up using Cockroach's serverless free-tier, head on over to https://cockroachlabs.cloud and create an account.

Once you create an account, you can create a free-tier cluster. You can call this whatever you'd like.

From here, you'll need to navigate over to the cluster and click on the connect button. Follow the prompts for downloading the CA certificate and grab the connection string.

Now you'll need to parse the connection string and export the following environment variables:

export COCKROACH_USERNAME="$insert_cockroach_username_here" \
    COCKROACH_PASSWORD="$insert_cockroach_password_here" \
    COCKROACH_HOSTNAME="$insert_cockroach_hostname_here" \
    COCKROACH_DATABASE="$insert_cockroach_database_here" \
    COCKROACH_PORT="$insert_cockroach_port_here" \
    COCKROACH_CA_CERT_PATH="$insert_cockroach_ca_cert_path_here" \
    COCKROACH_CLUSTER="$insert_cockroach_cluster_options_here"

If you need some help figuring out what these values should be, take a look at config/runtime.exs

If you don't want to sign up for the hosted serverless option, you can edit the Docker Compose file in this repo to set up a local cluster - here's a link for some doccumentation from Cockroach: https://www.cockroachlabs.com/docs/stable/start-a-local-cluster-in-docker-mac.html

(Note: using a Docker cluster is insecure and should not be deployed. If you need to deploy, reconsider the hosted option, or you can check out the manual deployment option for your preferred cloud provider/on-prem https://www.cockroachlabs.com/docs/stable/manual-deployment.html)

TODOs

  • Write migration files
  • Write boilerplate queries
    • tighten up changesets for users
  • Write tests for backend
  • Start working on front end / liveviews (use Phoenix PubSub for liveview updates)
  • Shift focus to work on end to end encryption

Phoenix

To start your Phoenix server:

  • Install dependencies with mix deps.get
  • Create and migrate your database with mix ecto.setup
  • Start Phoenix endpoint with mix phx.server or inside IEx with iex -S mix phx.server

Now you can visit localhost:4000 from your browser.

Ready to run in production? Please check our deployment guides.

Learn more

coffee-chat's People

Contributors

ssaunderss avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.