Skip to content

Instantly share code, notes, and snippets.

@cloudbring
Last active May 1, 2017 02:42
Show Gist options
  • Save cloudbring/f1b7c1cd9916120701fb to your computer and use it in GitHub Desktop.
Save cloudbring/f1b7c1cd9916120701fb to your computer and use it in GitHub Desktop.
Building an Phoenix / Elixir Web App in June 2015

My Twisted Sense of Humor

Phoenix Ecosystem June 2015

Goal of this Document / Gist is to layout the resources and challenges to writing a complete modern web app with Phoenix and Elixir as the state of the projects are starting on June 2015

Why Phoenix and not Rails or Node.js?

The app that I'm building will use Real-time chat and SMS from Twilio, Stripe, GPS and IoT.

TODO: Put stats about performance, etc.

TODO: Put reasoning

  • High Reliablity
  • Hot Code Loading
  • Low Latency

More Later...


Main Resources:

Awesome Elixir
A curated list of amazingly awesome Elixir libraries, resources, and shiny things.

Elixir Phoenix
My ever-growing list of bookmarks related to Phoenix and Elixir development.

Github Trending Elixir Projects


Common Application Requirements

Things that any web developer will expect in a framework and it's ecosystem in 2015

Authentication

Build Status Hex.pm Hex.pm Github Issues Pending Pull-Requests

What does it do? - For now, it enables your users to register, login, logout and recover/reset their passwords.

Addict depends on:


Caching / Queueing

Kafka

Apache Kafka client for Elixir/Erlang.


Rough


Redis

Redis client for Elixir.

ORM

Atlas is an Object Relational Mapper for Elixir. (Work in progress. Expect breaking changes)

defmodule User do
  use Atlas.Model

  @table :users
  @primary_key :id

  field :id, :integer
  field :email, :string
  field :is_site_admin, :boolean
  field :archived, :boolean
  field :state, :string

  validates_numericality_of :id
  validates_presence_of :email
  validates_length_of :email, within: 5..255
  validates_format_of :email, with: %r/.*@.*/, message: "Email must be valid"
  validates :lives_in_ohio


  def lives_in_ohio(record) do
    unless record.state == "OH", do: {:state, "You must live in Ohio"}
  end

  def admins do
    where(archived: false) |> where(is_site_admin: true)
  end

  def admin_with_email(email) do
    admins |> where(email: email)
  end
end

iex> admin = Repo.first User.admin_with_email("[email protected]")
%User{id: 5, email: "[email protected]", archived: false, is_site_admin: true...}

Templates

EEx stands for Embedded Elixir. It allows you to embed Elixir code inside a string in a robust way:

iex> EEx.eval_string "foo <%= bar %>", [bar: "baz"]
"foo baz"

Email

See ExGrid

There are others but, I currently only care about Sendgrid. Feel free to make a pull request and add some.

I know there's support for Mailgun.


Logging

Official Elixir Logger


JSON Logger is a logger backend that outputs elixir logs in JSON format.

This project is originally designed to make Elixir apps work with Logstash easily. It aims at providing as much information for the log is possible, so the logs can be more easily analyzed by backend services like Elasticsearch.


Testing

Official Basic unit testing framework for Elixir.


Build Status

Elixir of life

A polite, well mannered and thoroughly upstanding testing framework for Elixir.

fact "about factorial" do
  factorial(0) |> ! 0
  factorial(0) |> 1

  list_of_factorials = Enum.map 0..3, fn n -> factorial(n) end

  list_of_factorials |> contains 1
  list_of_factorials |> !contains 2

  list_of_factorials |> [ _, 1, _, 6 ]
end

For browser automation and writing integration tests in Elixir.

defmodule HoundTest do
  use ExUnit.Case
  use Hound.Helpers

  hound_session

  test "the truth", meta do
    navigate_to("http://example.com/guestbook.html")

    find_element(:name, "message")
    |> fill_field("Happy Birthday ~!")
    |> submit_element()

    assert page_title() == "Thank you"
  end

end

Build Status Coverage Status Hex.pm Hex.pm Github Issues Pending Pull-Requests License

Record and replay HTTP interactions library for elixir. It's inspired by Ruby's VCR (https://github.com/vcr/vcr), and trying to provide similar functionalities.


Specific App Requirements

Real-Time Chat

Looks like this will need to be written by hand


SMS

See Twilio section


GPS

Roll your own


IoT

Currently not really a standard, more of requirement to have many channels open for long periods of time


External APIs

Twilio

All of the Twilio libraries are written by @danielberkompas so twilio should buy him a beer or three next time they are around.

Build Status Hex Version Hex Downloads Github Issues Pending Pull-Requests Inline docs

Telephonist makes it easy to design state machines for [Twilio][twilio] calls. These state machines bring TwiML and logic together in one place, making call flows easier to maintain.


Build Status Hex.pm Hex.pm Github Issues Pending Pull-Requests Inline docs

Twilio API client for Elixir


SendGrid

Only concerned with SendGrid at this point. Free free to add others

Build Status Hex.pm Hex.pm Github Issues Pending Pull-Requests


Payment Processing (TBD) Stripe, etc.

Build Status Hex.pm Hex.pm Github Issues Pending Pull-Requests

Payment processing library for Elixir. Based on Shopify's ActiveMerchant ruby gem

Supported Gateways


Travis Hex.pm Hex.pm Github Issues Pending Pull-Requests Coveralls GitHub license

BitPay Library for Elixir or Erlang

Powerful, flexible, lightweight interface to the BitPay Bitcoin Payment Gateway API. Can be used in an Elixir project or directly in an Erlang project as described in the Elixir Crash Course. This document assumes that you are using Elixir.


CRM / Customer Service


Example Code, Articles, Walkthroughs

Tutorials to Duplicate from Other Languages

Ruby on Rails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment