App Icon Coach GPT App

System Architecture — Current vs Future

This document describes the current operational pipeline for the Coach GPT App, identifies key architectural issues, and outlines the next-generation Render Container Architecture for stable, scalable computation.

Current Architecture

                 ┌───────────────────────────────┐
                 │          User / Coach          │
                 │ (Prompt commands via ChatGPT)  │
                 └───────────────┬───────────────┘
                                 │
                                 ▼
        ┌─────────────────────────────────────────────┐
        │               ChatGPT App                   │
        │ (LLM reasoning + tool orchestration)        │
        └───────────────┬─────────────────────────────┘
                        │ HTTPS tool call
                        ▼
        ┌─────────────────────────────────────────────┐
        │          Cloudflare Worker Proxy            │
        │ - Auth proxy between ChatGPT & APIs         │
        │ - Serially concatenates GitHub + ICU calls  │
        └───────────────┬─────────────────────────────┘
                        │
           ┌────────────┴────────────┐
           ▼                         ▼
┌────────────────────┐     ┌──────────────────────────┐
│   GitHub Repo      │     │   Intervals.icu API      │
│ (Rules & schemas)  │     │ (Athlete, wellness data) │
└────────────────────┘     └──────────────────────────┘

Current System Limitations

IssueDescriptionImpact
API ConcatenationCloudflare combines multiple GET responses into one payload.Causes oversized responses and JSON corruption.
Data Serialization DriftBase64 + JSON double encoding across endpoints.Loss of numeric precision and audit variance > 2%.
Stateless ExecutionNo caching or Tier-level memory between requests.Duplicate ICU fetches and wasted API quota.
Proxy OverloadAll routing, merging, and logic done in Cloudflare.Brittle and unmaintainable; single point of failure.
Virtual LangChainChatGPT simulates code instead of executing real Python.Inconsistent numeric results, non-deterministic audits.
Schema CouplingNo handshake between GPT schema and GitHub version.Field renames silently break audits.
Lack of ObservabilityNo logs or telemetry from Cloudflare or ChatGPT tools.Impossible to debug intermittent failures.

Future Architecture (Render Container Model)

        ┌──────────────────────────┐
        │        ChatGPT App       │
        │ (User interface + logic) │
        └────────────┬─────────────┘
                     │ HTTPS (Tool call)
                     ▼
        ┌──────────────────────────┐
        │    Render Container      │
        │  (FastAPI + LangServe)   │
        │    ┌────────────────┐    │
        │    │  LangChain     │    │
        │    │  + your repo   │    │
        │    └────────────────┘    │
        │ Executes Python code     │
        └────────────┬─────────────┘
                     │
                     ▼
        ┌──────────────────────────┐
        │     Intervals.icu API    │
        │ (External Data Provider) │
        └──────────────────────────┘

Pipeline Improvements

Current WeaknessFuture Mitigation
Concatenated API callsFastAPI handles separate endpoints with structured responses.
Serialization driftTyped Pydantic models guarantee consistent datatypes.
Stateless pipelineLangChain memory cache retains Tier-level context.
Proxy overloadSplit routing logic; Cloudflare becomes static edge, not processor.
Virtual mathTrue Python execution in container ensures numeric accuracy.
Schema mismatchVersion negotiation headers (v16.17+) between GPT and backend.
No observabilityFastAPI logs + Prometheus metrics for traceable reports.