Skip to content

armgit / bygga

Public Imported from GitHub
0

IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.

TypeScript

Park the manual scanner for v2

Youssef4d411dcce582
diff --git a/README.md b/README.md
index 76d5d73..adba140 100644
--- a/README.md
+++ b/README.md
@@ -4,14 +4,14 @@
<h1 align="center">Bygga</h1>
-<p align="center">Type the name on an IKEA box and follow every assembly step in 3D, drawn like the paper manual, or scan any other manual with Together AI. <a href="https://bygga-eta.vercel.app">bygga-eta.vercel.app</a></p>
+<p align="center">Type the name on an IKEA box and follow every assembly step in 3D, drawn like the paper manual. <a href="https://bygga-eta.vercel.app">bygga-eta.vercel.app</a></p>
## Tech stack
- Next.js 16 (App Router, Cache Components) with React 19 and TypeScript, plain CSS, no UI kit
- three.js line-art stage (`src/engine`): ink outlines, fly-in parts, a zoomed callout per fitting, offscreen thumbnails
- A parametric plan generator (`src/lib/plan`) for 7 furniture types, with 152 products drawn offline and typo-tolerant search
-- Manual scanner (`/scan`): a vision model reads each page, `gpt-oss-120b` lays out the parts in millimetres, and `src/lib/plan/custom.ts` places every dowel, bolt and screw where parts touch
+- Manual scanner (`/scan`, parked for v2 and off unless `NEXT_PUBLIC_SCAN=1`): a vision model reads each page, `gpt-oss-120b` lays out the parts in millimetres, and `src/lib/plan/custom.ts` places every dowel, bolt and screw where parts touch
- Together AI for unknown product names, photo lookup and the "Stuck?" helper, with model fallback lists in `src/lib/together.ts`
- A hands-free voice on Together AI (Kokoro, `src/lib/voice/tts.ts`): every catalog line is pre-recorded with `npm run voice`, the rest are recorded live, and saying "next" turns the page
- Workshop (`/builds`): every finished build merged into one scene and rendered at true scale next to a person
@@ -22,7 +22,7 @@
2. Optional key: `cp .env.example .env.local`, then set `TOGETHER_API_KEY` (the 152 offline products work without it)
3. Run: `npm run dev`, open http://localhost:3000 and type `BISSA`
4. Jump to a step: http://localhost:3000/build/malm-3-drawers?step=12, or see finished builds at `/builds`
-5. Try the scanner free: on `/scan`, paste `bygga-dev-mock-key-000000` as the key and add any photo (only `npm run dev` accepts it)
+5. Try the scanner free: run with `NEXT_PUBLIC_SCAN=1`, then on `/scan` paste `bygga-dev-mock-key-000000` as the key and add any photo (only `npm run dev` accepts it)
6. Before pushing: `npm run lint && npm run build`
## Roadmap
diff --git a/src/app/api/scan/route.ts b/src/app/api/scan/route.ts
index e85546c..364f8ab 100644
--- a/src/app/api/scan/route.ts
+++ b/src/app/api/scan/route.ts
@@ -4,6 +4,7 @@ import { PAGE_PROMPT, PLAN_PROMPT, planInput, repairInput } from "@/lib/scan/pro
import { SAMPLE_SCAN } from "@/lib/scan/sample";
import { chatText, extractJson, ipOf, MODELS, rateLimited, TogetherError, userKey, type Msg } from "@/lib/together";
import type { ProductSpec } from "@/lib/types";
+import { SCAN_ENABLED } from "@/lib/site";
export const maxDuration = 300;
@@ -13,6 +14,7 @@ const DEV_MOCK_KEY = "bygga-dev-mock-key-000000";
type Note = { kind?: string; product?: { name?: string; brand?: string; type?: string }; parts?: unknown[]; hardware?: unknown[]; steps?: { n?: number }[] };
export async function POST(req: Request) {
+ if (!SCAN_ENABLED) return Response.json({ error: "off" }, { status: 404 });
const key = userKey(req);
if (!key) return Response.json({ error: "key" }, { status: 401 });
if (rateLimited(ipOf(req) + ":scan", 6, 10 * 60_000)) return Response.json({ error: "busy" }, { status: 429 });
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 6e7613d..b774f1b 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -10,6 +10,7 @@ import { ToolArt } from "@/components/art/Tools";
import { HwArt } from "@/components/art/Hardware";
import { IArrowRight, IScan } from "@/components/art/Icons";
import { PRODUCT_COUNT } from "@/lib/search";
+import { SCAN_ENABLED } from "@/lib/site";
const QUICK = [
{ slug: "kallax-2x2", label: "KALLAX" },
@@ -41,12 +42,14 @@ export default function Home() {
</Link>
))}
</div>
- <Link href="/scan" className="scan-link">
- <IScan size={17} />
- <span>
- Not from IKEA? <u>Scan its paper manual</u>
- </span>
- </Link>
+ {SCAN_ENABLED && (
+ <Link href="/scan" className="scan-link">
+ <IScan size={17} />
+ <span>
+ Not from IKEA? <u>Scan its paper manual</u>
+ </span>
+ </Link>
+ )}
</div>
<HeroStage />
</section>
diff --git a/src/app/scan/page.tsx b/src/app/scan/page.tsx
index e51ac6c..0b8f460 100644
--- a/src/app/scan/page.tsx
+++ b/src/app/scan/page.tsx
@@ -1,4 +1,6 @@
import type { Metadata } from "next";
+import { notFound } from "next/navigation";
+import { SCAN_ENABLED } from "@/lib/site";
import SiteHeader from "@/components/SiteHeader";
import SiteFooter from "@/components/SiteFooter";
import Scanner from "@/components/scan/Scanner";
@@ -9,6 +11,7 @@ export const metadata: Metadata = {
};
export default function Page() {
+ if (!SCAN_ENABLED) notFound();
return (
<div className="site">
<SiteHeader />
diff --git a/src/components/SiteFooter.tsx b/src/components/SiteFooter.tsx
index 4411b78..62391e4 100644
--- a/src/components/SiteFooter.tsx
+++ b/src/components/SiteFooter.tsx
@@ -1,6 +1,6 @@
import Link from "next/link";
import Logo from "./Logo";
-import { GITHUB_URL } from "@/lib/site";
+import { GITHUB_URL, SCAN_ENABLED } from "@/lib/site";
const MARKS = [0, 50, 100];
@@ -19,7 +19,7 @@ export default function SiteFooter() {
<nav className="foot-nav" aria-label="Footer">
<Link href="/browse">All guides</Link>
<Link href="/builds">Workshop</Link>
- <Link href="/scan">Scan a manual</Link>
+ {SCAN_ENABLED && <Link href="/scan">Scan a manual</Link>}
<a href={GITHUB_URL} target="_blank" rel="noreferrer">
GitHub
</a>
diff --git a/src/components/guide/CoverPanel.tsx b/src/components/guide/CoverPanel.tsx
index a44c329..c275f51 100644
--- a/src/components/guide/CoverPanel.tsx
+++ b/src/components/guide/CoverPanel.tsx
@@ -7,6 +7,7 @@ import { floorSpace, totals } from "@/lib/plan/contents";
import { IArrowRight, IBox, IClock, IExternal, IPeople, IPerson, IRuler, ISparkle, IWrench } from "../art/Icons";
import { Dots } from "./ui";
import { TOOL_INFO } from "../art/Tools";
+import { SCAN_ENABLED } from "@/lib/site";
export default function CoverPanel({
plan,
@@ -133,7 +134,7 @@ export default function CoverPanel({
? "Together AI only saw the cover, so this is a typical build for this product. Scan the inside pages for an exact match."
: "Together AI read your pages and drew each step. Check every step against the paper manual before you fix anything."}
</span>
- {s.custom?.fromCover && (
+ {s.custom?.fromCover && SCAN_ENABLED && (
<Link href="/scan" className="callout-link">
Scan the pages
</Link>
diff --git a/src/components/guide/GuideApp.tsx b/src/components/guide/GuideApp.tsx
index a62baa9..ffb1de5 100644
--- a/src/components/guide/GuideApp.tsx
+++ b/src/components/guide/GuideApp.tsx
@@ -34,6 +34,7 @@ import { heardWords, parse, type Intent } from "@/lib/voice/commands";
import { useMounted } from "@/lib/useMounted";
import { getUserKey, keyHeaders } from "@/lib/userKey";
import { decodeSpec } from "@/lib/scan/share";
+import { SCAN_ENABLED } from "@/lib/site";
type Via = "catalog" | "ai" | "guess" | "scan";
@@ -127,9 +128,9 @@ export default function GuideApp({ slug, query, step, kind }: { slug: string; qu
<div className="notfound">
<Figure pose="think" bubble="?" size={120} />
<h1>This guide lives on another device</h1>
- <p className="sub">Scanned guides are saved in the browser that made them. Ask for a share link from the done screen, or scan the manual again.</p>
- <Link href="/scan" className="btn primary">
- Scan a manual
+ <p className="sub">Scanned guides are saved in the browser that made them. Ask for a share link from the done screen{SCAN_ENABLED ? ", or scan the manual again" : ""}.</p>
+ <Link href={SCAN_ENABLED ? "/scan" : "/"} className="btn primary">
+ {SCAN_ENABLED ? "Scan a manual" : "Back to search"}
</Link>
</div>
</Shell>
@@ -208,12 +209,14 @@ function NotFound({ query, slug, suggestions, error }: { query: string; slug: st
))}
</div>
)}
- <Link href="/scan" className="scan-link nf-scan">
- <IScan size={17} />
- <span>
- Not from IKEA? <u>Scan its paper manual</u>
- </span>
- </Link>
+ {SCAN_ENABLED && (
+ <Link href="/scan" className="scan-link nf-scan">
+ <IScan size={17} />
+ <span>
+ Not from IKEA? <u>Scan its paper manual</u>
+ </span>
+ </Link>
+ )}
</div>
);
}
diff --git a/src/lib/site.ts b/src/lib/site.ts
index ff5b1b9..028fec4 100644
--- a/src/lib/site.ts
+++ b/src/lib/site.ts
@@ -1,2 +1,5 @@
export const GITHUB_REPO = process.env.NEXT_PUBLIC_GITHUB_REPO ?? "Luffixos/bygga";
export const GITHUB_URL = `https://github.com/${GITHUB_REPO}`;
+
+/** The manual scanner (/scan) is parked for a later version: hidden everywhere unless NEXT_PUBLIC_SCAN=1. */
+export const SCAN_ENABLED = process.env.NEXT_PUBLIC_SCAN === "1";