topfans/backend/QUICK_START.md
2026-04-07 22:29:48 +08:00

126 lines
2.9 KiB
Markdown
Raw Permalink 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.

# TopFans Backend - 快速安装指南
## 🚀 一键安装和启动macOS
### 新用户 - 完整安装
从克隆项目到启动服务,一条命令完成:
```bash
# 克隆项目
git clone https://github.com/Infinite-Matrix-Technology/TopFans.git
cd TopFans/backend
# 运行完整安装脚本(会自动安装所有依赖)
./setup-and-run.sh
```
### 已有项目 - 快速启动
如果项目已克隆,只需配置和启动:
```bash
cd TopFans/backend
# 运行快速启动脚本
./quick-start.sh
```
### 日常使用 - 启动/停止服务
```bash
# 启动所有服务
./start-all.sh
# 停止所有服务
./stop-all.sh
```
## 📋 脚本说明
| 脚本 | 用途 | 适用场景 |
|------|------|----------|
| `setup-and-run.sh` | 完整安装(含工具安装) | 全新环境,第一次配置 |
| `quick-start.sh` | 快速配置和启动 | 已有项目,重新配置 |
| `start-all.sh` | 启动所有服务 | 环境已配置好,日常启动 |
| `stop-all.sh` | 停止所有服务 | 停止运行中的服务 |
## 🔧 自动安装的组件
`setup-and-run.sh` 会自动安装:
- ✅ Homebrew如果未安装
- ✅ Go 1.23+
- ✅ PostgreSQL 18
- ✅ Protocol Buffers 编译器
- ✅ protoc 所有插件go、grpc、gateway、dubbo
- ✅ 配置数据库(创建用户和数据库)
- ✅ 生成 Proto 代码
- ✅ 启动所有微服务
## 🎯 启动后的服务
```
✅ Gateway (API网关): http://localhost:8080
✅ User Service: tri://127.0.0.1:20000
✅ Social Service: tri://127.0.0.1:20001
✅ Asset Service: tri://127.0.0.1:20003
✅ Gallery Service: tri://127.0.0.1:20004
```
## 🧪 测试 API
```bash
# 测试注册接口
curl -X POST http://localhost:8080/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"uid":"13800138000","password":"test123","fan_identity_id":"xz","nickname":"测试用户"}'
```
## 📊 查看日志
```bash
# 查看 Gateway 日志
tail -f logs/gateway.log
# 查看所有服务日志
tail -f logs/*.log
```
## 📚 详细文档
- **完整安装指南**: [INSTALL_GUIDE.md](./INSTALL_GUIDE.md)
- **API 文档**: [docs/HTTP REST API接口文档.md](./docs/HTTP%20REST%20API接口文档.md)
- **架构设计**: [docs/微服务架构设计.md](./docs/微服务架构设计.md)
## ⚡ 常见问题
### 端口被占用?
```bash
./stop-all.sh # 停止现有服务
./start-all.sh # 重新启动
```
### PostgreSQL 未启动?
```bash
brew services start postgresql@18
```
### 依赖下载慢?
```bash
export GOPROXY=https://goproxy.cn,direct
```
## 🆘 需要帮助?
1. 查看详细文档:[INSTALL_GUIDE.md](./INSTALL_GUIDE.md)
2. 查看日志:`logs/*.log`
3. 提交 Issue[GitHub Issues](https://github.com/Infinite-Matrix-Technology/TopFans/issues)
---
**注意**:这些脚本专为 macOS 设计。Linux 用户请参考 [手动安装指南](./INSTALL_GUIDE.md#手动安装)。