Files
thebet365/README.md
Mars 4c92157299 重构 API 为 8 领域 + 应用层架构
将后端模块拆分为 domains、applications、shared 三层,结算计算器移入 domain 纯函数目录,API 路径与测试保持不变。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-02 14:48:41 +08:00

108 lines
2.5 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.
# TheBet365 - 足球投注平台 MVP
Monorepo 项目,包含 NestJS 后端与 Vue 3 三端前端。
## 技术栈
| 层级 | 技术 |
|------|------|
| 后端 | NestJS + Prisma + PostgreSQL + Redis |
| 玩家前台 | Vue 3 + Vite + Pinia (H5 移动端优先) |
| 平台/代理后台 | Vue 3 + Vite + Element Plus |
| 包管理 | pnpm workspace |
## 快速开始
### 1. 启动基础设施
```bash
docker compose up -d
```
### 2. 安装依赖
```bash
pnpm install
```
### 3. 配置环境
```bash
cp .env.example apps/api/.env
```
### 4. 数据库迁移与种子数据
```bash
pnpm db:migrate
pnpm db:seed
```
### 5. 启动开发服务
```bash
pnpm dev:api # API http://localhost:3000
pnpm dev:player # 玩家前台 http://localhost:5173
pnpm dev:admin # 平台后台 http://localhost:5174
pnpm dev:agent # 代理后台 http://localhost:5175
```
API 文档http://localhost:3000/api/docs
## 测试账号
| 角色 | 用户名 | 密码 |
|------|--------|------|
| 超级管理员 | admin | Admin@123 |
| 一级代理 | agent1 | Agent@123 |
| 二级代理 | agent2 | Agent@123 |
| 玩家 | player1 | Player@123 |
## 项目结构
```
apps/api/src/
├── domains/ # 8 个业务领域
│ ├── identity/ # 身份与权限auth + users
│ ├── agent/ # 代理网络
│ ├── ledger/ # 账务账本wallet
│ ├── catalog/ # 赛事目录matches
│ ├── odds/ # 盘口赔率markets
│ ├── betting/ # 注单引擎
│ ├── settlement/ # 结算引擎(含 domain/ 纯函数)
│ └── operations/ # 运营支撑audit/cashback/content/i18n
├── applications/ # 三端应用层(编排,不含领域规则)
│ ├── player/
│ ├── admin/
│ └── agent/
├── shared/ # 基础设施
│ ├── prisma/
│ └── common/
├── app.module.ts
└── main.ts
apps/
player/ 玩家 H5 前台
admin/ 平台后台
agent/ 代理后台
packages/
shared/ 共享类型与常量
```
## MVP 功能
- 三端登录鉴权 + RBAC
- 2 级代理 + 信用额度池
- 钱包账变(禁止直接改余额)
- 11 种足球玩法 + 盘口模板
- 单关 / 2~5 串 1 下注
- 结算预览 + 确认入账
- 返水批次
- Banner / 公告 / 多语言
## 测试
```bash
pnpm --filter @thebet365/api test
```