- Clone
git clone https://github.com/azizjon-aliev/polis-calc.git && cd polis-calc
- Env
cp .env.example .env
# edit .env (DB, secrets, etc.)
- With Docker
docker compose up --build
# open http://0.0.0.0:8000/docs or /redoc
- Without Docker (dev)
# create venv (using uv tool in this repo)
uv venv; source .venv/bin/activate
uv sync # install deps
uv run alembic upgrade head
uv run uvicorn app.main:app --reload
-
Auth
POST /auth/register
— register (returns JWT)POST /auth/login
— login (returns access & refresh JWT)
-
Quotes
POST /quotes
— calculate a quote (body: tariff, age, experience, car_type) — returns price + saved quoteGET /quotes/{id}
— get quote by id
-
Applications
POST /applications
— create application (name, phone, email, tariff, quote_id)GET /applications/{id}
— view application (authenticated user)
Other: unified error format, input validation on all endpoints.
- Migrations with Alembic; add key indexes for lookup fields (quote id, user_id, created_at).
- Swagger/OpenAPI enabled; basic security headers + CORS configured.
- Optional:
docker compose up
brings API + PostgreSQL. Logging + simple request counter included.
Tariff
standard
→1.0
premium
→1.5
Age
age < 25
→1.2
25 ≤ age ≤ 60
→1.0
age > 60
→1.1
Driving experience
< 2 years
→1.3
2–4 years
→1.1
≥ 5 years
→1.0
Car type
sedan
→1.0
suv
→1.2
truck
→1.3
Formula
final_price = base_price
* tariff_coeff
* age_coeff(age)
* experience_coeff(experience)
* car_type_coeff
Round with:
Decimal.quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
Notes
settings.quote_base_price
must beDecimal
. Use Decimal end-to-end and serialize to string in JSON if needed.- Coefficients are static by default — move to config/DB if you need runtime changes.
- Validate
age
andexperience
as positive integers in schemas.