How aadityabuilds/recombyne works
Project Type and Purpose
• This is a full-stack web application (“Recombyne”) for AI-powered plasmid design.
• Frontend: React + TypeScript + Vite, providing a conversational UI and real-time DNA visualization.
• Backend: Node.js/Express (TypeScript) exposing REST endpoints that orchestrate:
• AI calls (OpenAIService)
• NCBI GenBank queries (GenbankService)
• Python-based DNA optimization (dna_optimization.py via child process)
File Structure
• Top‐level:
• public/ – static assets and HTML shell (served by Vite or by Express in prod)
• src/ – application source split into:
– src/components, src/styles, src/App.tsx (React UI layers: split-pane, modals, chat editor)
– src/services/*.ts (client API wrappers for OpenAI, NCBI, plasmid backbone)
– src/server/api/*.ts (Express route handlers for “/dna-optimization” and “/natural-language-to-entrez”)
– src/server/python/ (Python scripts using DNAChisel and helper modules)
• server.ts – entry point for Express server (mounts API routes)
• vite.config.ts, tsconfig.frontend.json, tsconfig.backend.json – separate build targets
Extract Architectural Insights from README
• Dual-server setup: Vite dev server (frontend) + Express backend (3001)
• Environment variables configure ports, OpenAI key, NCBI credentials, Python path
• External systems:
• OpenAI API (chat completion, embeddings)
• NCBI E-Utilities (Entrez queries)
• DNAChisel library (sequence optimization)
• @teselagen/ove (embedded in the frontend for sequence visualization)
Main Components & Their Interactions
a. Client (Browser)
• React/Vite SPA – renders UI, maintains conversation history in Redux or Context (store.ts)
• Sequence viewer/editor (@teselagen/ove) integrated into EditorPane
• Invokes backend via HTTP (fetch or axios) to /api endpoints
b. API Gateway (Express, server.ts)
• Routes: /api/dna-optimization, /api/natural-language-to-entrez
• Middlewares: error boundary, JSON parsing, CORS
c. Service Layer (backend/services)
• OpenAIService.ts – calls OpenAI REST API
• GenbankService.ts – calls NCBI E-Utilities
• PlasmidBackboneService.ts – loads local catalog of backbones
d. Python Worker
• dna_optimization.py – uses DNAChisel to optimize sequences
• debug_api.py, constraints_reference.py – support modules
• Invoked as a child process from dna-optimization.ts
e. External Systems
• OpenAI cloud endpoints
• NCBI Entrez API
Architectural Patterns & Design Principles
• Separation of concerns: UI vs API vs compute (Python)
• Modular services: each external integration lives in its own service class
• Microservice‐style compute offload: heavyweight optimization lives in Python subprocess
• Component-based UI: reusable modals, split panes, error boundaries
• Configuration via environment variables for portability
a. Layout & Components
• Center: Express API Server (server.ts) with two layers: Routes → Service Classes → Worker Orchestrator
• Right: Python Optimization Service (child process)
• Bottom: External APIs (OpenAI, NCBI)
• Data Store (optional): In-memory or Redux store for conversation context
• Browser → Express (HTTP POST /api/…)
• Express → OpenAI / NCBI (HTTPS)
• Express → Python Worker (spawn child, IPC)
• Python Worker → Express (stdout JSON) → Browser (HTTP response)
• UI Components: blue rectangles
• Server Components: green rectangles
• Python Worker: yellow capsule
d. Labels & Annotations
• Environment variables controlling ports, API keys