# ntgmc/goofish-infrast-public architecture

> Architecture diagram of the GitHub repository ntgmc/goofish-infrast-public, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ntgmc/goofish-infrast-public
- Repository: https://github.com/ntgmc/goofish-infrast-public

## Overview

This is a web application for Arknights players to configure and manage MAA base schedules, submit optimization jobs, and review results. The main flow runs from the React optimization workflow through the API into a durable PostgreSQL queue; a compatible external OptimizerPort worker performs the computation and results return through job-query APIs. The product also includes accounts and workspaces, billing and inventory, administration, public content, integrations, and service-status monitoring. Paths and wiring reflect the tree, README, and sampled excerpts; unsampled subsystem links are limited to explicitly documented behavior.

Main entry points: [`server/routes.ts`](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/routes.ts) (HTTP route dispatch), [`src/lib/api-client.ts`](https://github.com/ntgmc/goofish-infrast-public/blob/main/src/lib/api-client.ts) (API client), [`src/App.tsx`](https://github.com/ntgmc/goofish-infrast-public/blob/main/src/App.tsx) (React application), [`server/optimization/jobs/service.ts`](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/optimization/jobs/service.ts) (Job lifecycle service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webapp["React application<br/>[App.tsx]"]
  node_workflow["Optimization workflow"]
  node_session["Account workspace<br/>[useToolSession.ts]"]
  node_results["Schedule results<br/>[ResultPanel.tsx]"]
  node_api_client["API client<br/>[api-client.ts]"]
end

subgraph group_api["API and accounts"]
  node_routes["HTTP route dispatch<br/>[routes.ts]"]
  node_optimization_handler["Optimization API<br/>[optimization.ts]"]
  node_account_handlers["Account handlers<br/>[user-workspace.ts]"]
  node_admin_handlers["Admin API handlers<br/>[admin-users.ts]"]
  node_skland_binding["Skland binding API<br/>[skland-client.ts]"]
  node_public_content["Public content and events"]
end

subgraph group_jobs["Optimization jobs"]
  node_job_service["Job lifecycle service<br/>[service.ts]"]
  node_job_runner["Worker runtime"]
  node_optimizer_dispatch["Optimizer dispatcher"]
end

subgraph group_state["Persistent state"]
  node_postgres[("PostgreSQL<br/>[postgres.ts]")]
  node_job_store[("Job queue and results")]
  node_account_store[("Account and workspace stores<br/>[user-store.ts]")]
end

subgraph group_operations["Operations and integrations"]
  node_admin["Administration"]
  node_email["Transactional email<br/>[ses-email.ts]"]
  node_status["Service status<br/>[service-status.ts]"]
  node_autoscaler["ECS worker autoscaling"]
end

node_player(("Arknights player"))
node_optimizer_port["OptimizerPort implementation"]
node_skland["Skland service"]
node_email_providers["Brevo and Amazon SES"]
node_aliyun["Aliyun ECS"]

node_player -->|"uses"| node_webapp
node_webapp -->|"presents"| node_workflow
node_webapp -->|"manages session"| node_session
node_workflow -->|"submits and queries"| node_api_client
node_session -->|"loads and saves"| node_api_client
node_api_client -->|"HTTP requests"| node_routes
node_routes -->|"dispatches optimization"| node_optimization_handler
node_routes -->|"dispatches account"| node_account_handlers
node_optimization_handler -->|"submits and manages"| node_job_service
node_job_service -->|"queues and reads jobs"| node_job_store
node_job_store -->|"persists jobs"| node_postgres
node_job_runner -->|"claims and updates"| node_job_store
node_job_runner -->|"dispatches execution"| node_optimizer_dispatch
node_optimizer_dispatch -->|"invokes"| node_optimizer_port
node_optimizer_port -->|"returns computation"| node_job_runner
node_job_service -->|"serves job state"| node_api_client
node_api_client -->|"delivers results"| node_results
node_account_handlers -->|"reads and writes"| node_account_store
node_account_store -->|"persists accounts"| node_postgres
node_admin -->|"admin requests"| node_api_client
node_routes -->|"dispatches admin"| node_admin_handlers
node_admin_handlers -->|"accesses stored data"| node_postgres
node_skland_binding -.->|"fetches account data"| node_skland
node_email -.->|"sends transactional mail"| node_email_providers
node_routes -->|"dispatches content"| node_public_content
node_routes -->|"dispatches status"| node_status
node_autoscaler -.->|"starts and stops workers"| node_aliyun

click node_webapp "https://github.com/ntgmc/goofish-infrast-public/blob/main/src/App.tsx"
click node_workflow "https://github.com/ntgmc/goofish-infrast-public/blob/main/src/pages/tool/optimize/useOptimizeWorkflow.tsx"
click node_session "https://github.com/ntgmc/goofish-infrast-public/blob/main/src/pages/tool/useToolSession.ts"
click node_results "https://github.com/ntgmc/goofish-infrast-public/blob/main/src/components/result-panel/ResultPanel.tsx"
click node_api_client "https://github.com/ntgmc/goofish-infrast-public/blob/main/src/lib/api-client.ts"
click node_routes "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/routes.ts"
click node_optimization_handler "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/handlers/optimization.ts"
click node_account_handlers "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/handlers/user-workspace.ts"
click node_job_service "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/optimization/jobs/service.ts"
click node_job_runner "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/optimize-worker-runtime.ts"
click node_optimizer_dispatch "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/optimization/jobs/optimizer-dispatcher.ts"
click node_postgres "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/storage/postgres.ts"
click node_job_store "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/storage/optimize-job-store.ts"
click node_account_store "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/storage/user-store.ts"
click node_admin "https://github.com/ntgmc/goofish-infrast-public/blob/main/src/pages/admin/useAdminController.tsx"
click node_admin_handlers "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/handlers/admin-users.ts"
click node_skland_binding "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/handlers/skland-client.ts"
click node_email "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/ses-email.ts"
click node_public_content "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/handlers/site-public-content.ts"
click node_status "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/handlers/service-status.ts"
click node_autoscaler "https://github.com/ntgmc/goofish-infrast-public/blob/main/server/aliyun-ecs-worker-controller.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp,node_workflow,node_session,node_results,node_api_client toneBlue
class node_routes,node_optimization_handler,node_account_handlers,node_admin_handlers,node_skland_binding,node_public_content toneAmber
class node_job_service,node_job_runner,node_optimizer_dispatch toneMint
class node_postgres,node_job_store,node_account_store toneRose
class node_admin,node_email,node_status,node_autoscaler,node_player,node_optimizer_port,node_skland,node_email_providers,node_aliyun toneIndigo
```

## Components

### Web application

- [React application](https://github.com/ntgmc/goofish-infrast-public/blob/main/src/App.tsx): `src/App.tsx`
- [Optimization workflow](https://github.com/ntgmc/goofish-infrast-public/blob/main/src/pages/tool/optimize/useOptimizeWorkflow.tsx): `src/pages/tool/optimize/useOptimizeWorkflow.tsx`
- [Account workspace](https://github.com/ntgmc/goofish-infrast-public/blob/main/src/pages/tool/useToolSession.ts): `src/pages/tool/useToolSession.ts`
- [Schedule results](https://github.com/ntgmc/goofish-infrast-public/blob/main/src/components/result-panel/ResultPanel.tsx): `src/components/result-panel/ResultPanel.tsx`
- [API client](https://github.com/ntgmc/goofish-infrast-public/blob/main/src/lib/api-client.ts): `src/lib/api-client.ts`

### API and accounts

- [HTTP route dispatch](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/routes.ts): `server/routes.ts`
- [Optimization API](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/handlers/optimization.ts): `server/handlers/optimization.ts`
- [Account handlers](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/handlers/user-workspace.ts): `server/handlers/user-workspace.ts`
- [Admin API handlers](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/handlers/admin-users.ts): `server/handlers/admin-users.ts`
- [Skland binding API](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/handlers/skland-client.ts): `server/handlers/skland-client.ts`
- [Public content and events](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/handlers/site-public-content.ts): `server/handlers/site-public-content.ts`

### Optimization jobs

- [Job lifecycle service](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/optimization/jobs/service.ts): `server/optimization/jobs/service.ts`
- [Worker runtime](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/optimize-worker-runtime.ts): `server/optimize-worker-runtime.ts`
- [Optimizer dispatcher](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/optimization/jobs/optimizer-dispatcher.ts): `server/optimization/jobs/optimizer-dispatcher.ts`

### Persistent state

- [PostgreSQL](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/storage/postgres.ts): `server/storage/postgres.ts`
- [Job queue and results](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/storage/optimize-job-store.ts): `server/storage/optimize-job-store.ts`
- [Account and workspace stores](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/storage/user-store.ts): `server/storage/user-store.ts`

### Operations and integrations

- [Administration](https://github.com/ntgmc/goofish-infrast-public/blob/main/src/pages/admin/useAdminController.tsx): `src/pages/admin/useAdminController.tsx`
- [Transactional email](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/ses-email.ts): `server/ses-email.ts`
- [Service status](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/handlers/service-status.ts): `server/handlers/service-status.ts`
- [ECS worker autoscaling](https://github.com/ntgmc/goofish-infrast-public/blob/main/server/aliyun-ecs-worker-controller.ts): `server/aliyun-ecs-worker-controller.ts`

### Other components

- **Arknights player**
- **OptimizerPort implementation**
- **Skland service**
- **Brevo and Amazon SES**
- **Aliyun ECS**

## Connections

- Arknights player → React application: uses
- React application → Optimization workflow: presents
- React application → Account workspace: manages session
- Optimization workflow → API client: submits and queries
- Account workspace → API client: loads and saves
- API client → HTTP route dispatch: HTTP requests
- HTTP route dispatch → Optimization API: dispatches optimization
- HTTP route dispatch → Account handlers: dispatches account
- Optimization API → Job lifecycle service: submits and manages
- Job lifecycle service → Job queue and results: queues and reads jobs
- Job queue and results → PostgreSQL: persists jobs
- Worker runtime → Job queue and results: claims and updates
- Worker runtime → Optimizer dispatcher: dispatches execution
- Optimizer dispatcher → OptimizerPort implementation: invokes
- OptimizerPort implementation → Worker runtime: returns computation
- Job lifecycle service → API client: serves job state
- API client → Schedule results: delivers results
- Account handlers → Account and workspace stores: reads and writes
- Account and workspace stores → PostgreSQL: persists accounts
- Administration → API client: admin requests
- HTTP route dispatch → Admin API handlers: dispatches admin
- Admin API handlers → PostgreSQL: accesses stored data
- Skland binding API → Skland service: fetches account data
- Transactional email → Brevo and Amazon SES: sends transactional mail
- HTTP route dispatch → Public content and events: dispatches content
- HTTP route dispatch → Service status: dispatches status
- ECS worker autoscaling → Aliyun ECS: starts and stops workers
