How chadroyer/aiworkflowoptimizer works
High-Level Architecture Layers
• Client Layer (React SPA)
• Server Layer (Node.js + Express API)
• Data Layer (PostgreSQL + Drizzle ORM)
• External Services (Claude AI, Web Search API)
Main Components
A. Frontend (client/)
• React SPA entry (index.html → main.tsx)
• UI component library (shadcn/ui + TailwindCSS)
• Feature modules:
– Authentication (auth-form, login-form, auth-context, use-auth)
– Debug panel (debug-panel)
– Layout & navigation (header, user-profile, protected-route)
• State management via React Contexts (auth-context, chat-context) and React Query (queryClient)
• Pages: auth-page.tsx, chat.tsx, login.tsx, not-found.tsx
B. Backend (server/)
• Express app (index.ts → vite.ts for dev)
• Route definitions (routes.ts)
• Handlers for:
– Authentication (/auth)
– AI calls (/claude.ts)
– Web search (/websearch.ts)
– Storage / file handling (/storage.ts)
– Debugging endpoints (/debug.ts)
• API wiring and middleware
C. Data Layer (db/ + shared/schema.ts)
• Drizzle ORM configuration (drizzle.config.ts)
• Schema definitions (shared/schema.ts)
• Database connector (db/index.ts)
• Seed script (db/seed.ts)
D. External Services
• Anthropic Claude AI (via server/claude.ts)
• Search API (Serper or Google via server/websearch.ts)
E. Developer Tools
• Built-in debug panel (client/src/components/debug)
• Replit agent documentation (replit_agent/*.md)
Interactions & Data Flows
• User browser ↔ HTTP(S) ↔ Express API
• Auth requests
• Chat messages → server → Claude → server → client
• AI opportunity suggestions (with optional web search)
• Server ↔ PostgreSQL (Drizzle ORM) for persisting chats, workflows, user data
• Server ↔ Anthropic Claude service (API calls)
• Server ↔ Search API service
Architectural Patterns & Principles
• Separation of concerns: UI vs business logic vs data persistence
• SPA communicates with RESTful (or RPC-style) Express API
• Contexts & hooks for client-side state management
• Modular route handlers for AI and search integrations
• Shared code (schema.ts) for DRY database modeling
Final Checklist
✔ Four logical layers (Client, Server, Data, External)
✔ Components grouped and labeled by folder or functionality
✔ Callouts for key integrations (Anthropic Claude, Search API)