Files
AIclinicalresearch/backend
HaHafeng 4d7d97ca19 feat(aia): Protocol Agent streaming + editable state panel + protocol generation plan
Day 2 Development (2026-01-24):

Backend Enhancements:
- Implement SSE streaming in ProtocolAgentController using createStreamingService
- Add data condensation via LLM in ProtocolOrchestrator.handleProtocolSync
- Support stage editing without resetting progress
- Add explicit JSON output format for each stage in system prompt
- Create independent seed script for Protocol Agent (seed-protocol-agent.ts)

Frontend Improvements:
- Integrate useAIStream hook for typewriter effect in ChatArea
- Add MarkdownContent component for basic Markdown rendering
- Implement StageEditModal for editing stage data (scientific question, PICO, etc.)
- Add edit button to StageCard (visible on hover)
- Fix routing paths from /aia to /ai-qa
- Enhance CSS with full-screen layout and Markdown styles

New Documentation:
- One-click protocol generation development plan (v1.1)
- Editor selection evaluation (Novel vs BlockNote vs Tiptap)
- Novel fork strategy for AI-native editing

Technical Decisions:
- Choose Novel (Fork) as protocol editor for AI-first design
- Two-stage progressive generation: summary in chat, full protocol in editor
- 10-day development plan for protocol generation feature

Code Stats:
- Backend: 3 files modified, 1 new file
- Frontend: 9 files modified, 2 new files
- Docs: 3 new files

Status: Streaming and editable features working, protocol generation pending
2026-01-24 23:06:33 +08:00
..
2025-10-12 09:51:11 +08:00

AI临床研究平台 - 后端服务

🏠 导航


快速开始

1. 环境要求

  • Node.js >= 18
  • PostgreSQL 15+
  • Redis 7+

2. 安装依赖

npm install

3. 配置环境变量

复制.env.example.env并配置:

cp .env.example .env

4. 初始化数据库

# 生成Prisma Client
npm run prisma:generate

# 执行数据库迁移
npm run prisma:migrate

# 可选打开Prisma Studio查看数据
npm run prisma:studio

5. 启动开发服务器

npm run dev

服务器将在 http://localhost:3001 启动

6. 验证服务

访问以下端点验证服务是否正常:

项目结构

backend/
├── prisma/
│   └── schema.prisma          # 数据库模型定义
├── src/
│   ├── config/
│   │   ├── env.ts             # 环境变量配置
│   │   └── database.ts        # 数据库连接
│   ├── controllers/           # 控制器层
│   ├── services/              # 业务逻辑层
│   ├── routes/                # 路由定义
│   ├── types/                 # TypeScript类型定义
│   ├── utils/                 # 工具函数
│   └── index.ts               # 应用入口
├── .env                       # 环境变量不提交到Git
├── .env.example               # 环境变量模板
├── package.json               # 项目配置
└── tsconfig.json              # TypeScript配置

NPM Scripts

  • npm run dev - 启动开发服务器hot reload
  • npm run build - 构建生产版本
  • npm run start - 启动生产服务器
  • npm run prisma:generate - 生成Prisma Client
  • npm run prisma:migrate - 执行数据库迁移
  • npm run prisma:studio - 打开Prisma Studio

数据库设计

详见:../docs/01-设计文档/数据库设计文档.md

API文档

详见:../docs/01-设计文档/API设计规范.md

技术栈

  • 框架: Fastify
  • ORM: Prisma
  • 数据库: PostgreSQL
  • 缓存: Redis
  • 语言: TypeScript
  • 日志: Pino

Day 5 完成情况

初始化后端项目Node.js + TypeScript 配置Fastify框架 配置Prisma ORM 创建数据库表(执行迁移) 数据库连接测试通过

所有核心功能已完成!🎉