Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 8 additions & 8 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
**/*.pyo
**/*.db
**/.env
frontend
ui-showcase
apps/frontend
apps/ui-showcase
node_modules
backend/runtime_data
backend/output
backend/workflow.log
example_uploads
apps/backend/runtime_data
apps/backend/output
apps/backend/workflow.log
examples
outputs
assets
rules
docs/assets
docs/rules
/error_correction
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
backend/models/weight/*.pth filter=lfs diff=lfs merge=lfs -text
backend/text_eraser_model/weight/*.pth filter=lfs diff=lfs merge=lfs -text
apps/backend/models/weight/*.pth filter=lfs diff=lfs merge=lfs -text
apps/backend/text_eraser_model/weight/*.pth filter=lfs diff=lfs merge=lfs -text
6 changes: 3 additions & 3 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Backend CI
on:
pull_request:
paths:
- "backend/**"
- "apps/backend/**"
- "requirements.txt"
- "pyproject.toml"
- "Dockerfile"
Expand All @@ -15,7 +15,7 @@ on:
branches:
- main
paths:
- "backend/**"
- "apps/backend/**"
- "requirements.txt"
- "pyproject.toml"
- "Dockerfile"
Expand Down Expand Up @@ -52,4 +52,4 @@ jobs:
python -m pip install -r requirements.txt

- name: Run backend tests
run: python -m pytest backend/tests -v
run: python -m pytest apps/backend/tests -v
12 changes: 6 additions & 6 deletions .github/workflows/frontend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: Frontend CI
on:
pull_request:
paths:
- "frontend/**"
- "apps/frontend/**"
- ".github/workflows/frontend-ci.yml"
- ".github/workflows/release-ci-cd.yml"
push:
branches:
- main
paths:
- "frontend/**"
- "apps/frontend/**"
- ".github/workflows/frontend-ci.yml"
- ".github/workflows/release-ci-cd.yml"

Expand All @@ -34,16 +34,16 @@ jobs:
with:
node-version: "22"
cache: npm
cache-dependency-path: frontend/package-lock.json
cache-dependency-path: apps/frontend/package-lock.json

- name: Install dependencies
working-directory: frontend
working-directory: apps/frontend
run: npm ci

- name: Run tests
working-directory: frontend
working-directory: apps/frontend
run: npm test

- name: Build production assets
working-directory: frontend
working-directory: apps/frontend
run: npm run build
55 changes: 55 additions & 0 deletions .github/workflows/mobile-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Mobile CI

on:
pull_request:
paths:
- "apps/mobile/**"
- ".github/workflows/mobile-ci.yml"
push:
branches:
- main
paths:
- "apps/mobile/**"
- ".github/workflows/mobile-ci.yml"

permissions:
contents: read

concurrency:
group: mobile-ci-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
working-directory: apps/mobile

jobs:
test:
name: Analyze, test and build mobile app
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: "3.44.6"
channel: stable
cache: true
cache-key: flutter-${{ runner.os }}-${{ hashFiles('apps/mobile/pubspec.lock') }}

- name: Install dependencies
run: flutter pub get

- name: Check formatting
run: dart format --output=none --set-exit-if-changed lib test

- name: Analyze Dart code
run: flutter analyze --no-fatal-infos --fatal-warnings

- name: Run Flutter tests
run: flutter test

- name: Build Android debug APK
run: flutter build apk --debug
26 changes: 13 additions & 13 deletions .github/workflows/release-ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ jobs:
python -m pip install -r requirements.txt

- name: Run backend tests
run: python -m pytest backend/tests -v
run: python -m pytest apps/backend/tests -v

- name: Validate eraser model
shell: bash
run: |
set -euo pipefail
test -s backend/text_eraser_model/weight/best.pth
test "$(wc -c < backend/text_eraser_model/weight/best.pth)" -gt 100000000
test -s apps/backend/text_eraser_model/weight/best.pth
test "$(wc -c < apps/backend/text_eraser_model/weight/best.pth)" -gt 100000000

- name: Build production image
run: docker build --tag error-correction-backend:${{ github.sha }} .
Expand All @@ -70,29 +70,29 @@ jobs:
with:
node-version: "22"
cache: npm
cache-dependency-path: frontend/package-lock.json
cache-dependency-path: apps/frontend/package-lock.json

- name: Install dependencies
working-directory: frontend
working-directory: apps/frontend
run: npm ci

- name: Run tests
working-directory: frontend
working-directory: apps/frontend
run: npm test

- name: Build production assets
working-directory: frontend
working-directory: apps/frontend
run: npm run build

- name: Validate and package build
shell: bash
run: |
set -euo pipefail
test -f frontend/dist/app.html
test -d frontend/dist/assets
find frontend/dist/assets -type f -print -quit | grep -q .
cp frontend/dist/app.html frontend/dist/index.html
tar -C frontend/dist -czf error-correction-web.tar.gz .
test -f apps/frontend/dist/app.html
test -d apps/frontend/dist/assets
find apps/frontend/dist/assets -type f -print -quit | grep -q .
cp apps/frontend/dist/app.html apps/frontend/dist/index.html
tar -C apps/frontend/dist -czf error-correction-web.tar.gz .

- name: Upload production assets
uses: actions/upload-artifact@v7
Expand Down Expand Up @@ -244,7 +244,7 @@ jobs:
git lfs install --local
git lfs pull origin
test -f docker-compose.yml
test "$(wc -c < backend/text_eraser_model/weight/best.pth)" -gt 100000000
test "$(wc -c < apps/backend/text_eraser_model/weight/best.pth)" -gt 100000000
docker compose config --quiet
docker compose up -d --build --remove-orphans

Expand Down
30 changes: 16 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,32 @@ uv.lock

# Node 依赖与构建产物
node_modules/
ui-showcase/dist/
ui-showcase/package-lock.json
apps/ui-showcase/dist/
apps/ui-showcase/package-lock.json

# 前端构建产物
frontend/dist/
frontend/uploads/
frontend/output
apps/frontend/dist/
apps/frontend/uploads/
apps/frontend/output
presentation-vue/

# 后端运行产物
backend/runtime_data/
backend/output/
backend/*.db
backend/db/*.db
apps/backend/runtime_data/
apps/backend/output/
apps/backend/*.db
apps/backend/db/*.db
output/
outputs/
__pycache__/
backend/static/vue/assets
.pytest_cache/
apps/backend/static/vue/assets

# 模型权重文件
backend/models/weight/
backend/text_eraser_model/weight/
apps/backend/models/weight/
apps/backend/text_eraser_model/weight/

# 示例上传文件
example_uploads/notes/
examples/notes/
# 日志
workflow.log

Expand All @@ -49,7 +51,7 @@ dataset/

# 环境变量
.env
backend/.env
apps/backend/.env
*.pem
PR.md
TODO.md
Expand Down
36 changes: 18 additions & 18 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# AGENTS

本文件用于说明项目规则目录 `rules/` 的结构,方便在开始开发或修改代码前快速定位需要查看的规范。
本文件用于说明项目规则目录 `docs/rules/` 的结构,方便在开始开发或修改代码前快速定位需要查看的规范。

## 规则目录

### `rules/development`
### `docs/rules/development`

- `development/架构规则.md`:项目架构、核心入口和本地文档使用原则。
- `development/前端规则.md`:Vue、API 调用、主题、组件和设计规则。
- `development/后端规则.md`:模块副作用、数据库、线程安全、Agent、OCR 和文件路径规则。
- `development/测试规则.md`:测试组织、断言原则和外部依赖保护。
- `development/代码注释规则.md`:注释意图、前端注释位置和推荐写法。
- `docs/rules/development/架构规则.md`:项目架构、核心入口和本地文档使用原则。
- `docs/rules/development/前端规则.md`:Vue、API 调用、主题、组件和设计规则。
- `docs/rules/development/后端规则.md`:模块副作用、数据库、线程安全、Agent、OCR 和文件路径规则。
- `docs/rules/development/测试规则.md`:测试组织、断言原则和外部依赖保护。
- `docs/rules/development/代码注释规则.md`:注释意图、前端注释位置和推荐写法。

### `rules/workflow`
### `docs/rules/workflow`

- `workflow/提交规则.md`:commit message 格式和强制 checklist 要求。
- `workflow/常用命令索引.md`:本地命令类规则入口。
- `workflow/环境配置规则.md`:依赖安装、环境变量和 Provider 配置。
- `workflow/开发启动规则.md`:前后端开发服务、conda 环境和端口检查。
- `workflow/测试构建规则.md`:后端测试、前端测试和生产构建。
- `workflow/变更同步规则.md`:跨后端、前端、文档、配置和测试的同步要求。
- `workflow/协作提交流程规则.md`:fork、个人分支、PR 和 review 流程要求。
- `docs/rules/workflow/提交规则.md`:commit message 格式和强制 checklist 要求。
- `docs/rules/workflow/常用命令索引.md`:本地命令类规则入口。
- `docs/rules/workflow/环境配置规则.md`:依赖安装、环境变量和 Provider 配置。
- `docs/rules/workflow/开发启动规则.md`:前后端开发服务、conda 环境和端口检查。
- `docs/rules/workflow/测试构建规则.md`:后端测试、前端测试和生产构建。
- `docs/rules/workflow/变更同步规则.md`:跨后端、前端、文档、配置和测试的同步要求。
- `docs/rules/workflow/协作提交流程规则.md`:fork、个人分支、PR 和 review 流程要求。

## 使用建议

- 开始任务前,先查看本文件。
- 涉及前端改动时,优先查看 `development/前端规则.md`。
- 涉及后端改动时,优先查看 `development/后端规则.md`。
- 涉及测试、构建、提交流程时,查看 `development/测试规则.md` 和 `workflow/` 下对应文件。
- 涉及前端改动时,优先查看 `docs/rules/development/前端规则.md`。
- 涉及后端改动时,优先查看 `docs/rules/development/后端规则.md`。
- 涉及测试、构建、提交流程时,查看 `docs/rules/development/测试规则.md` 和 `docs/rules/workflow/` 下对应文件。
- 修改规则时,优先更新对应规则文件,而不是只改本文件。
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PYTHONPATH=/app/backend
PYTHONPATH=/app/apps/backend

WORKDIR /app

Expand All @@ -28,15 +28,15 @@ RUN sed \
--index-url "${TORCH_INDEX_URL}" \
&& rm -f /tmp/requirements-runtime.txt

COPY backend ./backend
COPY apps/backend ./apps/backend

RUN groupadd --gid 10001 app \
&& useradd --uid 10001 --gid app --no-create-home --shell /usr/sbin/nologin app \
&& mkdir -p /app/runtime_data \
&& chown -R app:app /app

USER app
WORKDIR /app/backend
WORKDIR /app/apps/backend

EXPOSE 8000

Expand Down
Loading
Loading