feat: Implement initial full-stack application structure including frontend pages, components, hooks, API integration, and backend services for account pooling and management.

This commit is contained in:
2026-01-30 07:40:35 +08:00
commit f4448bbef2
106 changed files with 19282 additions and 0 deletions

137
backend/README.md Normal file
View File

@@ -0,0 +1,137 @@
# Codex Pool Backend
Codex Pool 后端服务 - 标准 Go 项目结构
## 目录结构
```
backend/
├── cmd/
│ └── main.go # 程序入口
├── internal/
│ ├── api/
│ │ └── http.go # HTTP 工具、中间件
│ ├── auth/
│ │ ├── s2a.go # S2A 授权逻辑
│ │ ├── rod.go # Rod 浏览器自动化
│ │ └── chromedp.go # Chromedp 浏览器自动化
│ ├── client/
│ │ └── tls.go # TLS 指纹 HTTP 客户端
│ ├── config/
│ │ └── config.go # 配置类型和加载
│ ├── database/
│ │ └── sqlite.go # SQLite 操作
│ ├── invite/
│ │ └── team.go # Team 邀请功能
│ ├── logger/
│ │ └── logger.go # 日志系统
│ ├── mail/
│ │ └── service.go # 邮箱服务
│ └── register/
│ └── chatgpt.go # ChatGPT 注册功能
├── config.json # 配置文件
├── config.example.json # 配置示例
└── go.mod
```
## 快速启动
```bash
# 编译
go build -o codex-pool.exe ./cmd
# 运行
./codex-pool.exe
```
## 配置文件
创建 `config.json`
```json
{
"port": 8088,
"cors_origin": "*",
"s2a_api_base": "https://your-s2a-api.com",
"s2a_admin_key": "your-admin-key",
"default_proxy": "",
"accounts_path": "accounts.json",
"concurrency": 100,
"priority": 30,
"group_ids": [1, 2, 3],
"mail_services": [
{
"name": "主邮箱服务",
"api_base": "https://mail.example.com",
"api_token": "your-token",
"domain": "example.com"
}
]
}
```
## 包说明
| 包 | 说明 |
|---|------|
| `cmd` | 程序入口 |
| `internal/api` | HTTP 响应工具、CORS 中间件 |
| `internal/auth` | S2A 授权、浏览器自动化 |
| `internal/client` | TLS 指纹 HTTP 客户端 |
| `internal/config` | 配置类型、加载函数 |
| `internal/database` | SQLite 数据库操作 |
| `internal/invite` | Team 邀请功能 |
| `internal/logger` | 日志系统 |
| `internal/mail` | 邮箱服务 |
| `internal/register` | ChatGPT 注册功能 |
## API 接口
### 基础
- `GET /api/health` - 健康检查
- `GET /api/config` - 获取配置
### 日志
- `GET /api/logs` - 获取日志
- `POST /api/logs/clear` - 清空日志
### S2A 代理
- `GET /api/s2a/test` - 测试连接
### 邮箱服务
- `GET /api/mail/services` - 获取配置
- `POST /api/mail/services/test` - 测试连接
### Team Owner
- `GET /api/db/owners` - 获取列表
- `GET /api/db/owners/stats` - 获取统计
- `POST /api/db/owners/clear` - 清空
## 清理旧文件
如果已迁移到新结构,可以删除根目录的旧文件:
```powershell
# 删除旧的 .go 文件 (保留 go.mod, go.sum)
Remove-Item main.go, types.go, http.go, api_handlers.go, db_api.go, database.go, mail.go, codex-auth.go, browser-auth-rod.go, browser-auth-cdp.go, client.go, register.go, team-invite.go, log_stream.go, logger.go -ErrorAction SilentlyContinue
# 删除旧的 exe
Remove-Item codex-pool.exe -ErrorAction SilentlyContinue
```
## 开发
```bash
# 安装依赖
go mod tidy
# 运行
go run ./cmd
# 编译
go build -o codex-pool.exe ./cmd
```
## 许可
MIT License