This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
VATcomply is a free API service that provides:
- VAT number validation
- User IP geolocation
- Foreign exchange rates from the European Central Bank
The project consists of a Django backend API service and a Next.js frontend website.
- Django: Core web framework with async views and ORM
- Django Ninja: REST API framework built on top of Django
- Pydantic: Data validation
- APScheduler: Background task scheduler for fetching currency rates
- Httpx: Async HTTP client for external API calls
- Uvicorn: ASGI server
- Next.js: React-based frontend framework
- SCSS: For styling components
# Set up Python environment
pyenv shell 3.11.x
virtualenv env
. env/bin/activate
# Install dependencies
make pip # or: uv pip install -r requirements.in --upgrade
make freeze # or: uv pip compile requirements.in -o requirements.txt# Run development server
make run # or: export DEBUG=True; uvicorn vatcomply.asgi:application --reload
# Database migrations
make migrations # Create new migrations
make migrate # Apply migrations
# Data loading
python manage.py load_countries # Load country data
python manage.py load_rates # Load exchange rates (historical)
python manage.py load_rates --last-90-days # Load last 90 days of rates# Run all tests
make test # or: uv run pytest
# Run specific test file
uv run pytest vatcomply/tests/test_rates.py
# Run a specific test function
uv run pytest vatcomply/tests/test_rates.py::test_latest_api
# Verbose output
uv run pytest -v
# Test with coverage report
make coverage # or: uv run coverage run -m pytest && uv run coverage report -m- API: https://api.vatcomply.com
- Documentation: https://www.vatcomply.com/api/exchange-rates
-
API Endpoints (
vatcomply/api.py)/rates: Foreign exchange rates from ECB/vat: VAT number validation/countries: List of countries and their details/currencies: Supported currency information/geolocate: IP-based geolocation/iban: IBAN validation
-
Data Models (
vatcomply/models.py)Rate: Exchange rate data by dateCountry: Country information and metadata
-
Schemas (
vatcomply/schemas.py)- Pydantic models for request/response validation
-
Background Tasks (
vatcomply/middleware.py)BackgroundTasksMiddleware: ASGI middleware that runs periodic tasks- Scheduler that fetches currency rates from ECB
-
Management Commands (
vatcomply/management/commands/)load_countries.py: Imports country dataload_rates.py: Imports exchange rates from ECB
-
Exchange rate data:
- Fetched from ECB XML endpoints
- Stored in the
Ratemodel with date as primary key - Updated hourly by the background scheduler
- Served through the
/ratesAPI endpoint with options for base currency, symbols, and dates
-
Country data:
- Imported from JSON source
- Stored in the
Countrymodel - Used for VAT validation and geolocation features
Key environment variables used:
DEBUG: Enable debug mode (default: False)SECRET_KEY: Django secret keyALLOWED_HOSTS: Comma-separated list of allowed hostsBACKGROUND_SCHEDULER: Enable background scheduler (default: False)THROTTLE: Enable request throttling (default: True)BASE_URL: Base URL for the application (default: "http://localhost:8000")