CompanionHK is an AI companion app for Hong Kong users with three role spaces: Companion, Local Guide, and Study Guide, focused on safety and practical daily support.
frontend/: Next.js 16 (App Router) + TypeScript + Tailwind CSS 4 + shadcn/ui + Framer Motionbackend/: FastAPI + Pydantic orchestration APIinfra/: Local PostgreSQL (pgvector) + Redis development stack
- Multi-page frontend:
/welcome(landing),/login(auth),/(role selection),/chat/[role](chat),/weather(weather details). - localStorage-based auth via
AuthProvidercontext (hackathon scope). - Provider adapters with
MiniMaxas the core model route, feature-flagged. - Stateful orchestration through a LangGraph-capable runtime boundary (feature-flagged).
- Hybrid long-term memory: Postgres profile memory + pgvector retrieval memory.
- One chat model route with role-specific prompts and role-scoped thread spaces.
- Safety monitor with two-tier evaluation (MiniMax + rules fallback) and crisis banner UX.
- Weather-adaptive UI theming via CSS custom properties and
WeatherProvidercontext. - Voice pipeline: ElevenLabs + Cantonese.ai with adapter-based fallback.
- Local recommendations: Google Maps places + routes, weather context, preference scoring, optional Exa retrieval.
- Copy environment template:
cp .env.example .env
- Start local infra:
docker compose -f infra/docker-compose.yml up -d
- Apply database migrations:
cd backend && uv run alembic upgrade head && cd ..
- Run backend (choose one):
venv:cd backend && python3 -m venv .venv && source .venv/bin/activate && pip install -e '.[dev]' && uvicorn app.main:app --reload --port 8000uv:cd backend && uv sync --all-extras && uv run uvicorn app.main:app --reload --port 8000conda:cd backend && conda env create -f environment.yml || conda env update -f environment.yml --prune && conda run -n companionhk-backend uvicorn app.main:app --reload --port 8000
- Run frontend:
cd frontend && npm install && npm run dev
- Open
http://localhost:3000— you will land on the welcome page, then log in and select a role.
Minimum for local preview:
NEXT_PUBLIC_API_BASE_URL=http://localhost:8000CHAT_PROVIDER=mock(orminimaxwithMINIMAX_API_KEY)
Optional for richer Local Guide experience:
GOOGLE_MAPS_API_KEY(backend places + routes)NEXT_PUBLIC_GOOGLE_MAPS_API_KEY(frontend map canvas)
See .env.example for the full list of feature flags and provider keys.
- Backend tests:
venv:cd backend && source .venv/bin/activate && pytest -quv:cd backend && uv run pytest -qconda:cd backend && conda run -n companionhk-backend pytest -q
- Frontend tests:
cd frontend && npm run test
| Path | Purpose |
|---|---|
/welcome |
Landing page |
/login |
Login / signup |
/ |
Role selection (protected) |
/chat/companion |
Companion chat |
/chat/guide |
Local Guide chat |
/chat/study |
Study Guide chat |
/weather |
Weather details |
- Architecture overview:
ARCHITECTURE.md(design, diagrams, data flows)
- Weather API usage:
docs/integrations/open-meteo.md - Google Maps API usage:
docs/integrations/google-maps.md - Recommendation and weather app contract:
docs/architecture/recommendation-contract.md - Database schema:
docs/architecture/database-schema.md - Role system:
docs/architecture/role-system.md - Full tech stack:
docs/TECHSTACK.md
