Create / launch a postgres instance on your local machine. If you have docker installed, you can use the pre-seed postgres docker image:
docker run -d --name cf_dev_db -p 5432:5432 captainfact/dev-db:latest
-
Without Docker (recommended if you want to make changes in the API)
mix deps.get
mix ecto.migrate
iex -S mix
-
With Docker
- Download project's dependencies with
./dev/get_dependencies.sh
- Migrate your database with
./dev/db_migrate.sh
- Start server with
./dev/start_server.sh
- Download project's dependencies with
Following services will be started:
- localhost:4000 - REST API
- localhost:4001 - REST API (https)
- localhost:4002 - GraphQL API
- localhost:4003 - GraphQL API (https)
- localhost:4004 - Atom feed
You can run tests with ./dev/test.sh
. You can filter which tests to run by
running something like ./dev/test.sh test/your_test_subpath
.
Check ./dev/test.sh
script comments for details.
Elixir offers very nice ways to separate concerns and work with microservices. This application is organized as an umbrella project which allows us to divide CaptainFact API into small apps.
.
โโโ apps
โย ย โโโ cf => Core functions as a library. **Not deployed**
โย ย โโโ cf_atom_feed => Atom feed.
โย ย โโโ cf_graphql => GraphQL API (public).
โย ย โโโ cf_jobs => Jobs.
โย ย โโโ cf_opengraph => An app that generate opengraph tags.
โย ย โโโ cf_rest_api => REST/WS API (private).
โย ย โโโ db => DB repository and schemas **Not deployed**
โย ย โโโ lib
โย ย โย ย โโโ db
โย ย โย ย โโโ db_schema => Contains all the schemas (Video, Speaker, Comment...etc)
โย ย โย ย โโโ db_type => Special types (SpeakerPicture...etc)
โย ย โย ย โโโ db_utils => Some utils functions
โย ย โโโ priv
โย ย ย ย โโโ repo/migrations => All DB migrations files
โโโ README.md => You're reading it right now. Are you?
โโโ rel => Release configs & tools
โย ย โโโ commands => Commands that will be available to run on the release (seed DB...etc)
โย ย โโโ hooks => Some hooks for automatically run commands when release run.
โย ย โโโ runtime_config => Runtime configurations for all apps.
โย ย โโโ config.exs => Releases configuration.
Code should follow Elixy Style Guide and Credo style guide as much as possible.
Avoid lines longer than 80 characters, never go beyond 110 characters.