# core-images

The primary purpose of the core-images is to provide generic abd efficient way to access
artists, albums and other images located in different sources, like Spotify, Apple Music,
SCUBA, etc.

# Project context and relations

![System context diagram](docs/context_diagram.svg)

![Container diagram](docs/container_diagram.svg)

# Environment

Expects the following environment variables:

- APPLE_MUSIC_KEY_ID
- APPLE_MUSIC_SECRET_KEY
- APPLE_MUSIC_TEAM_ID
- DJANGO_ENVIRONMENT
- SENTRY_DSN
- SPOTIFY_CLIENT_ID
- SPOTIFY_CLIENT_SECRET
- AUTH0_DOMAIN
- AUTH0_MANAGEMENT_CLIENT_ID
- AUTH0_MANAGEMENT_CLIENT_SECRET
- SCUBA_API_HOST
- SCUBA_API_KEY
- REDIS_URL
- DB_NAME
- DB_USER
- DB_PASS
- DB_HOST
- DB_PORT
- ATLAS_PUBLIC_KEY_URL
- ATLAS_LOGIN_URL
- ATLAS_LOGOUT_URL
- CLOUDFRONT_DISTRIBUTION_ID
- VENDOR_DATA_TIMEOUT
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_STORAGE_BUCKET_NAME
- AWS_S3_ENDPOINT_URL (e.g. s3.amazonaws.com)
- AWS_S3_CUSTOM_DOMAIN (Cloudfront domain)

## Development

Python package dependencies are specified under in the `requirements.txt`.
Be sure to put only top level packages there, avoid `pip freeze`.
All sub dependencies will be pinned on the docker image artifacts level.

To develop core-images,
install requirements via the `pip install -f requirements.txt`.

Or use `app` service from the docker-compose config for your local
development needs.

To test features, that are heavily rely on the Atlas auth, there are 2 possible
options:
- authorize on the atlas dev env, and grab the token from the `dna_bearer_token`
  cookie there
- use the additional service `app_https`

Before using the `app_https`, follow the required steps, to configure the
local system:
- install [Mkcert](https://github.com/FiloSottile/mkcert) in any way, suitable for your local OS
- run `mkcert -install`
- run `mkcert local.atlas.stream` inside the project folder to create certs
- add the following record to your hosts file `127.0.0.1 local.atlas.stream`
  (usually `/etc/hosts`)
- use the [local.atlas.stream](https://local.atlas.stream) for the app

# Network dependencies

## Caching

Redis is being user for application cache.
Use REDIS_URL env var for connection setup.

## Database
Postgres database is being used for application data.

## S3
AWS S3 storage is being used for user uploaded files.
For local dev env Minio S3 compatible storage is being used
Refer to [docker-compose.yml](docker-compose.yml) for more details.

## Sentry

If the SENTRY_DSN env var is set, will report logged errors to
Sentry. The DJANGO_ENVIRONMENT env var gets passed on to Sentry to
inform Sentry which environment reported the error.
