Start the Next.js frontend: Google login, profile, birth data, admin

services/frontend (Next.js 16, App Router) runs on port 3001 in compose. The
browser only talks to the frontend: /api/v1/* is proxied to the backend, so
the session cookie lives on the frontend's host, and /api/geo/* exposes the
country list and place search of the horoscope-api.

- /belepes: Google Identity Services button, client id from /v1/config
- /profil: account facts, display name and language, own birth data with
  place search, DST ambiguity prompt and the chart's positions
- /admin: user search, role toggles, credit grants (admins only, 404 otherwise)

Services now tolerate migrations newer than their binary, so they can be
rebuilt one at a time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-15 21:00:50 +00:00
co-authored by Claude Opus 5.5
parent 4aabb7343c
commit 1f177f859e
38 changed files with 2996 additions and 5 deletions
@@ -0,0 +1,140 @@
import { ANGLES, POINTS, SIGNS, dms, signName } from "@/lib/astro";
import type { Chart, Position } from "@/lib/types";
function Pos({ p }: { p: Position }) {
return (
<>
{dms(p.degree_in_sign_dms)} <span className="sym">{SIGNS[p.sign]?.glyph}</span> {signName(p.sign)}
</>
);
}
/** The big three and the positions of a natal chart. */
export function ChartTables({ chart }: { chart: Chart }) {
const result = chart.chart;
const timeKnown = chart.highlights.time_known;
const angles = ANGLES.map(([key, label]) => [label, result.angles[key]] as const).filter(
(a): a is readonly [string, Position] => typeof a[1] === "object" && a[1] !== null,
);
const fortune = result.lots?.fortune;
const sun = result.points.find((p) => p.id === "sun");
const moon = result.points.find((p) => p.id === "moon");
return (
<div className="field" style={{ gap: 24 }}>
<div className="big3">
<div>
<span className="muted">Nap</span>
<span className="glyph sym">{SIGNS[chart.highlights.sun ?? ""]?.glyph}</span>
<strong>{signName(chart.highlights.sun)}</strong>
{sun && <span className="muted num">{dms(sun.degree_in_sign_dms)}</span>}
</div>
<div>
<span className="muted">Hold{!timeKnown && " (közelítő)"}</span>
<span className="glyph sym">{SIGNS[chart.highlights.moon ?? ""]?.glyph}</span>
<strong>{signName(chart.highlights.moon)}</strong>
{moon && <span className="muted num">{dms(moon.degree_in_sign_dms)}</span>}
</div>
<div>
<span className="muted">Aszcendens</span>
{timeKnown ? (
<>
<span className="glyph sym">{SIGNS[chart.highlights.ascendant ?? ""]?.glyph}</span>
<strong>{signName(chart.highlights.ascendant)}</strong>
</>
) : (
<strong className="muted">–</strong>
)}
</div>
</div>
<div className="grid-2" style={{ alignItems: "start" }}>
<div className="table-wrap">
<h3 style={{ marginBottom: 8 }}>Bolygók és pontok</h3>
<table>
<thead>
<tr>
<th scope="col">Pont</th>
<th scope="col">Pozíció</th>
{timeKnown && <th scope="col">Ház</th>}
</tr>
</thead>
<tbody>
{result.points.map((p) => (
<tr key={p.id}>
<td>
<span className="sym" aria-hidden="true">
{POINTS[p.id]?.glyph}
</span>{" "}
{POINTS[p.id]?.hu ?? p.id}
{p.retrograde && (
<abbr className="retro" title="retrográd">
R
</abbr>
)}
</td>
<td className="num">
<Pos p={p} />
</td>
{timeKnown && <td className="num">{p.house ? `${p.house}.` : "–"}</td>}
</tr>
))}
{timeKnown && fortune && (
<tr>
<td>Szerencsepont</td>
<td className="num">
<Pos p={fortune} />
</td>
<td className="num">{fortune.house ? `${fortune.house}.` : "–"}</td>
</tr>
)}
</tbody>
</table>
</div>
{timeKnown && (
<div className="field" style={{ gap: 24 }}>
<div className="table-wrap">
<h3 style={{ marginBottom: 8 }}>Tengelyek</h3>
<table>
<tbody>
{angles.map(([label, p]) => (
<tr key={label}>
<td>{label}</td>
<td className="num">
<Pos p={p} />
</td>
</tr>
))}
</tbody>
</table>
</div>
{result.houses && (
<div className="table-wrap">
<h3 style={{ marginBottom: 8 }}>Házcsúcsok (Placidus)</h3>
<table>
<tbody>
{result.houses.cusps.map((c) => (
<tr key={c.house}>
<td>{c.house}. ház</td>
<td className="num">
<Pos p={c} />
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</div>
)}
</div>
{!timeKnown && (
<p className="hint">
Születési idő nélkül a házak, a tengelyek és az Aszcendens nem számolhatók; a Hold helyzete a nap folyamán akár
jegyet is válthat, ezért közelítő.
</p>
)}
</div>
);
}
@@ -0,0 +1,27 @@
"use client";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { api } from "@/lib/api";
export function LogoutButton() {
const router = useRouter();
const [busy, setBusy] = useState(false);
async function logout() {
setBusy(true);
try {
await api("/auth/logout", { method: "POST" });
} catch {
// The session may already be gone; go to the login page either way.
}
window.google?.accounts.id.disableAutoSelect();
router.replace("/belepes");
router.refresh();
}
return (
<button type="button" className="btn btn-sm" onClick={logout} disabled={busy}>
Kilépés
</button>
);
}
@@ -0,0 +1,17 @@
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
export function NavLinks({ links }: { links: { href: string; label: string }[] }) {
const pathname = usePathname();
return (
<nav className="nav" aria-label="Fő navigáció">
{links.map((l) => (
<Link key={l.href} href={l.href} aria-current={pathname.startsWith(l.href) ? "page" : undefined}>
{l.label}
</Link>
))}
</nav>
);
}
@@ -0,0 +1,29 @@
import Link from "next/link";
import type { Me } from "@/lib/types";
import { LogoutButton } from "./LogoutButton";
import { NavLinks } from "./NavLinks";
export function Logo() {
return (
<Link href="/" className="logo">
sors<span>fonalak</span>
</Link>
);
}
export function SiteHeader({ me }: { me: Me }) {
const links = [{ href: "/profil", label: "Profil" }];
if (me.user.roles.includes("admin")) links.push({ href: "/admin", label: "Admin" });
return (
<header className="site-header">
<Logo />
<NavLinks links={links} />
<div className="who">
<span>{me.user.display_name || me.user.email}</span>
<LogoutButton />
</div>
</header>
);
}
@@ -0,0 +1,73 @@
// Decorative zodiac wheel for the login page (pure SVG, no data needed).
const GLYPHS = ["♈", "♉", "♊", "♋", "♌", "♍", "♎", "♏", "♐", "♑", "♒", "♓"];
// A few planets of a sample sky, for the aspect lines in the middle.
const SAMPLE = [12, 75, 131, 200, 247, 302, 338];
function point(deg: number, r: number) {
const t = ((180 - deg) * Math.PI) / 180;
return { x: 50 + r * Math.cos(t), y: 50 - r * Math.sin(t) };
}
export function ZodiacWheel({ className }: { className?: string }) {
const lines: { a: number; b: number; hard: boolean }[] = [];
SAMPLE.forEach((a, i) =>
SAMPLE.slice(i + 1).forEach((b) => {
let d = Math.abs(a - b) % 360;
if (d > 180) d = 360 - d;
if (Math.abs(d - 120) < 8 || Math.abs(d - 60) < 6) lines.push({ a, b, hard: false });
else if (Math.abs(d - 90) < 7 || Math.abs(d - 180) < 8) lines.push({ a, b, hard: true });
}),
);
return (
<svg className={className} viewBox="0 0 100 100" aria-hidden="true">
<circle cx="50" cy="50" r="49" fill="none" stroke="#2c3654" strokeWidth="0.5" />
<circle cx="50" cy="50" r="38" fill="none" stroke="#2c3654" strokeWidth="0.35" />
<circle cx="50" cy="50" r="24" fill="#0f1426" stroke="#263049" strokeWidth="0.35" />
{GLYPHS.map((_, i) => {
const a = point(i * 30, 38);
const b = point(i * 30, 49);
return <line key={`d${i}`} x1={a.x} y1={a.y} x2={b.x} y2={b.y} stroke="#263049" strokeWidth="0.35" />;
})}
{GLYPHS.map((g, i) => {
const p = point(i * 30 + 15, 43.5);
return (
<text
key={g}
x={p.x}
y={p.y}
textAnchor="middle"
dominantBaseline="central"
fontSize="5"
fill={i % 3 === 0 ? "#d9b46a" : "#5a6790"}
style={{ fontFamily: "var(--font-symbols)" }}
>
{g}
{"︎"}
</text>
);
})}
{lines.map(({ a, b, hard }) => {
const p = point(a, 24);
const q = point(b, 24);
return (
<line
key={`${a}-${b}`}
x1={p.x}
y1={p.y}
x2={q.x}
y2={q.y}
stroke={hard ? "#f08a4b" : "#7fb0ff"}
strokeWidth="0.4"
strokeDasharray={hard ? undefined : "1.4 0.8"}
opacity="0.8"
/>
);
})}
{SAMPLE.map((d) => {
const p = point(d, 24);
return <circle key={d} cx={p.x} cy={p.y} r="0.9" fill="#ece6d8" />;
})}
</svg>
);
}