- FastAPI backend: PostGIS estimator + 3 scrapers (Avito/Cian/Yandex)
- Next.js 15 frontend: tradein.html mockup design, basePath=/trade-in
- WeasyPrint PDF (Брусника-style 4-page report)
- Address autocomplete с typo-tolerance + 6 EKB presets
- Изолированный docker stack gendesign-tradein (отдельная postgres БД)
- Caddy inline routes: gendsgn.ru/trade-in/* и /trade-in/api/v1/*
- Forgejo Actions: .forgejo/workflows/deploy-tradein.yml (shell-based GHCR login)
- Триггер только по paths: tradein-mvp/** (не пересекается с deploy.yml)
- Образы: ghcr.io/lekss361/gendesign-tradein-{backend,frontend}:latest
Первый запуск на сервере (вручную, один раз):
- создать /opt/gendesign/tradein-mvp/.env.runtime (postgres pwd, contact email)
- docker network create gendesign_shared (если нет)
- docker compose -p gendesign-tradein up -d
- docker compose -p gendesign exec caddy caddy reload
43 lines
1.4 KiB
PL/PgSQL
43 lines
1.4 KiB
PL/PgSQL
BEGIN;
|
||
|
||
CREATE TABLE IF NOT EXISTS trade_in_estimates (
|
||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||
|
||
-- Input snapshot
|
||
address text NOT NULL,
|
||
lat double precision,
|
||
lon double precision,
|
||
area_m2 numeric(8, 2) NOT NULL,
|
||
rooms int NOT NULL,
|
||
floor int NOT NULL,
|
||
total_floors int NOT NULL,
|
||
year_built int,
|
||
house_type text,
|
||
repair_state text,
|
||
has_balcony boolean,
|
||
|
||
-- Output
|
||
median_price bigint NOT NULL,
|
||
range_low bigint NOT NULL,
|
||
range_high bigint NOT NULL,
|
||
median_price_per_m2 int NOT NULL,
|
||
confidence text NOT NULL CHECK (confidence IN ('low', 'medium', 'high')),
|
||
n_analogs int NOT NULL DEFAULT 0,
|
||
analogs jsonb NOT NULL DEFAULT '[]'::jsonb,
|
||
actual_deals jsonb NOT NULL DEFAULT '[]'::jsonb,
|
||
|
||
-- Metadata
|
||
created_at timestamptz NOT NULL DEFAULT NOW(),
|
||
expires_at timestamptz NOT NULL DEFAULT NOW() + interval '24 hours'
|
||
);
|
||
|
||
CREATE INDEX IF NOT EXISTS trade_in_estimates_created_idx
|
||
ON trade_in_estimates (created_at DESC);
|
||
|
||
CREATE INDEX IF NOT EXISTS trade_in_estimates_expires_idx
|
||
ON trade_in_estimates (expires_at);
|
||
|
||
COMMENT ON TABLE trade_in_estimates IS
|
||
'#314 TradeIn MVP — стор estimates с input snapshot + aggregated output. TTL 24h.';
|
||
|
||
COMMIT;
|