4.6 KiB
4.6 KiB
Project Context
Workspace
- Root:
D:\workspace\code\app - Git repository root:
D:\workspace - Projects:
app-go: Go backend.app-rn: Expo / React Native frontend.
- Database connection memo:
D:\workspace\code\app\db.local.yml- This file is intentionally placed under
approot and is currently Git-trackable.
Backend: app-go
- Tech stack: Go, Fiber v3, pgx PostgreSQL client, JWT, Viper, Zap, S3/RustFS, QQ/WeChat login.
- Main entry:
app-go/cmd/app/main.go - Bootstrap:
app-go/internal/bootstrap/app.go - Routes:
app-go/internal/router/router.go - API base path from config:
/app
Important endpoints:
POST /app/auth/login/qqPOST /app/auth/login/wechatPOST /app/bind/qqPOST /app/bind/wechatPOST /app/data/loadDataPOST /app/data/loadDataBySqlPOST /app/data/saveDataPOST /app/data/getUniqueIdPOST /app/s3/uploadPOST /app/s3/delete
Architecture notes:
- Backend exposes generic data APIs that accept table/view names, conditions, raw SQL, and save payloads.
- This matches the frontend's generic
loadDataApi,loadDataBySqlApi, andsaveDataApi. - There are no explicit database foreign keys; relationships are enforced by code and naming conventions.
go test ./...currently fails inpkg/uniqueid/IdGeneratorException.gobecausefmt.Println(message)should likely befmt.Println(message...).
Security notes:
- Existing config files include live credentials.
- User explicitly said they do not plan to modify the backend.
- Database access was allowed with full permissions via the connection in
db.local.yml.
Frontend: app-rn
- Tech stack: Expo 55, React Native 0.83, React 19, expo-router, Zustand, Alova/Axios, HeroUI Native, Uniwind.
- Main package file:
app-rn/package.json - Root layout:
app-rn/src/app/_layout.tsx - API wrapper:
app-rn/src/request/index.ts - API methods:
app-rn/src/request/api.ts - User store:
app-rn/src/store/user.ts - Family store:
app-rn/src/store/family.ts - Finance store:
app-rn/src/store/finance.ts
Frontend/backend contract:
- Frontend reads
EXPO_PUBLIC_API_URL. - Requests use Alova with Axios adapter.
- Auth token is sent in custom
Tokenheader. - Backend response shape is
{ code, message, data, track_id }. - Success code is
1000. - Unauthorized code is
1001. - Business error code is
2000. - System error code is
3000.
Known frontend type-check issues:
pnpm exec tsc --noEmitfails.tsconfig.jsonincludes**/*.tsand**/*.tsx, which pulls inexample.tsconfig.jsonhas a suspicious extra include entry:src/app/auth/login_2.- Generated iconfont components have
react-native-svgprop type incompatibilities. src/app/finance/(tabs)/analysis/index.tsxhasSurface variant="2"type mismatch.
Database: allapp
- PostgreSQL version observed: 18.1.
- Database:
allapp. - User used for inspection:
postgres. - Schema:
public. - Tables: 7.
- Views: 1.
- Explicit foreign keys: none.
Tables and row counts at inspection time:
b_user: 1 row.b_user_oauth: 2 rows.b_family: 1 row.b_family_member: 1 row.b_finance: 0 rows.b_finance_category: 20 rows.b_finance_category_default: 20 rows.
Main entities:
b_user: user profile, including nickname, avatar, last login time, name, phone, birth date.b_user_oauth: third-party login bindings. Fields includeuser_id,type,openid.b_family: family/space. Fields includename,invite_code,owner_id.b_family_member: family membership. Fields includefamily_id,user_id,role,nickname.b_finance: finance records. Fields includecategory_id,family_id,amount,remark,record_time.b_finance_category_default: default finance category template.b_finance_category: actual finance categories for a family.v_family_member: view joiningb_family_memberwithb_user.
View definition summary:
v_family_memberselects member fields fromb_family_memberand user profile fields fromb_user.- Join condition:
b_user.id = b_family_member.user_id.
Finance category convention:
type = 0: expense.type = 1: income.- Category icons match frontend iconfont names, for example:
finance_jiaotongfinance_canyinfinance_shicaifinance_gouwufinance_gongzifinance_jianzhifinance_shouru
Useful Mental Model
This is a small full-stack personal/family app. The backend is intentionally generic and thin, while most product behavior lives in the React Native frontend and database table conventions. The database is part of the project context and should be considered when understanding features.