Skip to content
/ ai Public

ai 愛(あい) — Phoenix & Elixir JSON API powering mirai.audio

License

Notifications You must be signed in to change notification settings

mirai-audio/ai

Repository files navigation

ai (あい)

CircleCI Coveralls branch Phoenix StackShare

Phoenix & Elixir JSON API powering mirai.audio

Docs

Prerequisites

You will need the following tools properly installed:

# macOS
brew install elixir  # installs Erlang & Elixir
brew install docker  # required to run PostgreSQL
mix local.hex        # install hex package manager
mix local.rebar      # install rebar
mix deps.get         # install app dependencies

Running / Development

Run the PostgreSQL (10.5) db server in Docker. Connect with postgres@localhost with password postgres for local development.

docker run -it -p 5432:5432 --rm \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=postgres \
  -e POSTGRES_DB=postgres \
  --name postgres \
  postgres:10.5

Environment variables

The following environment variables are available to override fallback (dev) configuration, it works best to add them to a .env file. Please see .env.example for examples.

ENV_AI_MIR_URL=https://mirai.audio       # URL of Mir, frontend
ENV_AI_DB_URL=ecto://postgres:postgres@localhost/ai_dev
ENV_AI_HOST=api.mirai.audio
ENV_AI_PORT=4000
ENV_AI_SECRET_KEY_BASE=<64-char string>  # use `mix phx.gen.secret` to generate a secret
ENV_AI_GUARDIAN_SECRET_KEY=<64-char string>
ENV_AI_DB_POOL_SIZE=20
ENV_AI_TWITTER_CONSUMER_KEY=changeme     # Twitter OAuth Consumer Key (API Key)
ENV_AI_TWITTER_CONSUMER_SECRET=changeme  # Twitter OAuth Consumer Secret (API Secret)

To create the database schema, run migrations and start Phoenix:

# set .env file environment variables 
export $(cat .env | xargs) && \
  mix ecto.setup && \
  mix phx.server

Now you can visit localhost:4000 from your browser.

Social Authentication

The client app, Mir can use Twitter OAuth 1.0a to authenticate users using the "Sign in with Twitter" API feature. To develop to this API, create a Twitter developers account, and register a twitter app. You'll need to enable "Sign in with Twitter" and set a callback URL:

https://app.mirai.audio/login/twitter/callback will be used in production, and http://dev.mirai.audio:4000/login/twitter/callback will be used for local development. Make sure you add an entry in your /etc/hosts file pointing 127.0.0.1 to dev.mirai.audio as twitter does not allow OAuth redirects back to localhost.

Running Tests

mix test

LICENSE

MIT

A product of (せい)(しん)(こう)() (seishinkouki) Co., Ltd

About

ai 愛(あい) — Phoenix & Elixir JSON API powering mirai.audio

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published