|
| 1 | +# Server Refactor v1 - Upgrade Guide |
| 2 | + |
| 3 | +> Applies to: v0.0.89+ |
| 4 | +> PR: #1509 |
| 5 | +
|
| 6 | +## What Changed |
| 7 | + |
| 8 | +The server codebase has been restructured from a flat layout to a **domain-driven architecture**. No API endpoints or database schemas were changed — this is a code organization refactor only. |
| 9 | + |
| 10 | +### Directory Mapping |
| 11 | + |
| 12 | +| Before | After | Description | |
| 13 | +|---|---|---| |
| 14 | +| `app/component/` | `app/core/` | Infrastructure utilities (database, encryption, celery, etc.) | |
| 15 | +| `app/controller/` | `app/domains/*/api/` | API controllers, grouped by domain | |
| 16 | +| `app/service/` | `app/domains/*/service/` | Business logic, grouped by domain | |
| 17 | +| `app/exception/` | `app/shared/exception/` | Exception handling | |
| 18 | +| `app/type/` | `app/shared/types/` | Shared type definitions | |
| 19 | +| _(new)_ | `app/shared/auth/` | Authentication & authorization | |
| 20 | +| _(new)_ | `app/shared/middleware/` | CORS, rate limiting, trace ID | |
| 21 | +| _(new)_ | `app/shared/http/` | HTTP client utilities | |
| 22 | +| _(new)_ | `app/shared/logging/` | Logging & sensitive data filtering | |
| 23 | + |
| 24 | +### Domain Structure |
| 25 | + |
| 26 | +Each domain (`chat`, `config`, `mcp`, `model_provider`, `oauth`, `trigger`, `user`) follows the same layout: |
| 27 | + |
| 28 | +``` |
| 29 | +app/domains/<domain>/ |
| 30 | + api/ # Controllers (route handlers) |
| 31 | + service/ # Business logic |
| 32 | + schema/ # Request/response schemas |
| 33 | +``` |
| 34 | + |
| 35 | +## Upgrade Action Required |
| 36 | + |
| 37 | +**This is a breaking change for local deployments.** The old server code will fail to start due to changed import paths. |
| 38 | + |
| 39 | +### Docker Users |
| 40 | + |
| 41 | +```bash |
| 42 | +cd server |
| 43 | +docker-compose up --build -d |
| 44 | +``` |
| 45 | + |
| 46 | +You **must** include `--build` to rebuild the image. Running `docker-compose up -d` without `--build` will use the stale old image and fail. |
| 47 | + |
| 48 | +### Non-Docker Users (Local Development) |
| 49 | + |
| 50 | +If you are running the server directly (via `start_server.sh` or `uv run uvicorn`): |
| 51 | + |
| 52 | +1. Stop the running server process |
| 53 | +2. Pull the latest code |
| 54 | +3. Restart the server |
| 55 | + |
| 56 | +```bash |
| 57 | +# If using start_server.sh |
| 58 | +cd server |
| 59 | +./start_server.sh |
| 60 | + |
| 61 | +# If running uvicorn directly |
| 62 | +cd server |
| 63 | +uv run uvicorn main:api --reload --port 3001 --host 0.0.0.0 |
| 64 | +``` |
| 65 | + |
| 66 | +### Electron App Users |
| 67 | + |
| 68 | +If you are running Eigent as a desktop app, simply restart the application. The server will be restarted automatically. |
| 69 | + |
| 70 | +## FAQ |
| 71 | + |
| 72 | +**Q: Will I lose my data?** |
| 73 | +A: No. Database volumes and schemas are not affected. Only the Python source code layout changed. |
| 74 | + |
| 75 | +**Q: Do I need to re-run database migrations?** |
| 76 | +A: No. There are no new migrations in this change. |
| 77 | + |
| 78 | +**Q: I see import errors like `ModuleNotFoundError: No module named 'app.component'`** |
| 79 | +A: This means you are running an old server binary/image. Follow the upgrade steps above. |
0 commit comments