How pyspur-dev/pyspur works
Main Components
• Frontend Application:
• Built with Next.js (React-based) from the “frontend” directory.
• Contains pages, components, state management (store slices), and routing.
• Interacts with the backend via RESTful API endpoints.
• Backend Application:
• Written in Python under the “backend” directory (pyspur package).
• Provides a set of API endpoints (under “backend/pyspur/api”) for agent management, file management, dataset and evaluation management, workflow operations, etc.
• Contains specialized modules for node handling, integrations (Slack, GitHub, Google, etc.), RAG (including vector datastore interactions and document processing), evaluations, and execution of workflows.
• Utilizes Alembic for database migrations, and supports both SQLite (development) and Postgres (production) as noted in the README and .env configuration.
• Database:
• A PostgreSQL database (or SQLite for testing) that persists user data, agent workflows, document collections, and evaluation runs.
• External Services and Integrations:
• Various third-party services such as OpenAI, Anthropic, Slack, Google Sheets, GitHub, YouTube, etc.
• Also includes optional vector database providers for RAG (Chroma, pgvector, Pinecone, etc.).
• Container and Deployment Infrastructure:
• Dockerfiles (Dockerfile.backend, Dockerfile.frontend) and docker-compose files are provided for development and production deployment.
• The devcontainer configuration supports a containerized development environment.
• Documentation & Dev Tools:
• The “docs” directory provides API references, walkthroughs, and essential guides.
• Scripts (like generate_migrations.sh, start_pyspur_docker.sh) help with automation and deployment.
• Render the Frontend and Backend as separate, clearly labeled nodes. Show how the frontend (via HTTP/HTTPS requests) calls the backend API.
• Backend’s internal modular structure by grouping related sub-components:
• API Layer: Routes and endpoints managing agent workflows (from “api” folder).
• Execution & Node Management: Nodes, execution contexts, CLI integration, and looping constructs (from “nodes”, “execution” directories).
• Integrations: Connectors for external services and providers (e.g., Slack, GitHub, Google, etc.).
• RAG Module: Components for document chunking, vector index creation, and datastore providers.
• Database Interaction: The module with Alembic migration scripts and SQL operations.
• Backend to the Database, indicating bi-directional data flow (CRUD operations).
• External Services as separate entities that the Backend communicates with, usually through dedicated integration modules.
• Docker/Container orchestration as the underlying infrastructure layer that houses both the Frontend and Backend components.
Architectural Patterns and Principles
• Separation of Concerns: Distinct separation between frontend UI, backend services/APIs, and external integrations.
• Modularity: The backend is divided into clear modules (e.g., API endpoints, node management, RAG, integrations) which can be independently maintained or extended.
• Containerization: Use of Docker ensures consistent environments across development and production.
• Extensibility: Python-based node additions and integrations that allow developers to plug in new functionalities with minimal friction.