# 记事本 **Repository Path**: sunbaoshun/notepad ## Basic Information - **Project Name**: 记事本 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-31 - **Last Updated**: 2026-05-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Notepad Starter Code This repository includes a starter implementation based on the architecture document: - SwiftUI client core skeleton (`client/`) - SQLite schema (`docs/sql/schema.sql`) - Vapor backend starter API (`server/`) ## Backend Quick Start ```bash cd server swift run ``` Default server: `http://127.0.0.1:8080` - Health: `GET /health` - Create message: `POST /v1/messages` - List messages: `GET /v1/messages?page=1&limit=20&userID=local-user` - Search messages: `GET /v1/messages/search?userID=local-user&keyword=hello&tagIDs=id1,id2` - Create tag: `POST /v1/tags` - List tags: `GET /v1/tags?userID=local-user` - Attach tag to message: `POST /v1/messages/{messageID}/tags` - Detach tag from message: `DELETE /v1/messages/{messageID}/tags/{tagID}?userID=local-user` - Incremental sync: `GET /v1/sync/changes?userID=local-user&sinceToken=0` - **Image upload (local storage, default):** `POST /v1/upload/image` — saves under server `Public/uploads/`, returns `imageURL` on this host ## Notes - **Storage default:** images go to the backend’s local `Public/uploads` via `POST /v1/upload/image`. Client-side data stays in embedded SQLite (`docs/sql/schema.sql`). No OSS configuration is required. - `client/NotepadCore/Data/GRDBMessageRepository.swift` provides SQLite + FTS5 repository implementation. - `client/NotepadCore/Data/SyncEngine.swift` provides pull-based sync orchestration (`sinceToken`). - `client/NotepadCore/Data/RemoteAPIClient.swift` provides remote API client contract and URLSession implementation. - `client/NotepadApp/NotepadApp.swift` currently keeps `InMemoryMessageRepository` as default runtime wiring. - To use GRDB in a package-based setup, start from `client/Package.swift`. - `docs/sql/schema.sql` can be used by both client and server schema alignment. ## Local Test Scripts ```bash ./scripts/test_schema.sh ``` ```bash # run backend first in another terminal cd server && swift run ``` ```bash ./scripts/test_api.sh ``` ## Optional: Alibaba Cloud OSS (later) Use this only when you switch from local uploads to OSS. Until then, ignore this section. Set these environment variables before running backend: ```bash export OSS_BUCKET="your-bucket" export OSS_ENDPOINT="oss-cn-hangzhou.aliyuncs.com" export OSS_ACCESS_KEY_ID="your-ak" export OSS_ACCESS_KEY_SECRET="your-sk" # optional when using STS temporary credentials: export OSS_SECURITY_TOKEN="your-sts-token" # optional public/custom domain: export OSS_PUBLIC_BASE_URL="https://your-bucket.oss-cn-hangzhou.aliyuncs.com" ``` Issue upload policy (only if you enable OSS env vars and need client direct upload): ```bash curl -s -X POST "http://127.0.0.1:8080/v1/upload/oss-policy" \ -H "Content-Type: application/json" \ -d '{"userID":"local-user","fileExtension":"jpg","maxSizeBytes":10485760}' ``` Optional smoke test: `./scripts/test_oss_policy.sh` (requires OSS env + running server). ## Electron MVP (for quick testing) ```bash cd electron npm install npm run dev ``` Rebuild app directory quickly: ```bash cd electron npm run rebuild ```