Home

Awesome

<div align="center"> <img src="logo.svg" width="300" /> <p> <br /><strong>The first developer-oriented translation tool</strong> <br />True asynchronous flow between translators and your team. <br /> </p> </div>

DemoWebsiteGraphiQL

Actions Status Coverage Status Join the chat at https://gitter.im/mirego/accent Docker Docker Registry

Accent provides a powerful abstraction around the process maintaining translations in a web/native app.

Contents

SectionDescription
🚀 Getting startedQuickly setup a working app
🚧 RequirementsDependencies required to run Accent’ stack
🎛 Mix commandsHow to execute mix task with the Twelve-Factor pattern
🏎 QuickstartSteps to run the project, from API to webapp, with or without Docker
🌳 Environment variablesRequired and optional env var used
✅ TestsHow to run the extensive tests suite
🚀 HerokuEasy deployment setup with Heroku
🌎 ContributeHow to contribute to this repo

🚀 Getting started

Easiest way to run an instance of Accent is by using the offical docker image: https://hub.docker.com/r/mirego/accent

  1. The only external dependancy is a PostgreSQL database.
  2. Create a .env file. Example:
DATABASE_URL=postgresql://postgres@docker.for.mac.host.internal/accent_development
DUMMY_LOGIN_ENABLED=1
  1. Run the image
$ docker run --env-file .env -p 4000:4000 mirego/accent

This will start the webserver on port 4000, migrate the database to have an up and running Accent instance!

🚧 Requirements

🎛 Executing mix commands

The app is modeled with the Twelve-Factor App architecture, all configurations are stored in the environment.

When executing mix commands, you should always make sure that the required environment variables are present. You can source, use nv or a custom l33t bash script.

Every following steps assume you have this kind of system.

But Accent can be run with default environment variables if you have a PostgreSQL user named postgres listening on port 5432 on localhost.

Example

With nv you inject the environment keys in the context with:

$ nv .env mix <mix command>

🏎 Quickstart

This is the full development setup. To simply run the app, see the Getting started instructions

  1. If you don’t already have it, install nodejs with brew install nodejs
  2. If you don’t already have it, install elixir with brew install elixir
  3. If you don’t already have it, install libyaml with brew install libyaml
  4. If you don’t already have it, install postgres with brew install postgres or the Docker setup as described below.
  5. Install dependencies with make dependencies
  6. Create and migrate your database with mix ecto.setup
  7. Start Phoenix endpoint with mix phx.server
  8. Start Ember server with npm run start --prefix webapp

That’s it!

Makefile

The Makefile should be the main entry for common tasks such as tests, linting, Docker, etc. This simplify the development process since you don’t have to search for which service provides which command. mix, npm, prettier, docker, stylelint, etc are all used in the Makefile.

Docker

For the production setup, we use Docker to build an OTP release of the app. With docker-compose, you can run the image locally. Here are the steps to have a working app running locally with Docker:

When running the production env, you need to provide a valid GOOGLE_API_CLIENT_ID in the docker-compose.yml file.

  1. Run make build to build the OTP release with Docker
  2. Run make dev-start-postgresql to start an instance of Postgresql. The instance will run on port 5432 with the postgres user. You can change those values in the docker-compose.yml file.
  3. Run make dev-start-application to start the app! The release hook of the release will execute migrations and seeds before starting the webserver on port 4000 (again you can change the settings in docker-compose.yml)

That’s it! You now have a working Accent instance without installing Elixir or Node!

🌳 Environment variables

Accent provides a default value for every required environment variable. This means that with the right PostgreSQL setup, you can just run mix phx.server.

VariableDefaultDescription
API_HOSTnoneThe API host, if the API is hosted by the same host as the webapp (like in a production setup) it should not be included in env var. It is required for the webapp in dev.
API_WS_HOSTnoneThe API Websocket host, same requirements and defaults as API_HOST
DATABASE_URLpostgres://localhost/accent_developmentA valid database URL
PORT4000A port to run the API on
WEBAPP_PORT4200A port to run the Webapp on (only used in dev environment)
WEBAPP_URLhttp://localhost:4000The Web client’s endpoint. Used in the authentication process and in the sent emails.

Production setup

VariableDefaultDescription
RESTRICTED_DOMAINnoneIf specified, only authenticated users from this domain name will be able to create new projects.
FORCE_SSLfalseIf the app should always be served by https (and wss for websocket)
SENTRY_DSNnoneThe secret Sentry DSN used to collect API runtime errors
WEBAPP_SENTRY_DSNnoneThe public Sentry DSN used to collect Webapp runtime errors

Authentication setup

Various login providers are included in Accent using Ueberauth to abstract services.

VariableDefaultDescription
DUMMY_LOGIN_ENABLEDnoneIf specified, the password-less authentication (with only the email) will be available.
GITHUB_CLIENT_IDnone
GITHUB_CLIENT_SECRETnone
GOOGLE_API_CLIENT_IDnone
GOOGLE_API_CLIENT_SECRETnone
SLACK_CLIENT_IDnone
SLACK_CLIENT_SECRETnone
SLACK_TEAM_IDnone
DISCORD_CLIENT_IDnone
DISCORD_CLIENT_SECRETnone

Start as kubernetes helm chart

You can up project with this helm chart

Email setup

If you want to send emails, you’ll have to configure the following environment variables:

VariableDefaultDescription
MAILER_FROMnoneThe email address used to send emails.
SENDGRID_API_KEYnoneUse SendGrid to send emails
MANDRILL_API_KEYnoneUse Mandrill to send emails
MAILGUN_API_KEYnoneUse Mailgun to send emails
SMTP_ADDRESSnoneUse an SMTP server to send your emails.
SMTP_API_HEADERnoneAn optional API header that will be added to sent emails.
SMTP_PORTnoneThe port ex: (25, 465, 587).
SMTP_PASSWORDnoneThe password for authentification.
SMTP_USERNAMEnoneThe username for authentification.

Kubernetes helm chart setup

You can setup the project with a helm chart like this one. This project uses a fork by andreymaznyak and not this canonical repository. The specs and values may need to be updated if you use this repo.

✅ Tests

API

Accent provides a default value for every required environment variable. This means that with the right PostgreSQL setup (and a few setup commands), you can just run mix test.

$ npm --prefix webapp run build
$ mix run ./priv/repo/seeds.exs
$ mix test

The full check that runs in the CI environment can be executed with ./priv/scripts/ci-check.sh.

🚀 Deploy on Heroku

An Heroku-compatible app.json makes it easy to deploy the application on Heroku.

<a href="https://heroku.com/deploy?template=https://github.com/mirego/accent"> <img src="https://www.herokucdn.com/deploy/button.svg" alt="Deploy on Heroku" /> </a>

🌎 Contribute

Before opening a pull request, please open an issue first.

Once you’ve made your additions and the test suite passes, go ahead and open a PR!

Don’t forget to run the ./priv/scripts/ci-check.sh script to make sure that the CI build will pass :)

License

Accent is © 2015-2019 Mirego and may be freely distributed under the New BSD license. See the LICENSE.md file.

About Mirego

Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We’re a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.

We also love open-source software and we try to give back to the community as much as we can.