d9e09b61ee770a846d1099681e3fb2661dd325d5
核心功能: - AIAgent 模型:AI 代理身份管理 - AIOperationLog: AI 操作日志记录 - AITask: AI 异步任务系统 - AIWebhook: AI webhook 订阅 API 端点: - POST /api/agents/auth/ - AI 代理认证 - GET/POST /api/agents/ - 代理管理 - GET /api/agent-logs/ - 操作日志查询 - GET/POST /api/agent-tasks/ - 任务管理 - GET/POST /api/agent-webhooks/ - Webhook 管理 - POST /api/batch/ - 批量操作 预置 AI 代理: - content-moderator-ai: 内容审核 AI - content-generator-ai: 内容生成 AI - service-curator-ai: 服务推荐 AI - analytics-ai: 数据分析 AI - admin-ai: 管理员 AI 文档: - AI_AGENT.md: AI-First 设计文档 - init_agents.py: AI 代理初始化脚本 测试: - 认证系统测试通过 - JWT token 生成正常 - 权限系统工作正常
React + Django Full-Stack Project
项目信息
项目名称: 城市手册(CityWiki)
项目定位: 地方志兼本地生活服务平台
技术栈: React + Django + PostgreSQL + Docker
功能特性
- ✅ 用户认证系统(注册、登录、JWT)
- ✅ 版块层级管理(省→市→县→乡镇→村)
- ✅ 文章管理(创建、审核、发布)
- ✅ 特色服务(衣食住行娱乐旅游文化)
- ✅ 交互功能(评论、评分、点赞、收藏)
- ✅ 版主管理(申请、权限、审核)
- ✅ 内容审核流程(版主初审 + AI 审核)
技术栈
Backend
- Django 4.2
- Django REST Framework
- JWT Authentication (djangorestframework-simplejwt)
- GraphQL (graphene-django)
- PostgreSQL
Frontend
- React 18 (Create React App)
- MobX (状态管理)
- styled-components (CSS-in-JS)
- React Router
Deployment
- Docker & Docker Compose
- Nginx (反向代理)
Project Structure
.
├── backend/ # Django project
│ ├── config/ # Settings and configuration
│ ├── apps/ # Django apps
│ ├── static/ # Static files
│ └── media/ # Media files
├── frontend/ # React project
│ ├── src/
│ │ ├── components/
│ │ ├── stores/ # MobX stores
│ │ ├── services/ # API calls
│ │ └── styles/
│ └── public/
├── docker-compose.yml
└── .env.example
快速开始
1. 克隆项目
git clone http://10.2.0.100:8989/mashen/chengshishouce.git
cd chengshishouce
2. 环境变量配置
cp .env.example .env
# 编辑 .env 文件,配置数据库和其他设置
3. 后端启动
cd backend
# 创建虚拟环境
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 安装依赖
pip install -r requirements.txt
# 运行迁移
python manage.py migrate
# 创建超级用户
python manage.py createsuperuser
# 启动开发服务器
python manage.py runserver
4. 前端启动
cd frontend
# 安装依赖
npm install
# 启动开发服务器
npm start
5. 访问应用
- 前端:http://localhost:3000
- 后端 API:http://localhost:8000
- GraphQL:http://localhost:8000/graphql
- Django Admin:http://localhost:8000/admin
Docker 部署
# 构建并启动所有服务
docker-compose up -d
# 查看日志
docker-compose logs -f
# 停止服务
docker-compose down
详细部署指南请参考 DEPLOYMENT.md
项目文档
API Endpoints
REST API
/api/users/- User management/api/users/me/- Current user/api/auth/token/- Login (POST)/api/auth/token/refresh/- Refresh token (POST)
GraphQL
/graphql/- GraphQL endpoint/graphql/?graphiql- GraphQL playground
Development
Running Backend
cd backend
python manage.py runserver
Running Frontend
cd frontend
npm start
Running Tests
Backend:
cd backend
python manage.py test
Frontend:
cd frontend
npm test
Production Deployment
Using Docker Compose
- Update
.envwith production values - Build images:
docker-compose build - Start services:
docker-compose up -d
Nginx Configuration
The frontend Dockerfile includes nginx configuration that:
- Serves React app
- Proxies
/apirequests to Django backend - Proxies
/graphqlrequests to Django backend - Handles static and media files
Security Notes
- Never commit
.envfiles - Change
DJANGO_SECRET_KEYin production - Use strong passwords for database
- Enable HTTPS in production
- Configure
ALLOWED_HOSTSproperly - Set
DEBUG=Falsein production
License
MIT
Description
Languages
Python
55.7%
JavaScript
31.2%
CSS
7.1%
Shell
5.6%
Dockerfile
0.2%
Other
0.2%