// ----------------------------------------------------------------------------- // Home-Ka — US real-estate aggregator (Groupe KA) // Author: Simon-Pierre Boucher — contact@spboucher.ai // pages/Stats.tsx : simple live dashboard — totals, by state, by type, // recent syncs (/api/stats). // ----------------------------------------------------------------------------- import { useEffect, useState } from "react"; import { Stats, fetchStats, sourceName } from "../api"; const n = (x: number | null | undefined) => x == null ? "—" : Math.round(x).toLocaleString("en-US"); const usd = (x: number | null | undefined) => x == null ? "—" : "$" + Math.round(x).toLocaleString("en-US"); function ago(ts: number): string { const s = Math.max(0, Math.floor(Date.now() / 1000 - (ts > 1e12 ? ts / 1000 : ts))); if (s < 3600) return `${Math.round(s / 60)} min ago`; if (s < 172800) return `${Math.round(s / 3600)} h ago`; return `${Math.round(s / 86400)} d ago`; } export default function StatsPage() { const [stats, setStats] = useState(null); const [error, setError] = useState(null); useEffect(() => { fetchStats().then(setStats).catch((e) => setError(String(e))); }, []); return (
The aggregated market

Statistics

Live dashboard of the homes for sale aggregated by Home-Ka — volumes and prices computed on the platform's real data (source duplicates excluded, "price on request" excluded).

{error && (

Statistics unavailable

{error}

)} {!stats && !error &&
Loading…
} {stats && ( <> {/* --- totals row -------------------------------------------------- */}
{n(stats.total)}
Homes for sale
{n(stats.properties)}
Physical properties tracked
{n(stats.states)}
States
{n(stats.cities)}
Cities
{n(stats.sources)}
Sources
{usd(stats.avg_price)}
Average price
{usd(stats.min_price)}
Lowest price
{usd(stats.max_price)}
Highest price
{/* --- by state ----------------------------------------------------- */} {stats.by_state.length > 0 && (

By state

{stats.by_state.map((r) => ( ))}
StateHomesAverage price
{r.state} {n(r.n)} {usd(r.avg_price)}
)} {/* --- by property type ---------------------------------------------- */} {stats.by_type.length > 0 && (

By property type

{stats.by_type.map((r) => ( ))}
TypeHomesAverage price
{r.property_type} {n(r.n)} {usd(r.avg_price)}
)} {/* --- recent syncs --------------------------------------------------- */} {(stats.recent_syncs?.length ?? 0) > 0 && (

Recent syncs

{stats.recent_syncs!.map((s, i) => ( ))}
SourceWhenFound AddedRemovedStatus
{sourceName(s.source)} {ago(s.ts)} {n(s.found)} {n(s.added)} {n(s.removed)} {s.ok ? OK : Error}
)} )}

Updated automatically — statistics are computed on the aggregated listings. Every listing links back to the original announcement at the source.

); }