Skip to content

azizjon-aliev/polis-calc

Repository files navigation

Polis Calculation Project — Setup Guide (compact)

Example docs

Swagger Docs

Redoc Docs


Quick start

  1. Clone
git clone https://github.com/azizjon-aliev/polis-calc.git && cd polis-calc
  1. Env
cp .env.example .env
# edit .env (DB, secrets, etc.)
  1. With Docker
docker compose up --build
# open http://0.0.0.0:8000/docs or /redoc
  1. 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

API surface (short)

  • 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 quote
    • GET /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.


DB & infra

  • 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.

Quote calculation — coefficients (compact)

Tariff

  • standard1.0
  • premium1.5

Age

  • age < 251.2
  • 25 ≤ age ≤ 601.0
  • age > 601.1

Driving experience

  • < 2 years1.3
  • 2–4 years1.1
  • ≥ 5 years1.0

Car type

  • sedan1.0
  • suv1.2
  • truck1.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 be Decimal. 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 and experience as positive integers in schemas.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published