Skip to content
SAGE Documentation Bot edited this page Jan 5, 2026 · 16 revisions

Sage.ai Documentation

Single Source of Truth for all Sage.ai project documentation

This repository contains all authoritative documentation, specifications, and architecture guidelines for the Sage.ai platform - an AI-powered investment mentor that helps users make smarter financial decisions.


Repository Overview

Sage.ai is organized across 4 independent repositories:

1. sage-docs (THIS REPOSITORY)

2. sage-front

  • Purpose: React web application
  • Repository: https://github.com/5010-dev/sage-front
  • Tech Stack: React 18.3, Vite 5, TypeScript, Zustand, TanStack Query
  • Deployment: AWS Amplify (automatic on push to main)

3. sage-back

  • Purpose: Nest.js API server
  • Repository: https://github.com/5010-dev/sage-back (to be created)
  • Tech Stack: Nest.js 10.x, Prisma 5.x, PostgreSQL 18, Valkey 8.x
  • Deployment: AWS ECS Fargate via GitHub Actions

4. sage-infra

  • Purpose: Infrastructure as Code (Pulumi)
  • Repository: https://github.com/5010-dev/sage-infra (to be created)
  • Tech Stack: Pulumi 3.x (TypeScript)
  • Resources: ECS, RDS, ElastiCache, ALB, Amplify

Documentation Structure

sage-docs/
β”œβ”€β”€ specs/                 # Technical specifications (AUTHORITATIVE)
β”‚   β”œβ”€β”€ backend-spec.md           # Backend API, Agent Pipeline, SSE streaming
β”‚   β”œβ”€β”€ frontend-spec.md          # React components, SSE client, state management
β”‚   └── infrastructure-spec.md    # Pulumi, ECS, RDS, ElastiCache, Amplify
β”‚
β”œβ”€β”€ architecture/          # System architecture
β”‚   └── system-overview.md        # Multi-repo structure, data flow, tech stack
β”‚
β”œβ”€β”€ business/              # Business context (informational, not prescriptive)
β”‚   β”œβ”€β”€ mvp-definition.md         # MVP scope, timeline, success criteria
β”‚   β”œβ”€β”€ business-plan.md          # Market analysis, revenue model
β”‚   β”œβ”€β”€ development-roadmap.md    # Phase 1-4 feature timeline
β”‚   β”œβ”€β”€ executive-brief.md        # Executive summary
β”‚   β”œβ”€β”€ ai-team-strategy.md       # AI team composition
β”‚   β”œβ”€β”€ branding-guide.md         # Brand identity
β”‚   └── sage-overview-kr.md       # Overview (Korean)
β”‚
β”œβ”€β”€ product/               # Product requirements
β”‚   └── product-spec.md           # Features, user journeys, Agent Pipeline
β”‚
β”œβ”€β”€ operations/            # GTM and operations
β”‚   β”œβ”€β”€ operations-roadmap.md     # Operations timeline
β”‚   β”œβ”€β”€ genesis-operations.md     # Launch operations
β”‚   β”œβ”€β”€ live-ops-playbook.md      # Live operations guide
β”‚   β”œβ”€β”€ mystery-campaign.md       # Mystery campaign strategy
β”‚   └── discord-management.md     # Discord community management
β”‚
β”œβ”€β”€ docs/                  # Legacy documentation (to be migrated)
β”‚   β”œβ”€β”€ technical/                # Old specs (use specs/ instead)
β”‚   └── ai-guides/                # Claude Code development guides
β”‚
β”œβ”€β”€ wiki/                  # GitHub Wiki sync (auto-generated, do not edit)
β”‚
β”œβ”€β”€ CLAUDE.md              # AI development constitution
β”œβ”€β”€ README.md              # This file
└── README-kr.md           # Korean version

Quick Start

For Developers

  1. Read the specs first:

  2. Understand the architecture:

  3. Check MVP scope:

For AI Assistants (Claude Code)

  • Read CLAUDE.md first - it's the constitution for AI development
  • Always reference specs/ when implementing features
  • Follow terminology guidelines (Agent Pipeline, not "multi-agent system")
  • Preserve performance targets: <2s first token, <0.5s context load

Tech Stack Summary

Frontend

  • Framework: React 18.3 + Vite 5
  • State: Zustand 4.x (client), TanStack Query 5.x (server)
  • Styling: Tailwind CSS 3.x + shadcn/ui
  • Real-time: SSE (Server-Sent Events) for AI streaming

Backend

  • Framework: Nest.js 10.x
  • Database: PostgreSQL 18 (via Prisma 5.x)
  • Cache: Valkey 8.x (Redis-compatible)
  • AI: Claude Sonnet 4 + Haiku 4 (@anthropic-ai/sdk)
  • Auth: Auth.js with Google OAuth

Infrastructure

  • IaC: Pulumi 3.x (TypeScript)
  • Compute: AWS ECS Fargate
  • Database: AWS RDS PostgreSQL 18
  • Cache: AWS ElastiCache Valkey 8.x
  • CDN: AWS Amplify (frontend), CloudFront
  • LB: AWS ALB

Key Features (MVP)

1. AI Chat with Warren Buffett Persona

  • Agent Pipeline: Manager β†’ Analyst β†’ Persona β†’ Risk
  • Streaming: SSE for token-by-token response (<2s first token)
  • Context: 20-message window (no RAG in MVP)

2. Shadow Portfolio

  • Virtual Trading: No real money, practice-only
  • AI Signals: Extracted from chat conversations
  • Performance: Historical performance tracking

3. Proactive Analysis

  • Market Alerts: BTC -5%, ETH -7% triggers notification
  • Deep Links: Push notification β†’ Auto-open chat with context
  • Multi-channel: PWA push + Discord webhook

Documentation Synchronization

Code repositories contain local copies of relevant specs:

# Frontend repo
sage-front/docs/frontend-spec.md  # Copied from specs/frontend-spec.md

# Backend repo
sage-back/docs/backend-spec.md    # Copied from specs/backend-spec.md

# Infrastructure repo
sage-infra/docs/infrastructure-spec.md  # Copied from specs/infrastructure-spec.md

When updating specs:

  1. Edit in sage-docs/specs/ (Source of Truth)
  2. Copy to relevant code repository
  3. Commit with message: Sync [spec] from sage-docs@[commit-hash]

Example:

# Update frontend spec in sage-docs
cd sage-docs
git commit specs/frontend-spec.md -m "Update SSE reconnection logic"
git push

# Sync to frontend repo
cd ../sage-front
cp ../sage-docs/specs/frontend-spec.md docs/
git commit docs/frontend-spec.md -m "Sync frontend-spec from sage-docs@abc123"
git push

Performance Targets (MUST NOT CHANGE)

These are hard requirements, not suggestions:

Metric Target Measurement
SSE First Token < 2s Time from POST to first SSE token
Context Load < 0.5s Fetch 20 messages from PostgreSQL
API Response < 200ms (P95) REST endpoint latency
Cache Hit Rate > 80% Valkey hit/miss ratio
Hallucination Rate < 1% Risk Agent rejection rate

Terminology Guide

Use these terms correctly in all documentation and code:

Correct Term Definition Wrong Usage
Agent Pipeline Manager β†’ Analyst β†’ Persona β†’ Risk sequence ❌ "multi-agent system"
Agent Functional unit within ONE persona (Manager, Analyst, etc.) ❌ Agent = Persona
Persona Character + LLM combination (Warren Buffett + Claude) ❌ "agent" when referring to persona
SSE Streaming Server-Sent Events for AI response ❌ "WebSocket" (not used in MVP)
Shadow Portfolio Virtual/practice portfolio ❌ "paper trading", "simulated"

Development Workflow

Phase 1: Planning & Documentation (Current)

  • βœ… Tech stack finalized
  • βœ… Specs written (backend, frontend, infrastructure)
  • βœ… Repository split planned
  • πŸ”„ Amplify migration planned
  • πŸ”„ SSE vs WebSocket decision: Keep SSE

Phase 2: Infrastructure Setup (Next)

  • Create sage-infra repository
  • Define Pulumi resources (ECS, RDS, ElastiCache)
  • Set up AWS Amplify app via Pulumi

Phase 3: Backend Implementation

  • Create sage-back repository
  • Implement Agent Pipeline
  • Set up SSE streaming endpoints
  • Connect to Claude API

Phase 4: Frontend Implementation

  • Create sage-front repository
  • Implement SSE client
  • Build chat interface
  • Deploy to Amplify

Contributing

For Documentation Updates

  1. Specs (specs/): Create PR with clear description
  2. Architecture (architecture/): Discuss with team first
  3. Business/Product (business/, product/): Requires product owner approval
  4. Operations (operations/): Requires operations lead approval

For Code Changes

Go to the relevant code repository:


FAQs

Why split into multiple repositories?

  1. Independent deployment cycles: Frontend, backend, infra deploy at different rates
  2. Team autonomy: Each team can work independently
  3. Clearer boundaries: Docs vs code separation
  4. Simplified CI/CD: Each repo has focused pipelines

Why not use Git submodules?

  • Complexity: Submodules add overhead (init, update, nested commits)
  • Independence: Each repo should work standalone
  • Simplicity: Copy + README link is simpler for our team size

Why Amplify instead of S3+CloudFront?

  • Automatic deployment: Git push β†’ auto build (no GitHub Actions needed)
  • PR previews: Auto preview URL for every PR
  • Simplicity: Less manual configuration
  • MVP speed: Faster time to market

Will we use WebSocket later?

Possibly in Phase 2+ if we add:

  • Real-time collaborative features (group chat, shared portfolio)
  • Live market data streaming to UI (ticker)
  • User interrupt during AI response

For MVP, SSE is sufficient and simpler.


Contact & Support


License

(To be determined)


Last Updated: 2026-01-05 Migration Status: Converted from monorepo to multi-repository structure

🏠 Home

πŸ›οΈ Architecture

πŸ“‹ Technical Specs

πŸ“¦ Product

🏒 Business & Strategy

πŸš€ Operations

πŸ€– AI Guides (Legacy)


πŸ”— Repositories

Clone this wiki locally