Skip to content

Transferring API requests to the backend#32

Merged
Payel-git-ol merged 6 commits into
Payel-git-ol:masterfrom
konard:issue-31-dcb7bc9e4398
May 31, 2026
Merged

Transferring API requests to the backend#32
Payel-git-ol merged 6 commits into
Payel-git-ol:masterfrom
konard:issue-31-dcb7bc9e4398

Conversation

@konard

@konard konard commented May 31, 2026

Copy link
Copy Markdown
Contributor

Transferring API requests to the backend (#31)

Moves the entire API surface to the backend and routes the CLI through it along the
cli → GraphQL → backend → api path. Both ends own a repository, and every
GraphQL class lives in its own file in a graphql/ folder on each side. The
monolithic App.tsx and the flat src/cli/ layout are broken into folders.

Backend — src/backend/graphql/

  • facade.tsTRADEFAST_FACADE token + TradefastApiFacade interface (the only
    contract the backend depends on; keeps backend files minimalist).
  • dto/ — one @ObjectType per file: table-count, strategy, analytics,
    status, symbol-run, run-report.
  • repository.ts@Injectable() TradefastRepository maps the facade onto the
    DTOs (status/strategies/start/update/clear).
  • tradefast.resolver.ts — thin resolver delegating to the repository.
  • index.ts — barrel. src/backend/graphql.ts (185 lines) is deleted.

Frontend — src/cli/graphql/

  • client.ts — minimal GraphqlClient (fetch-based POST, GraphqlRequestError).
  • one file per GraphQL class (table-count, analytics, strategy, status,
    symbol-run, run-report, clear) holding the typed document + result types,
    fully decoupled from the backend Nest decorators.
  • repository.tsGraphqlTradefastRepository: the only place the CLI talks
    to the API.
  • The headless status, strategies and clear commands now make their requests
    through this repository (spinning up the in-process backend).

CLI split into folders — src/cli/components/

  • The seven popup selectors (Theme, Exchange, Interval, Mode, Currency,
    Level, Platform) are extracted from App.tsx into one file each, shrinking
    App.tsx by ~270 lines.

Scope note

start/update and the interactive TUI are intentionally not rerouted through
GraphQL: the GraphQL RunReportDto does not model the analysis/validation/interval
fields the trade-log renderer needs, and the TUI relies on progress streaming and
local config mutation not expressed in the schema. Only the cleanly-mappable
headless commands go through the new path, keeping the backend minimalist.

Implementation note

Nest DI uses explicit @Inject(...) tokens throughout — the esbuild-based bundler
(tsx/tsup) does not emit decorator metadata, so type-only DI fails silently.

Tests

  • tests/graphql-repository.test.ts (new): end-to-end GraphqlTradefastRepository
    → in-process backend assertions for every method, plus GraphqlClient error paths.
  • tests/backend.test.ts: updated to construct the resolver with the repository.
  • Full suite: 131 tests / 15 files passing, typecheck clean, tsup build green.

Fixes #31

@konard konard changed the title [WIP] Transferring API requests to the backend Transferring API requests to the backend May 31, 2026
@konard konard marked this pull request as ready for review May 31, 2026 07:41
@konard

konard commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

Working session summary

Done. PR #32 is finalized and ready for review.

Summary

Issue #31 ("Transferring API requests to the backend") is fully addressed on branch issue-31-dcb7bc9e4398, in PR #32: #32

What was delivered (every issue requirement met):

  1. API moved to the backend, routed along cli → GraphQL → backend → api.
  2. Backend graphql/ folder, one class per filefacade.ts, six DTOs under dto/ (one @ObjectType each), repository.ts (TradefastRepository), tradefast.resolver.ts, barrel. The old 185-line graphql.ts is deleted; backend kept minimalist.
  3. Frontend src/cli/graphql/ folder, one class per fileclient.ts, typed document files (status, strategy, analytics, table-count, symbol-run, run-report, clear), barrel.
  4. A repository on each side, requests go through it — backend TradefastRepository (facade→DTO) and frontend GraphqlTradefastRepository (the sole API entry point). Headless status/strategies/clear now flow through it.
  5. CLI split into folders — the seven popup selectors extracted from App.tsx into src/cli/components/, one file each (~270 lines removed from App.tsx).

Verification:

  • 131 tests / 15 files passing (incl. new tests/graphql-repository.test.ts end-to-end + error-path coverage)
  • typecheck clean, tsup build green
  • CI green on the final commit 19f5b6a (conclusion: success)
  • Version bumped 0.5.0 → 0.6.0, README documents the new layer
  • PR title/description updated, marked ready for review

One deliberate scoping note (documented in the PR): start/update and the interactive TUI stay on the direct path because the GraphQL RunReportDto doesn't model the analysis/validation fields the trade-log renderer needs and the TUI relies on progress streaming — keeping the backend minimalist as the issue asked.


This summary was automatically extracted from the AI working session output.

@konard

konard commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $5.110814

📊 Context and tokens usage:

Claude Opus 4.8: (2 sub-sessions)

  1. 116.7K / 1M (12%) input tokens, 41.8K / 128K (33%) output tokens
  2. 37.1K / 1M (4%) input tokens, 4.1K / 128K (3%) output tokens

Total: (6.7K new + 168.6K cache writes + 5.4M cache reads) input tokens, 52.1K output tokens, $5.110814 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Model: Claude Opus 4.8 (claude-opus-4-8)

📎 Log file uploaded as Gist (2348KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@Payel-git-ol Payel-git-ol merged commit e366a5b into Payel-git-ol:master May 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transferring API requests to the backend

2 participants