83 lines
4.2 KiB
Markdown
83 lines
4.2 KiB
Markdown
# Local And Server Integration Plan
|
|
> **For agent:** REQUIRED SUB-SKILL: Use Section 4 or Section 5 to implement this plan.
|
|
**Goal:** Prepare `D:\Document Cleaning` for local and server integration, then execute real smoke tests for upload, conversion, download, deletion, and Dify sync where credentials allow.
|
|
**Architecture:** Keep the existing Docker deployment path for server use, but add a direct local execution path that does not depend on Docker, Redis, or PostgreSQL being installed on the developer workstation. Real conversion should run through the existing `edkb_system` and LibreOffice chain. Dify sync should use the existing production service when a real API key is present.
|
|
**Tech Stack:** FastAPI, SQLAlchemy, Alembic, RQ, Redis, PostgreSQL, SQLite, Vue/Vite, LibreOffice
|
|
|
|
## Current Environment Findings
|
|
|
|
- `docker` and `docker compose` are not installed or not on PATH in the current Windows environment.
|
|
- LibreOffice is installed locally at `C:\Program Files\LibreOffice\program\soffice.exe`.
|
|
- Python and Node are installed locally.
|
|
- Root `.env` is missing.
|
|
- `DIFY_API_KEY` is currently empty in `.env.example`, `backend.env.example`, and the current process/user/machine environment.
|
|
|
|
## Execution Strategy
|
|
|
|
### Track 1: Server Path
|
|
**Files:**
|
|
- Modify as needed: `docker-compose.yml`
|
|
- Modify as needed: `.env.example`
|
|
- Modify as needed: `backend/backend.env.example`
|
|
**Steps:**
|
|
1. Normalize environment variable handling so `PUBLIC_BASE_URL` and the Dify settings are driven by `.env`.
|
|
2. Create a real root `.env` file for the current machine.
|
|
3. Verify the compose configuration is ready for the target server once Docker is available.
|
|
|
|
### Track 2: Local Path
|
|
**Files:**
|
|
- Modify as needed: `backend/app/config.py`
|
|
- Modify as needed: `backend/app/services/queue_service.py`
|
|
- Modify as needed: `backend/worker.py`
|
|
- Modify as needed: `.env.example`
|
|
- Modify as needed: `backend/backend.env.example`
|
|
**Steps:**
|
|
1. Add a local task execution mode that can run queue tasks inline without Redis.
|
|
2. Keep the existing RQ mode unchanged for server deployment.
|
|
3. Configure the current workstation to use SQLite plus inline execution for local smoke tests.
|
|
|
|
### Task 1: Prepare integration configuration
|
|
**Files:**
|
|
- Modify: `docker-compose.yml`
|
|
- Modify: `.env.example`
|
|
- Modify: `backend/backend.env.example`
|
|
- Create: `.env`
|
|
**Step 1:** Add all required variables for local and server paths, including `PUBLIC_BASE_URL` and a task execution mode switch.
|
|
**Step 2:** Keep production defaults intact where possible.
|
|
**Step 3:** Verify the resulting configuration files are internally consistent.
|
|
|
|
### Task 2: Add local inline task execution mode
|
|
**Files:**
|
|
- Modify: `backend/app/config.py`
|
|
- Modify: `backend/app/services/queue_service.py`
|
|
- Modify as needed: `backend/tests/*`
|
|
**Step 1:** Add a configuration switch that chooses between `rq` and `sync`.
|
|
**Step 2:** In `sync` mode, execute `app.tasks.run_convert_job` and `app.tasks.run_sync_job` inline while preserving persisted job state.
|
|
**Step 3:** Verify the existing backend tests still pass after the change.
|
|
|
|
### Task 3: Start the local integration stack
|
|
**Files:**
|
|
- Read: `frontend/vite.config.ts`
|
|
- Read: `backend/alembic.ini`
|
|
- Read: `backend/migrations/env.py`
|
|
**Step 1:** Run Alembic against the local database.
|
|
**Step 2:** Start the backend locally.
|
|
**Step 3:** Start the frontend locally if needed for manual browser access.
|
|
**Step 4:** Confirm health and login endpoints respond over HTTP.
|
|
|
|
### Task 4: Run real smoke tests
|
|
**Files:**
|
|
- Read: `backend/data/original/**/*`
|
|
- Use runtime data under `backend/data/`
|
|
**Step 1:** Create a real group and upload a real document through the running API.
|
|
**Step 2:** Verify conversion completes using the existing document cleaning pipeline and LibreOffice path.
|
|
**Step 3:** Verify original download, markdown download, and local delete.
|
|
**Step 4:** Attempt real Dify sync if a valid key is available; otherwise capture the exact blocker and the furthest successful precondition.
|
|
|
|
### Task 5: Report integration status
|
|
**Files:**
|
|
- Read: generated runtime output and logs
|
|
**Step 1:** Record what was prepared for server deployment.
|
|
**Step 2:** Record what was proven locally with real runtime execution.
|
|
**Step 3:** Record any remaining blockers, especially around Docker and Dify credentials.
|