app-template/README.md

51 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# App Template — Astro + tRPC + Drizzle Monorepo
可复用全栈脚手架:**不绑定产品业务**,只保留鉴权 + `user` 垂直示例,演示完整分层接线。
```
.
├── app/
│ └── web/ @app/web — Astro SSR + React islands + i18n 路由
├── packages/
│ ├── types/ @app/types — Zod 入参 schema + 共享 DTO
│ ├── models/ @app/models — Drizzle 表定义(唯一 schema 源)
│ ├── db/ @app/db — libSQL/Turso 连接单例 + drizzle-kit
│ ├── dao/ @app/dao — 数据访问层
│ ├── trpc/ @app/trpc — tRPC 路由 + service
│ ├── ui/ @app/ui — shadcn 风格基础组件 + Storybook
│ ├── design-tokens/ @app/design-tokens
│ ├── seo-geo/ @app/seo-geo — SEO/GEO 纯函数
│ ├── i18n/ @app/i18n — zh-CN / en 文案与 locale 工具
│ └── adsense/ @app/adsense — AdSense 加载(可选)
└── docs/
```
## 快速开始
```bash
yarn install
cp .env.example .env
# 填入 TURSO_DATABASE_URL / TURSO_AUTH_TOKEN / PUBLIC_SITE_URL
yarn db:push # 推 schema
yarn dev:web # Astro :4321
```
## 技术栈
| 层 | 技术 |
|------|------|
| 前端 | Astro 7 + React 19 islands |
| API | tRPC v11 |
| ORM | Drizzle + @libsql/client(Turso) |
| 样式 | Tailwind CSS 4 + design-tokens |
| 校验 | Zod 4 |
| 工程 | TypeScript 7 · Biome · Yarn 4 · Turbo |
## 分层(必须遵守)
`web → trpc → dao → db → models`,横切 `types`。禁止循环依赖;跨包只走 `package.json` 的 `exports`。
新增业务实体请复制 `user` 垂直切片:`types` schema → `models` 表 → `dao` 查询 → `trpc` service/router → `web` 页面。细节见根目录 `AGENTS.md`。