130 lines
4.6 KiB
Markdown
130 lines
4.6 KiB
Markdown
# 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 `app` root 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/qq`
|
|
- `POST /app/auth/login/wechat`
|
|
- `POST /app/bind/qq`
|
|
- `POST /app/bind/wechat`
|
|
- `POST /app/data/loadData`
|
|
- `POST /app/data/loadDataBySql`
|
|
- `POST /app/data/saveData`
|
|
- `POST /app/data/getUniqueId`
|
|
- `POST /app/s3/upload`
|
|
- `POST /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`, and `saveDataApi`.
|
|
- There are no explicit database foreign keys; relationships are enforced by code and naming conventions.
|
|
- `go test ./...` currently fails in `pkg/uniqueid/IdGeneratorException.go` because `fmt.Println(message)` should likely be `fmt.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 `Token` header.
|
|
- 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 --noEmit` fails.
|
|
- `tsconfig.json` includes `**/*.ts` and `**/*.tsx`, which pulls in `example`.
|
|
- `tsconfig.json` has a suspicious extra include entry: `src/app/auth/login_2`.
|
|
- Generated iconfont components have `react-native-svg` prop type incompatibilities.
|
|
- `src/app/finance/(tabs)/analysis/index.tsx` has `Surface 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 include `user_id`, `type`, `openid`.
|
|
- `b_family`: family/space. Fields include `name`, `invite_code`, `owner_id`.
|
|
- `b_family_member`: family membership. Fields include `family_id`, `user_id`, `role`, `nickname`.
|
|
- `b_finance`: finance records. Fields include `category_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 joining `b_family_member` with `b_user`.
|
|
|
|
View definition summary:
|
|
|
|
- `v_family_member` selects member fields from `b_family_member` and user profile fields from `b_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_jiaotong`
|
|
- `finance_canyin`
|
|
- `finance_shicai`
|
|
- `finance_gouwu`
|
|
- `finance_gongzi`
|
|
- `finance_jianzhi`
|
|
- `finance_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.
|