Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/CaptainFact/captain-fact-api

πŸ”Ž CaptainFact - API. The one that serves and process all the data for https://captainfact.io
https://github.com/CaptainFact/captain-fact-api

absinthe elixir graphql hacktoberfest phoenix

Last synced: about 2 months ago
JSON representation

πŸ”Ž CaptainFact - API. The one that serves and process all the data for https://captainfact.io

Lists

README

        


CaptainFact.io



Discord




AGPL3
GitHub release
CI Status
Coverage Status












# Install & Run

## Prerequisites

You need to install Elixir. We recommand using [asdf-vm](https://github.com/asdf-vm/asdf#setup).
Check their documentation on how to install it, then run `asdf install` from
root `captain-fact-api` folder.

## Start DB

Create / launch a PostgreSQL instance on your local machine. If you have
Docker installed, you can use the pre-Seed PostgreSQL Docker image:

`docker run -d --name cf_dev_db -p 5432:5432 captainfact/dev-db:latest`

## Start API

- `mix deps.get` --> Get dependencies
- `mix ecto.create` --> Create DB
- `mix ecto.migrate` --> Migrate DB
- `iex -S mix` --> Start project

Following services will be started:

- [localhost:4000](http://localhost:4000) - REST API
- [localhost:4001](https://localhost:4001) - REST API (HTTPS)
- [localhost:4002](http://localhost:4002) - GraphQL API
- [localhost:4003](https://localhost:4003) - GraphQL API (HTTPS)
- [localhost:4004](http://localhost:4004) - Atom feed

You can also see all e-mail sent, by going to http://localhost:4000/\_dev/mail

## Other useful commands

- `mix test` --> Run tests
- `mix test.watch` --> Run test watcher
- `mix format` --> Format code
- `mix ecto.gen.migration [migration_name]` --> Generate migration

# Project architecture

This application is organized as an [umbrella project](https://elixir-lang.org/getting-started/mix-otp/dependencies-and-umbrella-apps.html) 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_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 utility 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 => Release configuration.
```

# Linked projects

- [Community discussions and documentation](https://github.com/CaptainFact/captain-fact/)
- [Front-end](https://github.com/CaptainFact/captain-fact-frontend)
- [Extension](https://github.com/CaptainFact/captain-fact-extension)
- [Overlay injector](https://github.com/CaptainFact/captain-fact-overlay-injector)