Skip to content

Commit

Permalink
django based vatcomply
Browse files Browse the repository at this point in the history
  • Loading branch information
madisvain committed Dec 25, 2023
1 parent d9ca374 commit 5670165
Show file tree
Hide file tree
Showing 49 changed files with 930 additions and 1,252 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/pytest.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: VATcomply tests

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
run: |
python manage.py test
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Madis Väin
Copyright (c) 2023 Madis Väin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
run:
uvicorn app:app --reload
export DEBUG=True; uvicorn vatcomply.asgi:application --reload

pip:
pip install -r requirements.in --upgrade

migrate:
PYTHONPATH=.:$PYTHONPATH alembic upgrade head
python manage.py migrate

migrations:
python manage.py makemigrations

test:
export TESTING=True; pytest -s --disable-warnings
python manage.py test --keepdb
2 changes: 0 additions & 2 deletions Procfile

This file was deleted.

41 changes: 24 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# VATcomply

VATcomply is a free API service for vat number validation, user ip geolocation and foreign exchange rates [published by the European Central Bank](https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html).
[VATcomply](https://www.vatcomply.com) is a free API service for vat number validation, user ip geolocation and foreign exchange rates [published by the European Central Bank](https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html).

## Usage

Expand All @@ -12,12 +12,6 @@ Get the latest foreign exchange rates.
GET /rates
```

Get historical rates for any day since 1999.

```http
GET /rates/2018-03-26
```

Rates are quoted against the Euro by default. Quote against a different currency by setting the base parameter in your request.

```http
Expand All @@ -30,7 +24,7 @@ Request specific exchange rates by setting the symbols parameter.
GET /rates?symbols=USD,GBP
```

#### Rates history
#### Rates history and query parameters combinations

Get historical rates for a date

Expand Down Expand Up @@ -60,22 +54,21 @@ let demo = () => {
alert("£1 = $" + rate.toFixed(4));
};

fetch("https://api.vatcomply.com/latest")
fetch("https://api.vatcomply.com/rates")
.then((resp) => resp.json())
.then((data) => (fx.rates = data.rates))
.then(demo);
```

## Stack

VATcomply API is built upon [Starlette](https://github.com/encode/starlette) the asyncronous Python framework to achieve high throughput. The current setup can asyncronously handle thousands of requests per second.
VATcomply API is built upon [Django](https://www.djangoproject.com/) with asyncronous views, [Pydantic](https://docs.pydantic.dev/latest/) and asyncronous ORM queries to achieve high throughput. The current setup can asyncronously handle thousands of requests per second.

#### Libraries used

- [Starlette](https://github.com/encode/starlette)
- [SQLAlchemy](https://www.sqlalchemy.org/)
- [Django](https://www.djangoproject.com/)
- [Pydantic](https://docs.pydantic.dev/latest/)
- [APScheduler](https://github.com/agronholm/apscheduler)
- [uvloop](https://github.com/MagicStack/uvloop)
- [ultraJSON](https://github.com/esnme/ultrajson)

## Deployment
Expand Down Expand Up @@ -105,26 +98,40 @@ On initialization it will check the database. If it's empty all the historic rat
## Development

```shell
uvicorn app:app --reload
export DEBUG=True; uvicorn vatcomply.asgi:application --reload
```

or
or for simplicity a Makefile is provided with all the commands for development.

```shell
make run
```

## Migrations

Make migrations

```shell
make migrations
```

Run migrations

```shell
make migrate
```

## Tests

```shell
PYTHONPATH=.:\$PYTHONPATH alembic revision --autogenerate -m "create users table"
make test
```

## Contributing

Thanks for your interest in the project! All pull requests are welcome from developers of all skill levels. To get started, simply fork the master branch on GitHub to your personal account and then clone the fork into your development environment.

Madis Väin (madisvain on Github, Twitter) is the original creator of the VATcomply API.
Madis Väin ([madisvain](https://github.com/madisvain) on Github) is the original creator of the VATcomply API.

## License

Expand Down
72 changes: 0 additions & 72 deletions alembic.ini

This file was deleted.

23 changes: 0 additions & 23 deletions app.json

This file was deleted.

Loading

1 comment on commit 5670165

@vercel
Copy link

@vercel vercel bot commented on 5670165 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.