Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions docs/USER-JOURNEY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Tagwerk user journey

Who does what, from the first day of a project to the daily report, and what must be ready before
someone outside the team can use Tagwerk without us standing next to them.

## People

| Person | Where | Uses | Wants |
|---|---|---|---|
| Site manager (Polier / Bauleiter vor Ort) | On site, gloves, noise, little time | **Mobile app** (`mobile/`) | Record what happened in under a minute; never type a report |
| Bauleiter / project lead | Office or site container | **Dashboard** (`/app`) | Plan vs actual, delays with causes, a report and a notice draft he can sign |
| Office / scheduler | Office | Upload P6 XML + GAEB, P6/ICS exports | Schedule and BoQ stay the source of truth |
| Labour | Not a user | Appears only as data (trades, counts, absences) | – |

## Journey

### 0. Project setup (office, once, ~10 min)

Two paths, the same result: elements, activities, BoQ positions, zones and a baseline.

- **No BIM:** drop the P6 XML schedule and the GAEB file (X83/X84). Tagwerk derives zones and elements
from the activities and the BoQ positions.
- **With BIM:** add the IFC model. Every element is tracked individually (Schependomlaan: 2,082 elements).
- **Nothing yet:** walk the site with the phone in *Scan* mode; Tagwerk proposes a starter project from
what it sees (`/api/scan` with `make_project`).

Then connect the site manager: open the dashboard on the laptop, show the server address (Tailscale
`http://100.118.181.69:8080`), and the site manager enters it once in the app (or scans the connect QR code).

### 1. Morning (site manager, 1 min)

Opens the app on the **Heute** tab: today's open activities with their elements, plan vs actual, delay in
days, and any proposals waiting for a decision.

### 2. During the day (site manager, 30–60 s per recording)

**Erfassen** tab. Pick the zone, then one of:

- **Video with commentary** (main path): walk and talk. "Estrich im Saal fertig, zwei Mann vom Trockenbau krank."
- **Photo** (+ optional voice note or typed note)
- **Voice note** only
- **Typed note** (counts like voice)

Upload runs in the background; without signal the recording waits in the queue and resends itself with the
same `capture_id` (the server ignores duplicates). After processing the app shows what Tagwerk understood:

- **Confirmed** (green): the sentence names it, so the element state moves up.
- **Proposed** (amber): only the camera saw it. One tap confirms, otherwise nothing changes.
- **Absences, deliveries, special events** (weather, defects, hindrances).

### 3. Correcting (site manager, seconds)

Tap any element on **Heute**, pick its real state. A manual tap counts like voice evidence.

### 4. Walk-through scan (site manager, occasional)

**Scan** tab: a slow 30–90 s walk. Tagwerk lists the objects and elements it recognised (with the frame where it
saw them) and builds a 3D scan with what was said where. Opens in the browser.

### 5. End of day (site manager → Bauleiter, 2 min)

**Bericht** tab: the daily report is already written from the day's recordings (work done, labour, absences,
weather, delays with causes). Site manager checks it and releases it. The Bauleiter sees it on the dashboard,
together with forecast, SPI and the notice draft for delays that need one (Behinderungsanzeige, VOB/B §6).

### 6. Bauleiter (office, any time)

Dashboard: plan vs actual, forecast finish, delays and their causes, the live graph (recording → element →
activity → BoQ position), BIM view, daily reports, P6 XML and .ics exports back into the planning tools.

## Ready checklist (before outside users)

### Must have (demo, Fri 27 Nov)

- [x] API and GPU worker on the laptop, reachable over Tailscale (`:8080` Hörsaal, `:8081` Schependomlaan, `:8082` scan)
- [x] Dashboard `/app`: dashboard, live graph, BIM, daily report, 3D scan
- [x] Capture pipeline: video/photo/voice/note → transcript → vision → structured → graph → dashboard
- [x] Mobile app `mobile/` (Expo + shadcn/React Native Reusables, Android via Expo Go): connect, today, capture with offline queue, result, scan, report
- [ ] Tailscale installed on the demo phone and signed in to the same tailnet
- [x] Metro for the app running on the laptop (`~/tw-mobile.sh start`, serves `exp://100.118.181.69:8090`)
- [ ] Expo Go installed on the demo phone, app opened via `mobile/expo-go-qr.png`
- [ ] One rehearsal on site: record, see the result on the phone, see it live on the dashboard
- [ ] `tw-doubletest.sh` green on the morning of the demo, demo data reset

### Should have (first pilot)

- [ ] `API_TOKEN` set on the laptop (no dev mode outside the demo) and entered in the app
- [ ] HTTPS (Tailscale `serve` gives a certificate), so tokens are not sent in clear text
- [ ] A standalone Android build (`eas build -p android --profile preview`), so the site manager needs no Expo Go
- [ ] Claude structuring key in `.env` (rules fallback misses words outside the glossary, e.g. excavation)
- [ ] Project setup from the UI (today: seed files or `/api/scan` with `ALLOW_PROJECT_CREATE=1`)
- [ ] Glossary per project (trade words, element nicknames the crew uses)
- [ ] Notice (Behinderungsanzeige) export reviewed by someone who signs them; marked as a draft, not legal advice

### Later

- [ ] Several projects per server and a project picker in the app
- [ ] Users and roles instead of one bearer token
- [ ] Push notification when a proposal waits or a delay needs a notice
- [ ] GPS / zone from the phone's location
- [ ] Hosting off the laptop (GPU box in the office or a cloud GPU)
5 changes: 5 additions & 0 deletions mobile/.claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"enabledPlugins": {
"expo@claude-plugins-official": true
}
}
41 changes: 41 additions & 0 deletions mobile/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# dependencies
node_modules/

# Expo
.expo/
dist/
web-build/
expo-env.d.ts

# Native
.kotlin/
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local

# typescript
*.tsbuildinfo

# generated native folders
/ios
/android
41 changes: 41 additions & 0 deletions mobile/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
This is an Expo/React Native mobile application. Prioritize mobile-first patterns, performance, and cross-platform compatibility.

## Expo has changed — do not trust your training data

Expo ships breaking changes every SDK release. APIs you remember are likely renamed, moved, or removed. Before writing any code that touches an Expo, EAS, or React Native API:

1. Read the major version of the `expo` package in `package.json`.
2. Fetch the matching versioned docs: `https://docs.expo.dev/versions/v<major>.0.0/`
3. For anything else, fetch https://docs.expo.dev/llms.txt — an index of all Expo docs with corrections to common LLM misconceptions. Follow its links to the specific page you need; never answer from memory.

## Commands

Use `bunx` instead of `npx` if the project uses bun (`bun.lock` present).

```bash
npx expo install <package> # ALWAYS use instead of npm/yarn/pnpm/bun add — resolves SDK-compatible versions
npx expo start # start the dev server
npx expo lint # lint
npx tsc --noEmit # typecheck
npx expo-doctor # diagnose dependency and config issues
npx expo install --fix # fix incompatible package versions
```

Run lint and typecheck before declaring any task done.

## Navigation & Routing

- Use **Expo Router** for all navigation. Routes live in `src/app/` — every file there is a screen, `_layout.tsx` files define navigators. Keep non-route code (components, hooks, utils) outside `src/app/`.
- Import `Link`, `router`, and `useLocalSearchParams` from `expo-router`.
- Docs: https://docs.expo.dev/router/introduction.md

## Building with EAS

Use EAS to build, sign, and submit the app in the cloud (`eas build`, `eas submit`) and to ship over-the-air updates (`eas update`) — no local Xcode or Android Studio required. Run EAS CLI as `bunx eas-cli <command>` in Bun projects, or `npx eas-cli@latest <command>` otherwise; substitute that for bare `eas` in docs examples.
Docs: https://docs.expo.dev/eas/index.md

## Rules

- If `ios/` and `android/` directories do not exist, they are generated (Continuous Native Generation). Never create or edit them by hand — configure native behavior in `app.json` and config plugins.
- Expo Go only includes its bundled native modules. After adding a library with native code, the app needs a development build: `npx expo run:ios|android` locally, or `eas build --profile development`.
- Prefer recommended Expo modules over third-party libraries, and check your available skills before adding dependencies. Docs: https://docs.expo.dev/versions/latest/index.md
134 changes: 134 additions & 0 deletions mobile/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// Tagwerk for site managers: today, capture, scan, report. Talks to the API on the GPU laptop over Tailscale.
import "./global.css";
import { Button } from "@/components/ui/button";
import { Icon } from "@/components/ui/icon";
import { Text } from "@/components/ui/text";
import { cn } from "@/lib/utils";
import { PortalHost } from "@rn-primitives/portal";
import { StatusBar } from "expo-status-bar";
import { CircleDot, FileText, PlusCircle, ScanLine, Settings as Gear, X } from "lucide-react-native";
import React, { useCallback, useEffect, useRef, useState } from "react";
import { Animated, Pressable, View } from "react-native";
import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";
import { Health, Overview, Report as ReportData, Zone, getJson, listen, loadSettings } from "./src/api";
import { Job, initQueue, setStep, subscribe } from "./src/queue";
import { Capture } from "./src/screens/Capture";
import { Report } from "./src/screens/Report";
import { Scan } from "./src/screens/Scan";
import { Settings } from "./src/screens/Settings";
import { Today } from "./src/screens/Today";

type Tab = "today" | "capture" | "scan" | "report";
const TABS: [Tab, any, string][] = [["today", CircleDot, "Heute"], ["capture", PlusCircle, "Erfassen"], ["scan", ScanLine, "Scan"], ["report", FileText, "Bericht"]];

export default function App() {
const [ready, setReady] = useState(false);
const [tab, setTab] = useState<Tab>("capture");
const [showSettings, setShowSettings] = useState(false);
const [health, setHealth] = useState<Health | null>(null);
const [overview, setOverview] = useState<Overview | null>(null);
const [report, setReport] = useState<ReportData | null>(null);
const [zones, setZones] = useState<Zone[]>([]);
const [error, setError] = useState<string | null>(null);
const [refreshing, setRefreshing] = useState(false);
const [jobs, setJobs] = useState<Job[]>([]);
const [msg, setMsg] = useState<{ text: string; err?: boolean } | null>(null);
const fade = useRef(new Animated.Value(0)).current;
const toastTimer = useRef<ReturnType<typeof setTimeout> | null>(null);

const toast = useCallback((text: string, err?: boolean) => {
setMsg({ text, err });
Animated.timing(fade, { toValue: 1, duration: 150, useNativeDriver: true }).start();
if (toastTimer.current) clearTimeout(toastTimer.current);
toastTimer.current = setTimeout(() => Animated.timing(fade, { toValue: 0, duration: 250, useNativeDriver: true }).start(), 2800);
}, [fade]);

const load = useCallback(async () => {
setRefreshing(true);
try {
const [h, z, o, r] = await Promise.all([
getJson<Health>("/health"), getJson<Zone[]>("/zones"), getJson<Overview>("/api/overview"), getJson<ReportData>("/api/v2/report"),
]);
setHealth(h); setZones(z); setOverview(o); setReport(r); setError(null);
} catch (e: any) {
setError(e.message); setHealth(null);
} finally {
setRefreshing(false);
}
}, []);

useEffect(() => {
(async () => { await loadSettings(); setReady(true); await initQueue(); load(); })();
return subscribe(setJobs);
}, [load]);

// live: pipeline steps for queued jobs, and a refresh when the graph changes (also from the dashboard)
useEffect(() => {
if (!ready || !health) return;
let t: ReturnType<typeof setTimeout> | null = null;
const stop = listen((m) => {
if (m.type === "status" && m.props?.step) setStep(m.id, m.props.step);
if (m.type === "update" || (m.type === "status" && m.props?.step === "done")) { if (t) clearTimeout(t); t = setTimeout(load, 700); }
});
return () => { stop(); if (t) clearTimeout(t); };
}, [ready, health?.project, load]);

const names: Record<string, string> = {};
(overview?.zones ?? []).forEach((z) => z.elements.forEach((e) => (names[e.id] = e.name)));
const pending = jobs.filter((j) => j.status !== "done" && j.status !== "error").length;

return (
<SafeAreaProvider>
<SafeAreaView className="bg-secondary flex-1" edges={["top", "bottom"]}>
<StatusBar style="dark" />
<View className="bg-background border-border flex-row items-center border-b px-4 py-3">
<View className="bg-primary mr-3 size-8 items-center justify-center rounded-lg">
<Text className="text-primary-foreground text-base font-extrabold">T</Text>
</View>
<View className="flex-1">
<Text className="text-lg font-bold leading-6">Tagwerk</Text>
<View className="flex-row items-center gap-1.5">
<View className={cn("size-2 rounded-full", health ? "bg-success" : error ? "bg-destructive" : "bg-warning")} />
<Text className="text-muted-foreground text-xs" numberOfLines={1}>{health ? health.project : error ? "nicht verbunden" : "verbinde …"}</Text>
</View>
</View>
<Button size="icon" variant="ghost" onPress={() => setShowSettings((v) => !v)} accessibilityLabel="Einstellungen">
<Icon as={showSettings ? X : Gear} className="size-6" />
</Button>
</View>

<View className="flex-1">
{!ready ? null : showSettings ? <Settings onClose={() => setShowSettings(false)} onSaved={load} />
: tab === "today" ? <Today data={overview} error={error} reload={load} refreshing={refreshing} toast={toast} />
: tab === "capture" ? <Capture zones={zones} jobs={jobs} names={names} toast={toast} />
: tab === "scan" ? <Scan toast={toast} />
: <Report data={report} reload={load} refreshing={refreshing} toast={toast} />}
</View>

<Animated.View pointerEvents="none" style={{ position: "absolute", left: 16, right: 16, bottom: 96, opacity: fade, alignItems: "center" }}>
{msg && (
<View className={cn("rounded-lg px-4 py-3 shadow-lg", msg.err ? "bg-destructive" : "bg-primary")}>
<Text className="text-sm font-medium text-white">{msg.text}</Text>
</View>
)}
</Animated.View>

<View className="bg-background border-border flex-row border-t">
{TABS.map(([key, icon, label]) => {
const on = tab === key && !showSettings;
return (
<Pressable key={key} onPress={() => { setShowSettings(false); setTab(key); }} accessibilityRole="tab" accessibilityState={{ selected: on }}
className="min-h-[60px] flex-1 items-center justify-center gap-1 py-2">
<Icon as={icon} className={cn("size-6", on ? "text-foreground" : "text-muted-foreground")} />
<Text className={cn("text-xs", on ? "text-foreground font-semibold" : "text-muted-foreground")}>
{label}{key === "capture" && pending ? ` (${pending})` : ""}
</Text>
</Pressable>
);
})}
</View>
<PortalHost />
</SafeAreaView>
</SafeAreaProvider>
);
}
1 change: 1 addition & 0 deletions mobile/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
21 changes: 21 additions & 0 deletions mobile/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
37 changes: 37 additions & 0 deletions mobile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Tagwerk mobile (site manager app)

Expo (SDK 58) app for the site manager, built with React Native Reusables (shadcn/ui for React Native, NativeWind).
It talks to the Tagwerk API on the GPU laptop over Tailscale. Journey and roles: `../docs/USER-JOURNEY.md`.

| Tab | What it does | API |
|---|---|---|
| Heute | Plan vs actual, SPI, delay; camera proposals to confirm; open activities, tap an element to set its state | `GET /api/overview`, `POST /api/elements/{id}/confirm` |
| Erfassen | Zone, then video with commentary / photo / voice note / typed note. Offline queue, resend with the same `capture_id`, live pipeline steps, result card | `POST /captures`, `GET /captures/{id}`, websocket `/events` |
| Scan | Walk-through video: recognised objects with the frame, 3D scan link | `POST /api/scan`, `/app/#/scan/{id}` |
| Bericht | Today's Bautagebuch; release; PDF; dashboard link | `GET /api/v2/report`, `/export/report.html` |
| ⚙︎ | Server URL (`:8080` Hörsaal, `:8081` Schependomlaan, `:8082` scan), token, connect QR (`tagwerk://connect?url=…&token=…`) | `GET /health`, `GET /zones` |

## Run on the phone (Android, Expo Go)

1. Phone: install **Tailscale** (same tailnet as the laptop) and **Expo Go** from the Play Store.
2. Laptop (Metro runs there; the Mac firewall blocks incoming connections): `~/tw-mobile.sh start` (`stop`, `log`).
The app source on the laptop is `~/Developer/hacka/tagwerk-mobile`; after changes on the Mac:
`rsync -az --delete --exclude node_modules --exclude .expo ./ anoushk@100.118.181.69:Developer/hacka/tagwerk-mobile/`
then `~/tw-mobile.sh stop && ~/tw-mobile.sh start` (CI mode: no live reload).
3. Expo Go: scan `expo-go-qr.png` or enter `exp://100.118.181.69:8090`.
4. The app connects to `http://100.118.181.69:8080` by default; change it under ⚙︎.

## Develop on the Mac

```sh
npm install
npx tsc --noEmit
npx expo start --web --port 19006 # UI in the browser; the API sends no CORS headers, so use a local proxy for web only
```

Add shadcn components with `npx @react-native-reusables/cli@latest add <name>` (they land in `components/ui/`).

## Not done yet

- Standalone APK (`npx eas-cli@latest build -p android --profile preview`) so no Expo Go is needed.
- HTTPS and `API_TOKEN` for anything beyond the demo.
Loading
Loading