How franckinani/ai-investment-agent works
Purpose and Entry Points
Ledgerline is a private, owner-scoped multi-agent investment research workspace. It supports research, evidence review, agent conversations, auditable decisions, and paper proposals—not real-capital execution. The browser app boots at client/src/main.tsx, renders application routing in client/src/App.tsx, and communicates with the Node server entry point server/index.ts. /welcome is public; operational views require authentication.
Client Operating Workspace
The React/Vite client provides Mission Control as the primary desk view, plus focused specialist conversations, task/decision, portfolio, activity, connection, wallet, and settings views. Core application surfaces reside in client/src/pages/MissionControl.tsx, client/src/pages/Chat.tsx, and client/src/pages/DecisionDesk.tsx. client/src/components/DashboardLayout.tsx supplies the common operator shell; client/src/_core/hooks/useAuth.ts gates owner-scoped UI; client/src/contexts/ThemeContext.tsx manages presentation state.
API, Authentication, and Server Composition
The server composes authenticated tRPC procedures and HTTP/Vite hosting. Request context, cookies, authentication integration, and RPC setup are concentrated in server/_core/context.ts, server/_core/oauth.ts, and server/_core/trpc.ts; route aggregation is in server/routers.ts. The client RPC boundary is client/src/lib/trpc.ts. Server-side ownership checks are the authoritative boundary—client state must not establish access scope.
Agent Fabric and Research Runtime
The agent system defines specialist roles, capabilities, orchestration, and bounded research execution. server/agentFabric.ts coordinates agent-facing workflows, server/agentExecutor.ts runs agent work, and server/agentCapabilities.ts resolves permitted capabilities. Shared role/runtime contracts live in shared/agentRuntime.ts, shared/tradingAgents.ts, and shared/capabilityRegistry.ts. Capability and team declarations are externalized in config/agents/team.yaml, config/capabilities/registry.yaml, and config/capabilities/mcp-servers.yaml, forming a policy/configuration boundary around runtime code.
Memory, Conversations, and Auditability
Individual conversations are restricted to eligible non-execution research agents. Server-derived context combines authenticated owner, selected agent, active/expiry state, and retrieval limits; it must not trust client-provided memory scope. server/agentMemoryRouter.ts exposes the memory API, server/agentMemoryDb.ts persists and retrieves scoped records, and shared/agentMemory.ts defines shared/private memory semantics. The additive schema evolution is represented by drizzle/0011_agent_memory_workspace.sql, with main persistence schema in drizzle/schema.ts. Private-to-shared promotion is an explicit reviewed workflow with revision and audit actions.
Decision, Policy, and Execution Boundaries
Research results flow into policy review, decisions, paper simulation, and immutable activity rather than live orders. Policy/authority contracts are in shared/mandateAuthority.ts, shared/authorityState.ts, and shared/hardGate.ts; server enforcement and security endpoints reside in server/authorityRouter.ts, server/security.ts, and server/securityRouter.ts. Paper-only execution is implemented through server/paperRouter.ts, server/paperExecutor.ts, and server/backends/paper.backend.ts. Live CEX/on-chain adapters exist under server/liveAdapter.ts, server/backends/cex.backend.ts, and server/backends/onchain.backend.ts, but the compiled real-venue mutation seal remains the material no-go control.
Persistence, Operations, and Deployment
Drizzle migrations/schema target PostgreSQL through server/db.ts, drizzle.config.ts, and drizzle/schema.ts. Dockerized deployment is defined by Dockerfile, docker-compose.yml, and docker-compose.prod.yml; Nginx is configured in nginx/nginx.conf. Optional operations monitoring uses Prometheus, Alertmanager, and Grafana configuration in monitoring/prometheus.yml, monitoring/alertmanager.yml, and monitoring/grafana/dashboard.json. Environment values originate from .env.example; secrets, wallet material, and database credentials remain deployment-managed inputs.
Main entry points: routers.ts Router aggregation · agentFabric.ts Agent fabric · agentMemoryRouter.ts Scoped memory API · MissionControl.tsx Operator workspace
Components 22
Operator client
- React/Vite bootstrap
client/src/main.tsx - Application routes
client/src/App.tsx - Operator workspace · Authenticated research, chat, and decision surfaces share an operator shell.
client/src/pages/MissionControl.tsx - Client auth gate · Gates owner-scoped UI; it is not the authority boundary.
client/src/_core/hooks/useAuth.ts - tRPC client boundary
client/src/lib/trpc.ts
API and runtime
- Node server · Hosts HTTP, authenticated RPC, and Vite integration.
server/index.ts - Authenticated tRPC · Cookies and server-derived identity establish authoritative owner scope.
server/_core/trpc.ts - Router aggregation
server/routers.ts
Agent research fabric
- Agent fabric
server/agentFabric.ts - Bounded agent execution
server/agentExecutor.ts - Agent runtime contracts · Defines roles, runtime behavior, and capability registry contracts.
shared/agentRuntime.ts - Agent policy declarations · External declarations constrain teams, capabilities, and MCP servers.
config/agents/team.yaml
Memory and decision controls
- Scoped memory API · Derives eligible agent, owner, active state, expiry, and retrieval limits server-side.
server/agentMemoryRouter.ts - Agent memory store · Persists private/shared memory and reviewed promotion audit records.
server/agentMemoryDb.ts - Memory semantics
shared/agentMemory.ts - Authority enforcement · Applies mandate, authority-state, and hard-gate controls.
server/authorityRouter.ts - Paper execution · Produces proposals and simulations, not real-capital orders.
server/paperExecutor.ts - Real-venue mutation seal · Blocks live CEX and on-chain mutation despite adapter presence.
server/liveAdapter.ts
Persistence and deployment
- PostgreSQL persistence · Holds owner-scoped application, memory, decision, and activity data.
server/db.ts - Schema and migration · Includes additive agent-memory workspace evolution.
drizzle/schema.ts - Container deployment · Deployment-managed environment supplies secrets and credentials.
docker-compose.yml - Nginx edge
nginx/nginx.conf
Connections 22
- React/Vite bootstrap → Application routes: renders
- Application routes → Operator workspace: routes to
- Client auth gate → Operator workspace: gates
- Operator workspace → tRPC client boundary: uses
- tRPC client boundary → Node server: RPC over HTTP
- Node server → Authenticated tRPC: composes
- Authenticated tRPC → Router aggregation: authorizes procedures
- Router aggregation → Agent fabric: research workflows
- Agent fabric → Bounded agent execution: dispatches
- Bounded agent execution → Agent runtime contracts: uses
- Agent fabric → Agent policy declarations: loads declared policy
- Router aggregation → Scoped memory API: memory procedures
- Scoped memory API → Memory semantics: enforces semantics
- Scoped memory API → Agent memory store: reads and writes
- Agent memory store → PostgreSQL persistence: persists to
- Router aggregation → Authority enforcement: policy and security procedures
- Agent fabric → Authority enforcement: submits research outcomes
- Authority enforcement → Paper execution: permits paper proposals
- Paper execution → Real-venue mutation seal: cannot bypass
- Schema and migration → PostgreSQL persistence: defines and evolves
- Nginx edge → Node server: proxies to
- Container deployment → Nginx edge: deploys