Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ interactive terminal UI.
to hold the directional bet) while every strategy algorithm stays identical.
- **In-process NestJS GraphQL backend**: the interactive CLI starts a local
GraphQL endpoint without a second service process.
- **Repository-mediated GraphQL layer**: the API surface lives entirely in the
backend. Both ends of the `cli → graphql → backend` path own a repository — the
backend `TradefastRepository` (`src/backend/graphql/`) maps the application
facade onto GraphQL DTOs, and the frontend `GraphqlTradefastRepository`
(`src/cli/graphql/`) is the only place the CLI talks to the API. Each GraphQL
class lives in its own file on both sides. The headless `status`, `strategies`
and `clear` commands make their requests through this path.
- **Dockerised**: `docker compose up` brings up PostgreSQL and the CLI.

---
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Tradefast",
"version": "0.5.0",
"version": "0.6.0",
"description": "TRADEFΛST — a disciplined crypto market-research CLI: strategies, analytics, risk and AI-assisted research, in the style of Gemini CLI.",
"type": "module",
"license": "MIT",
Expand Down
185 changes: 0 additions & 185 deletions src/backend/graphql.ts

This file was deleted.

32 changes: 32 additions & 0 deletions src/backend/graphql/dto/analytics.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Field, Float, Int, ObjectType } from '@nestjs/graphql';

/** Per-symbol consensus analytics for the latest run. */
@ObjectType()
export class AnalyticsDto {
@Field(() => String)
symbol!: string;

@Field(() => Float)
consensusScore!: number;

@Field(() => Int)
longCount!: number;

@Field(() => Int)
shortCount!: number;

@Field(() => Int)
neutralCount!: number;

@Field(() => String, { nullable: true })
strongestStrategy!: string | null;

@Field(() => Float, { nullable: true })
strongestStrength!: number | null;

@Field(() => Float, { nullable: true })
lastPrice!: number | null;

@Field(() => Float, { nullable: true })
atr!: number | null;
}
22 changes: 22 additions & 0 deletions src/backend/graphql/dto/run-report.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Field, Int, ObjectType } from '@nestjs/graphql';

import { SymbolRunDto } from './symbol-run.dto.js';

/** The outcome of a `/start` or `/update` collection run. */
@ObjectType()
export class RunReportDto {
@Field(() => Int)
runId!: number;

@Field(() => String)
kind!: string;

@Field(() => [SymbolRunDto])
symbols!: SymbolRunDto[];

@Field(() => Int)
searchResults!: number;

@Field(() => Int)
durationMs!: number;
}
20 changes: 20 additions & 0 deletions src/backend/graphql/dto/status.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Field, Int, ObjectType } from '@nestjs/graphql';

import { AnalyticsDto } from './analytics.dto.js';
import { TableCountDto } from './table-count.dto.js';

/** A snapshot of the backend's database and the latest run's analytics. */
@ObjectType()
export class StatusDto {
@Field(() => String)
driver!: string;

@Field(() => [TableCountDto])
counts!: TableCountDto[];

@Field(() => Int, { nullable: true })
latestRunId!: number | null;

@Field(() => [AnalyticsDto])
latestAnalytics!: AnalyticsDto[];
}
11 changes: 11 additions & 0 deletions src/backend/graphql/dto/strategy.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Field, ObjectType } from '@nestjs/graphql';

/** A registered trading strategy, exposed for discovery by clients. */
@ObjectType()
export class StrategyDto {
@Field(() => String)
id!: string;

@Field(() => String)
title!: string;
}
26 changes: 26 additions & 0 deletions src/backend/graphql/dto/symbol-run.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Field, Int, ObjectType } from '@nestjs/graphql';

/** What a single symbol contributed to a collection run. */
@ObjectType()
export class SymbolRunDto {
@Field(() => String)
symbol!: string;

@Field(() => Int)
candlesAdded!: number;

@Field(() => Int)
signalsInserted!: number;

@Field(() => Int)
signalsUpdated!: number;

@Field(() => Int)
signalsUnchanged!: number;

@Field(() => Int)
scrapesAdded!: number;

@Field(() => String)
insight!: string;
}
11 changes: 11 additions & 0 deletions src/backend/graphql/dto/table-count.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Field, Int, ObjectType } from '@nestjs/graphql';

/** A single database table together with its current row count. */
@ObjectType()
export class TableCountDto {
@Field(() => String)
name!: string;

@Field(() => Int)
count!: number;
}
19 changes: 19 additions & 0 deletions src/backend/graphql/facade.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { StatusReport } from '../../app/tradefast.js';
import type { RunReport } from '../../pipeline/collector.js';

/** DI token under which the application facade is provided to the resolver. */
export const TRADEFAST_FACADE = Symbol('TRADEFAST_FACADE');

/**
* The slice of the {@link Tradefast} application the GraphQL backend depends on.
* Keeping it an interface lets tests provide a lightweight stand-in and keeps the
* backend decoupled from the full application class.
*/
export interface TradefastApiFacade {
readonly driver: string;
status(): Promise<StatusReport>;
strategies(): { id: string; title: string }[];
start(): Promise<RunReport>;
update(): Promise<RunReport>;
clear(): Promise<number>;
}
10 changes: 10 additions & 0 deletions src/backend/graphql/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** Barrel for the backend GraphQL layer: facade, DTOs, repository and resolver. */
export { TRADEFAST_FACADE, type TradefastApiFacade } from './facade.js';
export { AnalyticsDto } from './dto/analytics.dto.js';
export { RunReportDto } from './dto/run-report.dto.js';
export { StatusDto } from './dto/status.dto.js';
export { StrategyDto } from './dto/strategy.dto.js';
export { SymbolRunDto } from './dto/symbol-run.dto.js';
export { TableCountDto } from './dto/table-count.dto.js';
export { TradefastRepository, toRunDto } from './repository.js';
export { TradefastResolver } from './tradefast.resolver.js';
Loading
Loading