12 Commits
Author SHA1 Message Date
CatoandClaude Opus 5.5 ebe51fa38e feat(auth): every way in on AccountKit's own screens (#289)
* feat(auth): every way in on AccountKit's own screens

Botsmann signed people in against OrangeCat's GoTrue (auth.users). It now
runs on AccountKit (@bitbaum/accountkit 0.23) with AccountKit's own forms:
/auth/signin offers email and password, an emailed sign-in link, a
passkey, recovery through the mailed link and the second factor;
/auth/signup is sign-up; /account carries the account panel ("Sign-in and
security" in the account menu). "Continue with OrangeCat" and the shared
sign-in show when their clients are set, the link and recovery when mail
is. The GoTrue routes (/api/auth/signin, signup, forgot-password,
resend-verification, profile) and pages (callback, forgot-password,
reset-password, verify-email) and the cookie-session client are gone.

AccountKit's tables live in a host accounts database (drizzle/, loki
accounts-db.conf); the data stays in the botsmann supabase schema, which
every route already read with the service-role client. verifyUser now reads
AccountKit's session; /api/user/profile moves onto it too. New accounts get
uuid ids, and migration 013 drops the person columns' keys to auth.users,
which a new person's id is not in. Nothing is deleted. The profile editor
writes AccountKit's name and image.

Existing people keep their rows: scripts/db/accountkit-people.sql lists
everyone who owns rows with their OrangeCat actor id, and
scripts/db/accountkit-import.sql gives each an account under the same id,
linked to OrangeCat by that actor id, never by address (loki
accountkit-supabase.yml rehearses it rolled back, then imports).

Pages were served with public, max-age=3600 to every browser, account pages
included: after sign-out the browser showed its cached /account. /account
and /auth/* are now private, no-store. The account menu's trigger has a name.

tests/__tests__/accounts runs the ways in and the import on the committed
migration; browser-smoke.yml's account job rehearses the import and runs
the browser journey against the production build with AccountKit's real
mail caught by a sink.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9

* fix(auth): send a signed-out visitor to sign in with the router

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9

* ci(auth): the shared sign-in's button is matched by how it starts

AccountKit 0.24 names only the providers Morulia publishes, so the label
changes with Morulia.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9

* ci(auth): expect the shared sign-in only once Morulia publishes a provider

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9

* ci: run the checks on the journey change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-02 23:27:16 +01:00
CatoandClaude Opus 5.5 938618698a fix(security): the public role can no longer read contact submissions (#221)
botsmann.consultations had no RLS and anon held ALL on it; the schema is
served by PostgREST and the anon key ships in the bundle, so anyone could
list every visitor's name, email and message. Applied by hand on the live
DB 2026-10-06 (verified as anon: SELECT email denied, insert+return id
still works); this migration makes it part of the schema. rate_limits
loses anon access too (unused since limitkit). Gateway log back to
2026-08-02 shows only the health check reading id.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 07:38:23 -07:00
107e8c5c08 docs(db): point this repo at its own database, and gate the way back (#143)
The schema fix landed in #138, but the repo still told you to operate a
Supabase we do not have. docs/SUPABASE_SETUP.md opened with "Completed Setup"
for a hosted project jkjmhtirxwhljpkcfxqe.supabase.co and said to apply
migrations by pasting SQL into a supabase.com dashboard. Two unreferenced
scripts printed the same instruction, one handing out a psql string against
pooler.supabase.com, and the CLI's .temp cache with the old project ref was
committed — twice, once nested under supabase/migrations/.

That is not stale clutter, it is the outage. A wrong pointer to a real-looking
place is worse than no pointer: no pointer makes someone ask, a plausible one
makes them assume it was handled. Nobody pasted anything, the eleven migrations
were never applied, and /api/health served PGRST205 for months while every
deploy went green.

So the doc now describes what is actually true — self-hosted on bitbaum at
supabase.orangecat.ch, our tables in the `botsmann` schema because one database
backs several apps and `public` is orangecat's, and migrations applied
automatically on deploy by fleetcrown's apply-schema.sh against the
botsmann._deploy_schema_history ledger. Nothing is pasted anywhere. 280 lines
became 100.

Fixing today's copies only clears today's copies, so check:selfhost joins
verify: it fails on supabase.com/dashboard, app.supabase.com, pooler URLs and
real project refs, allows supabase.com/docs because the product documentation
is still correct for us, and exempts docs/archive/ so history can stay honest.
Proven to fail before shipping — it catches an injected dashboard link and a
project ref, and leaves the your-project.supabase.co placeholder alone.


Claude-Session: https://claude.ai/code/session_018waGt1ieA9TjpscqrbrnGb

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 08:08:06 +00:00
g-butandClaude Opus 4.6 b32b30c4cb feat(context): add user context accumulation system
Core differentiator: professionals learn about users over time.

- Add user_context table with vector embeddings (migration 011)
- Add get_relevant_context() SQL function for semantic search
- Create lib/context/ module:
  - store.ts: save and retrieve user context entries
  - extractor.ts: LLM-based fact extraction from conversations
  - domain-detector.ts: keyword-based domain classification
- Integrate into professional-chat route:
  - Retrieve relevant user context and inject into system prompt
  - Async extraction of facts after each conversation turn

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 17:23:15 +01:00
g-butandClaude Opus 4.6 82e4623105 feat(rate-limit): replace in-memory rate limiting with Supabase-based
In-memory rate limiting (LRU cache + Map) doesn't work correctly in
serverless — each function instance has its own memory. Replace with
a Supabase PostgreSQL function that atomically checks and increments
per key, shared across all instances.

- Add rate_limits table + check_rate_limit SQL function (migration 010)
- Rewrite lib/rate-limit.ts to call Supabase RPC instead of LRU cache
- Simplify lib/middleware/rate-limit.ts to wrap the new checkRateLimit
- Update all 7 routes using the old LRU-based limiter
- Remove lru-cache and @types/lru-cache dependencies
- Auth routes (5) unchanged — they already use the middleware wrapper

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 17:23:15 +01:00
g-butandClaude Opus 4.5 1c7abeebac docs(claude): add global standards reference and update date
- Add @~/.claude/CLAUDE.md import for global engineering standards
- Update Last Updated date to 2026-01-23

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 15:22:36 +01:00
g-butandClaude Opus 4.5 4929569807 chore: Remove obsolete pre-launch waitlist code
The waitlist feature was from the pre-launch phase when collecting
early signups. Now that Botsmann is live, this code is no longer needed.

Removed:
- app/api/waitlist/route.ts
- lib/models/waitlist.ts
- lib/schemas/waitlist.ts
- supabase/migrations/010_waitlist.sql (was just created in error)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 11:32:53 +01:00
g-butandClaude Opus 4.5 842abc3590 feat: Migrate waitlist to Supabase and add error boundaries
- Replace file-based JSON storage with Supabase for waitlist API
- Add SQL migration for waitlist table (010_waitlist.sql)
- Add error.tsx for segment-level error handling
- Add global-error.tsx for root-level error handling
- Add not-found.tsx for 404 page
- Add reusable ErrorBoundary component for client components
- Remove unused data/waitlist.json

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 11:01:43 +01:00
g-butandClaude Opus 4.5 beae8512a7 feat: add user-centric architecture with profiles and domain tagging
Implements user-centric data model where users are the constant and
professionals are lenses into their data. Follows DRY, SSOT, and SoC principles.

Database changes (migration 009):
- Add user_profiles table with RLS policies
- Add domains column to documents table (TEXT[])
- Add professional_slug column to conversations table
- Add triggers for auto-updating user stats
- Add ensure_user_profile() helper function

New files:
- lib/domains.ts: SSOT for all domain definitions
- lib/validations/domain.ts: Zod schemas for domain validation
- lib/validations/user-profile.ts: User profile validation schemas
- app/api/user/profile/route.ts: GET/PATCH user profile API
- app/api/documents/[id]/route.ts: GET/PATCH document API

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 15:10:53 +01:00
g-butandClaude Sonnet 4.5 9aa417e273 refactor: clean up API routes and components, add shared utilities
Refactored multiple API routes and components to improve code organization and reduce duplication:
- Simplified API route implementations across chat, documents, consultations, and other endpoints
- Reorganized navigation components for better maintainability
- Added shared utility functions and hooks
- Created reusable Avatar and Logo components
- Added validation schemas and API utilities
- Improved type definitions and constants management

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-16 11:04:19 +01:00
g-butandClaude Opus 4.5 403c9bf5a7 Add Phase 3: Document upload and RAG chat
- Add Transformers.js for local embeddings generation
- Create document upload API with Supabase Storage
- Create document processing pipeline (parse, chunk, embed)
- Create semantic search API using pgvector
- Create RAG chat API combining search + LLM
- Add documents page UI with upload, process, and chat
- Add database migration for document status columns
- Configure Next.js to externalize ONNX packages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 12:39:43 +01:00
g-butandClaude Opus 4.5 e06e68f5fe Migrate database from MongoDB to Supabase
- Replace MongoDB/Mongoose with Supabase (free tier)
- Add lib/supabase.ts client with lazy loading
- Update consultations API to use Supabase
- Update health endpoint for Supabase
- Add SQL migration for consultations table
- Remove MongoDB dependencies from package.json
- Update .env.example with Supabase variables

Cost: $0/month (Supabase free tier)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 11:55:15 +01:00