# NP Replica This project provides a local Chinese web replica of the core NUPACK `analysis/input` workflow. ## Run ```bash docker compose up --build -d ``` Open `http://127.0.0.1:18765`. ## Reverse Proxy The service listens on port `18765`. The current local deployment is reverse proxied as `npt.lihato.icu`. Traefik only performs TLS termination, compression, and reverse proxying for `npt`; authentication is enforced by this application. ## Endpoints - `GET /` - `GET /health` - `GET /api/example` - `POST /api/analyze` - `POST /api/jobs` - `GET /api/jobs/` ## Persistent Shares Live jobs and sessions are stored in Redis when `NP_REDIS_URL` is enabled. Account history and share links are stored in `./runtime/account/np-replica.sqlite3`; back up both runtime directories when moving the deployment. ## Notes - `tube` mode supports strand concentrations and `SetSpec(max_size=...)`. - `complex` mode supports explicit complex definitions such as `A+B`. - Pair matrices are returned as a preview block to keep responses manageable. - The Docker image compiles ViennaRNA `RNAplot` from `rna/ViennaRNA-2.7.2.tar.gz` and embeds SVG structure plots into MFE results. - Multistrand MFE plots now use a split-strand layout by default when a structure contains `+`, with `RNAplot` retained as the fallback path. - The web UI supports Chinese and English switching, account-scoped cloud history, result export, share controls, and async polling for submitted jobs. - Docker now starts three services: `np-replica`, `np-worker`, and `redis`. - Async jobs use Redis-backed storage and queueing when `NP_REDIS_URL` is configured; otherwise the app falls back to the older in-memory mode. - The browser-facing API and page behavior stay the same after enabling Redis-backed jobs. - Worker concurrency is controlled by `NP_WORKER_CONCURRENCY` and defaults to `2`. - Per-job native thread usage is capped by `NP_PER_JOB_THREAD_LIMIT` and defaults to `1` to prevent a single analysis from monopolizing the machine. - `NP_STRUCTURE_PLOT_MODE` supports `auto` (default), `split`, and `rnaplot`. - Static pages are served with ETag-based browser caching; JSON API responses remain uncached. - The force-directed structure viewer lazy-loads D3 only when that view is opened, so the initial page load is not blocked by the external CDN. - `/health` uses Redis queue length plus a running-job set instead of scanning every historical job on each poll. - Application login uses the public Authentik issuer at `https://auth.lihato.icu/` with Authorization Code + PKCE. - The current `npt` instance uses issuer `/application/o/nupack-account-npt/`, client `npt-replica-web`, callback `https://npt.lihato.icu/auth/callback`, and logout return `https://npt.lihato.icu/`. - For the independent `np` deployment on `100.64.0.11`, set `NP_OIDC_ISSUER=https://auth.lihato.icu/application/o/nupack-account/`, `NP_OIDC_CLIENT_ID=np-replica-web`, `NP_OIDC_REDIRECT_URI=https://np.lihato.icu/auth/callback`, and `NP_OIDC_POST_LOGOUT_URI=https://np.lihato.icu/`. - Redis stores the live queue and login sessions. SQLite WAL at `/data/np-replica.sqlite3` stores users, owned jobs, compressed inputs/results/errors, usage totals, and durable share links. - History and job APIs enforce ownership by the Authentik OIDC subject. Public share links expose only the selected record and can be disabled or given an expiry by its owner. 现在 `docker-compose.yml` 面向 64 核 / 64G WSL 服务器的并发策略是: - 最多同时跑 16 个任务 - 每个任务最多用 4 个计算线程 - 后续任务进入队列等待 - 每个任务的 NUPACK 缓存上限为 8 GB - 理论上最多占用约 64 个 native 计算线程 如果后面你发现机器还会被压满,最直接的调法就是在 docker-compose.yml 里继续压: - 把 NP_WORKER_CONCURRENCY 改小 - 或保持并发不变,把 NP_PER_JOB_THREAD_LIMIT 改成 2 或 1