{"id":18315788,"url":"https://github.com/aifuxi/fuxiaochen","last_synced_at":"2026-04-26T14:04:18.723Z","repository":{"id":178677777,"uuid":"661913229","full_name":"aifuxi/fuxiaochen","owner":"aifuxi","description":"🌈 一个简单的个人博客，使用 Next.js 构建 ","archived":false,"fork":false,"pushed_at":"2026-04-26T11:46:39.000Z","size":11547,"stargazers_count":440,"open_issues_count":0,"forks_count":55,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-26T12:20:43.871Z","etag":null,"topics":["better-auth","bytemd","docker-compose","nextjs","prisma","react","shadui","tailwindcss"],"latest_commit_sha":null,"homepage":"https://fuxiaochen.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aifuxi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2023-07-04T00:49:01.000Z","updated_at":"2026-04-26T11:46:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"2e780a62-aeaf-4381-b490-9d4015164ba9","html_url":"https://github.com/aifuxi/fuxiaochen","commit_stats":null,"previous_names":["aifuxi/aifuxi.cool"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/aifuxi/fuxiaochen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aifuxi%2Ffuxiaochen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aifuxi%2Ffuxiaochen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aifuxi%2Ffuxiaochen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aifuxi%2Ffuxiaochen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aifuxi","download_url":"https://codeload.github.com/aifuxi/fuxiaochen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aifuxi%2Ffuxiaochen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32299645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T09:34:17.070Z","status":"ssl_error","status_checked_at":"2026-04-26T09:34:00.993Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["better-auth","bytemd","docker-compose","nextjs","prisma","react","shadui","tailwindcss"],"created_at":"2024-11-05T17:01:14.671Z","updated_at":"2026-04-26T14:04:18.715Z","avatar_url":"https://github.com/aifuxi.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# fuxiaochen\n\n基于 Next.js 16 App Router 的个人站点与后台管理系统。项目同时包含公开站点、认证页面、后台 CRUD、数据库配置化站点信息、内容导入脚本，以及 Docker standalone 部署配置。\n\n## 技术栈\n\n- Framework: Next.js 16, React 19, TypeScript strict\n- UI: Tailwind CSS v4, shadcn/ui `new-york`, Radix UI, Lucide, Sonner, NiceModal\n- Data: PostgreSQL, Drizzle ORM, Drizzle Kit, Redis\n- Auth: Better Auth, GitHub OAuth\n- Content: ByteMD Markdown preview/rendering, Highlight.js\n- Tooling: Bun, Oxlint, Oxfmt, Husky, lint-staged, commitlint\n- Deploy: Next `output: \"standalone\"`, Docker, `next-sitemap`\n\n## 功能概览\n\n- 公开站点：主页、博客、项目、友链、更新日志、关于页。\n- 博客体验：分类/标签筛选、详情页、目录、代码高亮、阅读统计、点赞、相似文章、评论。\n- 后台管理：分析看板、文章、项目、分类、标签、友链、更新日志、评论、用户、站点设置。\n- 认证与权限：Better Auth 负责登录注册与会话，`proxy.ts` 保护 `/admin/**` 与 `/api/admin/**`。\n- 站点配置：站点名称、SEO、个人资料、社交链接、备案与分析配置存储在 `site_settings`，默认值在 `lib/settings/defaults.ts`。\n- 数据接口：公开接口位于 `/api/public/**`，后台接口位于 `/api/admin/**`，统一通过 `lib/server/**` 分层实现。\n\n## 快速开始\n\n### 环境要求\n\n- Node.js `\u003e= 20`，推荐使用仓库 `.nvmrc` 中的 Node `24`\n- Bun `\u003e= 1.3.11`\n- Docker / Docker Compose，用于本地 PostgreSQL 与 Redis\n\n### 安装依赖\n\n```bash\nbun install\n```\n\n### 配置环境变量\n\n```bash\ncp .env.example .env\n```\n\n至少需要配置：\n\n- `DATABASE_URL`\n- `REDIS_URL`\n- `BETTER_AUTH_SECRET`\n- `BETTER_AUTH_URL`\n- `NEXT_PUBLIC_SITE_URL`\n- GitHub OAuth 与 OSS 相关变量按需配置\n\n本地依赖服务默认可以用 Docker 启动：\n\n```bash\ndocker compose up -d postgresql redis\n```\n\n`.env.example` 中 PostgreSQL 端口为 `5400`，和 `docker-compose.yml` 的本地映射一致。密码、库名等值需要与本地 `.env` 保持一致。\n\n### 初始化数据库\n\n```bash\nbun run db:migrate\n```\n\n如需导入 `data/` 下的博客、分类、标签示例内容：\n\n```bash\nbun run db:import:blog-content\n```\n\n### 启动开发服务器\n\n```bash\nbun run dev\n```\n\n默认访问：\n\n- 公开站点：http://localhost:3000\n- 后台入口：http://localhost:3000/admin\n\n## 常用命令\n\n| 命令                             | 说明                                           |\n| -------------------------------- | ---------------------------------------------- |\n| `bun run dev`                    | 启动 Next.js 开发服务器                        |\n| `bun run build`                  | 生产构建，并在 `postbuild` 生成 sitemap        |\n| `bun run start`                  | 启动生产构建产物                               |\n| `bun run build:analyzer`         | 启用 bundle analyzer 执行构建                  |\n| `bun run lint`                   | 运行 Oxlint                                    |\n| `bun run lint:fix`               | 运行 Oxlint 自动修复                           |\n| `bun run format`                 | 运行 Oxfmt 格式化                              |\n| `bun run format:check`           | 检查格式                                       |\n| `bun run db:generate`            | 根据 `lib/db/schema.ts` 生成 Drizzle migration |\n| `bun run db:migrate`             | 执行 Drizzle migration                         |\n| `bun run db:push`                | 直接推送 schema 到数据库                       |\n| `bun run db:reset`               | 清空已存在表数据，不重建 schema                |\n| `bun run db:studio`              | 打开 Drizzle Studio                            |\n| `bun run db:import:blog-content` | 导入 `data/` 下的博客内容                      |\n| `bun run commit`                 | 使用 Commitizen 生成提交信息                   |\n\n## 目录结构\n\n```text\napp/\n  (site)/             公开站点页面\n  (auth)/             登录、注册页面\n  (admin)/admin/      后台管理页面\n  api/                Route Handlers\ncomponents/           业务组件与 shadcn/ui 组件\nconstants/            路由、展示文案、基础信息常量\ndata/                 内容导入用示例数据\ndrizzle/              Drizzle migration\nhooks/                React hooks\nlib/\n  api/                前端 API fetcher\n  db/                 Drizzle schema 与数据库连接\n  server/             服务端 dto/handler/service/repository 分层\n  settings/           站点配置类型与默认值\nscripts/              数据库辅助脚本\npublic/               静态资源\n```\n\n## 数据与 API 约定\n\n服务端资源通常按以下结构组织：\n\n```text\nlib/server/\u003cresource\u003e/\n  dto.ts\n  handler.ts\n  service.ts\n  repository.ts\n  mappers.ts\n```\n\n- `dto` 使用 Zod 校验输入。\n- `handler` 解析请求并返回统一 API envelope。\n- `service` 承载业务规则和错误归一化。\n- `repository` 承载 Drizzle 查询。\n- `mappers` 将数据库行、聚合结果或第三方返回值归一化成 API DTO。\n\n前端请求优先复用 `lib/api/fetcher.ts` 中的 `apiRequest`、`fetchApiData` 和 `buildApiUrl`。通用错误提示通过客户端事件总线集中分发，需要页面自行展示错误状态时可关闭 `toastOnError`。\n\n## 数据库\n\nSchema 唯一来源是 `lib/db/schema.ts`，migration 输出到 `drizzle/`。主要业务表包括：\n\n- `blogs`, `categories`, `tags`, `blog_tags`\n- `blog_daily_stats`\n- `projects`, `friends`, `changelogs`\n- `comments`, `notifications`\n- `site_settings`\n- Better Auth 相关的 `users`, `sessions`, `accounts`, `verifications`\n\n修改 schema 后应执行：\n\n```bash\nbun run db:generate\nbun run db:migrate\n```\n\n`bun run db:reset` 只清空当前 schema 下已经存在的表数据。如果目标数据库还没有建表，先运行 migration 或 `db:push`。\n\n## 质量检查\n\n提交前至少运行：\n\n```bash\nbun run lint\nbun run format:check\n```\n\n涉及路由、构建配置、数据库 schema、服务端 API 或生产行为时，额外运行：\n\n```bash\nbun run build\n```\n\n仓库当前没有 `test` 脚本。Husky 会在提交时运行 lint-staged 与 commitlint，但本地钩子不应替代手动验证。\n\n## Docker\n\n构建镜像：\n\n```bash\nmake build_image\n```\n\n或直接：\n\n```bash\ndocker build -t fuxiaochen:latest .\n```\n\n运行依赖服务与应用容器：\n\n```bash\ndocker compose up -d\n```\n\nDocker 构建与运行需要 `.env` 中提供数据库、Redis、Better Auth、OSS、GitHub OAuth、站点 URL 等环境变量。生产构建输出使用 Next standalone，运行入口为 `node server.js`。\n\n## 提交规范\n\n提交信息遵循 Conventional Commits，例如：\n\n```text\nfeat(blog): improve list filtering\nfix(api): handle invalid payload\n```\n\n可以使用：\n\n```bash\nbun run commit\n```\n\nPR 描述建议包含变更摘要、验证方式、UI 截图或录屏，以及 schema、认证或环境变量相关的升级说明。\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faifuxi%2Ffuxiaochen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faifuxi%2Ffuxiaochen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faifuxi%2Ffuxiaochen/lists"}