07fbeea09b
Ersätter den tidigare webappen på denna branch med ett fokuserat monorepo: - apps/mobile: Expo/React Native med tre vyer (Welcome, Chat, Paywall), Cognito hosted UI-inloggning (Apple/Google/e-post) och In-App Purchase/Play Billing via en gemensam purchases-modul. - services/api: en enda Lambda-backend — OpenAI Responses API med Markdown-kunskapsbas som systeminstruktioner, free tier-gräns i PostgreSQL (HTTP 402 -> paywall) och kvittoverifiering bakom ett delat PaymentProvider-interface (Apple/Google, Stripe kan läggas till för webb senare). - infra: AWS CDK-stack med API Gateway (JWT-authorizer), Lambda, Cognito, Aurora Serverless v2 och Secrets Manager. - db/migrations: minimal datamodell (users + usage), inga konversationer sparas. - GitHub Actions: CI (lint, typecheck, test) och deploy från main. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0118DaxZR36RpnY524vRqx3z
20 lines
718 B
TypeScript
20 lines
718 B
TypeScript
import { readdirSync, readFileSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
|
|
let cached: string | undefined;
|
|
|
|
/**
|
|
* The knowledge base is a set of Markdown files bundled with the Lambda.
|
|
* They are concatenated and injected as system instructions. RAG (selective
|
|
* retrieval) can replace this later without changing the API surface.
|
|
*/
|
|
export function loadKnowledgeBase(): string {
|
|
if (cached !== undefined) return cached;
|
|
const dir = process.env.KNOWLEDGE_DIR ?? join(import.meta.dirname, '..', 'knowledge');
|
|
const files = readdirSync(dir)
|
|
.filter((f) => f.endsWith('.md'))
|
|
.sort();
|
|
cached = files.map((f) => readFileSync(join(dir, f), 'utf-8')).join('\n\n---\n\n');
|
|
return cached;
|
|
}
|