Initial public release

Aurum — a self-hosted personal finance operating system: cash flow,
net worth tracking, budgets, goals, recurring payments, reports,
proactive alerts, and a compound-interest returns calculator, all
bilingual (RU/EN) and mobile-first. Ships as a three-container Docker
Compose stack (Postgres + FastAPI + nginx-served React frontend).

See README.md for setup and CONTRIBUTING.md for development.
This commit is contained in:
ZProger
2026-08-16 18:39:52 +03:00
commit fe9b079c12
199 changed files with 14410 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/Card";
import { getCategoryIcon } from "@/lib/icons";
import { formatCurrency } from "@/lib/format";
import { useTranslation } from "@/lib/i18n";
import { translateCategoryName } from "@/lib/categoryLabels";
import type { CategoryRankingItem } from "@/types";
interface CategoryRankingCardProps {
items: CategoryRankingItem[];
isLoading: boolean;
selectedCategoryId: number | null;
onSelectCategory: (categoryId: number) => void;
}
/** Ranks every expense category by total spent over the currently selected
* period — unlike the Dashboard breakdown (locked to one month) or the
* detail chart below (locked to one category), this is "which category
* costs the most" across the whole range at once. Clicking a row drills
* into that category in the detail chart/transaction list below. */
export function CategoryRankingCard({ items, isLoading, selectedCategoryId, onSelectCategory }: CategoryRankingCardProps) {
const { t } = useTranslation();
return (
<Card>
<CardHeader>
<CardTitle>{t("reports.categoryRankingTitle")}</CardTitle>
</CardHeader>
<CardContent>
{isLoading ? (
<p className="py-10 text-center text-sm text-text-muted">{t("common.loading")}</p>
) : items.length === 0 ? (
<p className="py-10 text-center text-sm text-text-muted">{t("reports.noRankingData")}</p>
) : (
<ul className="divide-y divide-gridline">
{items.map((item, index) => {
const Icon = getCategoryIcon(item.icon);
const isSelected = item.category_id === selectedCategoryId;
return (
<li key={item.category_id}>
<button
type="button"
onClick={() => onSelectCategory(item.category_id)}
className={`flex w-full items-center gap-3 rounded-lg py-2.5 text-left transition-colors hover:bg-surface-2 ${
isSelected ? "bg-surface-2" : ""
}`}
>
<span className="w-4 shrink-0 text-right text-xs tabular-nums text-text-muted">{index + 1}</span>
<span
className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full"
style={{ backgroundColor: `${item.color}26` }}
>
<Icon size={15} style={{ color: item.color }} />
</span>
<span className="min-w-0 flex-1 truncate text-sm text-text-primary">
{translateCategoryName(item.name)}
</span>
<span className="hidden w-24 shrink-0 items-center gap-2 sm:flex">
<span className="h-1.5 flex-1 overflow-hidden rounded-full bg-surface-2">
<span
className="block h-full rounded-full"
style={{ width: `${item.percent}%`, backgroundColor: item.color }}
/>
</span>
<span className="w-9 shrink-0 text-right text-xs text-text-muted tabular-nums">
{item.percent.toFixed(0)}%
</span>
</span>
<span className="shrink-0 pr-1 text-sm font-medium tabular-nums text-text-primary">
{formatCurrency(item.amount)}
</span>
</button>
</li>
);
})}
</ul>
)}
</CardContent>
</Card>
);
}

View File

@@ -0,0 +1,114 @@
import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis } from "recharts";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/Card";
import { formatCurrency, getIntlLocale, pluralizeRu } from "@/lib/format";
import { useTranslation, type Language } from "@/lib/i18n";
import { translateCategoryName } from "@/lib/categoryLabels";
import type { CategorySpendingReport } from "@/types";
interface CategorySpendingChartProps {
report: CategorySpendingReport | undefined;
isLoading: boolean;
}
function monthKey(year: number, month: number): string {
return `${year}-${String(month).padStart(2, "0")}-01`;
}
function formatMonthLabel(key: string): string {
return new Intl.DateTimeFormat(getIntlLocale(), { month: "short", year: "numeric" }).format(
new Date(`${key}T00:00:00`)
);
}
function transactionsCountLabel(count: number, language: Language): string {
if (language === "ru") return pluralizeRu(count, "транзакция", "транзакции", "транзакций");
return count === 1 ? "transaction" : "transactions";
}
/** Same landmark idea as the Net Worth chart: year ticks only when the bars
* span more than one calendar year, so a 5-year report reads at a glance. */
function computeYearTicks(keys: string[]): string[] {
if (keys.length < 2) return [];
const startYear = Number(keys[0].slice(0, 4));
const endYear = Number(keys[keys.length - 1].slice(0, 4));
if (startYear === endYear) return [];
const ticks: string[] = [];
for (let year = startYear + 1; year <= endYear; year++) {
const jan = `${year}-01-01`;
if (keys.includes(jan)) ticks.push(jan);
}
return ticks;
}
function ChartTooltip({ active, payload }: { active?: boolean; payload?: Array<{ payload: { key: string; amount: number } }> }) {
if (!active || !payload?.length) return null;
const point = payload[0].payload;
return (
<div className="rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm shadow-md">
<p className="text-text-muted">{formatMonthLabel(point.key)}</p>
<p className="font-medium text-text-primary">{formatCurrency(point.amount)}</p>
</div>
);
}
export function CategorySpendingChart({ report, isLoading }: CategorySpendingChartProps) {
const { t, language } = useTranslation();
const chartData = report?.series.map((point) => ({
key: monthKey(point.year, point.month),
amount: Number(point.amount),
})) ?? [];
const yearTicks = computeYearTicks(chartData.map((point) => point.key));
return (
<Card>
<CardHeader className="items-start">
<div>
<CardTitle>{report ? translateCategoryName(report.category_name) : t("reports.defaultChartTitle")}</CardTitle>
<p className="mt-1.5 text-2xl font-semibold tabular-nums text-text-primary sm:text-[28px]">
{isLoading || !report ? "…" : formatCurrency(report.total_amount)}
</p>
{report && (
<p className="mt-1 text-sm text-text-muted">
{t("reports.averagePerMonth", { amount: formatCurrency(report.average_per_month) })} ·{" "}
{report.transaction_count} {transactionsCountLabel(report.transaction_count, language)}
</p>
)}
</div>
</CardHeader>
<CardContent>
<div className="h-56 w-full sm:h-64">
{isLoading || !report || chartData.length === 0 ? (
<div className="flex h-full items-center justify-center text-sm text-text-muted">
{isLoading ? t("common.loading") : t("reports.noDataForPeriod")}
</div>
) : (
<ResponsiveContainer width="100%" height="100%">
<BarChart data={chartData} margin={{ top: 8, right: 4, bottom: 0, left: 4 }}>
{yearTicks.length > 0 && (
<XAxis
dataKey="key"
type="category"
ticks={yearTicks}
tickFormatter={(value: string) => value.slice(0, 4)}
axisLine={false}
tickLine={false}
tick={{ fill: "var(--text-muted)", fontSize: 11 }}
interval="preserveStartEnd"
/>
)}
<Tooltip content={<ChartTooltip />} cursor={{ fill: "var(--surface-2)" }} />
<Bar dataKey="amount" fill={report.category_color} radius={[2, 2, 0, 0]} isAnimationActive={false} />
</BarChart>
</ResponsiveContainer>
)}
</div>
{chartData.length > 1 && (
<div className="mt-2 flex justify-between text-xs text-text-muted">
<span>{formatMonthLabel(chartData[0].key)}</span>
<span>{formatMonthLabel(chartData[chartData.length - 1].key)}</span>
</div>
)}
</CardContent>
</Card>
);
}