# Tracker - tracking artists

```

alembic revision --autogenerate -m "<message>"

alembic upgrade head

```

### Conventions

`twt`  -  code and prefix for twitter, eid as the entity id

`sc` - code and profexi for soundcloud

`spy` - code a prefix for spotify

`yt` - code a prefix for youtube

### Layout

`/tracker` - main python package

`/api` - python flask api (uses `tracker` package)

`/alembic` - alembic scripts for main db (note some sub-packages in tracker are doing there own alembic (eg. tidal)) 

`/docker` - docker files for building the images for deployment

`/scripts` - cli scripts for developing / ops related tasks. (also jupyter notebooks under here)

`/bin` - executables called by the daily scraper (ran in docker ECS, not cli) 


### How To

#### Add a dependency
 - decide if it's in requirements tracker or just api
 - add to the relevant requirements-*.txt in the /docker directory
 - run ./script/build_deps.sh
    - this will build and tag a new trackerdeps image
 - run ./scripts/compose_tracker_unit.sh
    - this will build new tracker image, and run unit tests


#### Run API Locally

From a fresh checkout:
  - make a virtual env
```
python3 -m venv venv
source ./venv/bin/activate
```
 - install all the requirements. These are in different files for the docker builds, but locally you should install everything.
```
pip install -r docker/requirements-compile.txt
pip install -r docker/requirements-tracker.txt
pip install -r docker/requirements-api.txt
pip install -r requirements-dev.txt
```
- launch the 'local resources' in docker, these are the postgres db, dynamo local and elastic search.

```
./scripts/run_docker_local_resources.sh
```

- in another shell, run the alembic scripts to upgrade the database.
```
alembic upgrade head
```
- run the local flask api

```
./scripts/localapi.sh seed
```
 
 The `seed`  argument adds some test data to the database. You don't need to seed everytime. 
 
 Flask will be running in debug mode and will restart on changes.  

