The Trade Tariff Backend provides an API which allows to search commodity codes
for import and export for tax, duty and licences that apply to goods, from and
to UK and NI.
Projects using the Trade Tariff (TT) API:
Development
Make sure you install and enable all pre-commit hooks https://pre-commit.com/
Dependencies
- Ruby v3.2
- Postgresql v13
- OpenSearch v2
- Redis
These can be configured by running docker-compose up
or by manual installation.
Setup
- Clone this repo
- Install the correct ruby version according to the
.ruby-version
- eg using
rbenv
or asdf
.
- Setup the app:
- If you don’t have a db dump then run
bin/setup
without parameters.
- NB: this will result in a empty dataset.
- If you do have a database dump, run
bin/setup <path/to/dump/ file>
.
Sidekiq is started to build the search indexes - once the jobs have all
finished (10 [done]
jobs, one after the other), hit Ctrl-C
to exit
sidekiq.
- Start the app with
bin/rails s
. If you want to run rails plus the sidekiq worker, run bin/dev
.
Database
If you have access, you can download a database dump from our environments.
Details of how to fetch a database dump are available on Slack.
To restore the database dump:
psql -h localhost tariff_development < tariff-merged-staging.sql
Running an XI service
- Add
SERVICE=xi
to .env.development.local
- Rebuild the search indexes
bin/rake tariff:reindex
bundle exec sidekiq
- Run the rails server as normal -
bin/rails s
These are run daily by a background job, CdsUpdatesSynchronizerWorker
or
TaricUpdatesSynchronizerWorker
. Additional environment variables are needed to
run these jobs locally.
These should be added to .env.development.local
:
AWS_ACCESS_KEY_ID
AWS_BUCKET_NAME
AWS_REGION
AWS_REPORTING_BUCKET_NAME
AWS_SECRET_ACCESS_KEY
HMRC_API_HOST
HMRC_CLIENT_ID
HMRC_CLIENT_SECRET
TARIFF_FROM_EMAIL
TARIFF_IGNORE_PRESENCE_ERRORS
TARIFF_MANAGEMENT_EMAIL
TARIFF_SUPPORT_EMAIL
TARIFF_SYNC_EMAIL
TARIFF_SYNC_HOST
TARIFF_SYNC_PASSWORD
TARIFF_SYNC_USERNAME
GREEN_LANES_UPDATE_EMAIL
GREEN_LANES_NOTIFY_MEASURE_UPDATES
Licence
Trade Tariff is licenced under the MIT licence