How smallcloudai/refact works
Major Components
• GUI / Frontend – Located in “refact-agent/gui”, which is a full-featured frontend built with components in TypeScript/React (or similar frameworks) using modern tooling (Vite, ESLint, Prettier) and integrating with the engine.
• Server – In “refact-server”, you see Dockerfiles, API routes, webgui middleware, and data pipelines. This layer serves the self-hosted containerized backend, offering REST endpoints, integration with databases (PostgreSQL, MySQL) and external APIs.
• Documentation & DevOps – The “docs” folder (built with Astro, storybook files, Docker Compose scripts) and GitHub workflows show CI/CD and documentation generation.
• Data Pipeline and Integration Modules – Within “refact-server/refact_data_pipeline” and “refact_known_models” are modules that process and filter data, manage model pipelines, and ensure integrations with external LLM providers. They are key for RAG (Retrieval-Augmented Generation) and support the Bring Your Own Key (BYOK) feature.
• Self-Hosting and Orchestration – Under “refact-server/self_hosting_machinery” there’s another layer responsible for finetuning, inference, watchdog scripts, and model hosting.
Relationships and Data Flow
• The GUI communicates with the server layer via APIs (provided by web endpoints in “refact-server/refact_webgui” and REST routers in “refact-agent/engine/src/http/routers/v1”).
• The engine interacts with integrations (like GitHub, GitLab, Docker, databases) to fetch code context and execute tasks. It also uses its modules for AST parsing, LSP capabilities, and tool execution.
• The server orchestrates deployments, handles authentication, and also manages data pipelines for processing model input and output.
• CI/CD pipelines (GitHub workflows/scripts) ensure that changes in these components are built and deployed correctly.
Architectural Patterns and Design Principles
• Modular structure: Each major functionality is neatly organized in its own folder (e.g., “engine”, “gui”, “server”) following separation of concerns.
• Microservices-like design: The agent engine and the server are somewhat decoupled, communicating through well-defined API interfaces.
• Integration through plugins: The system’s design allows for external tool integrations (e.g., IDE chat plugins, Docker containers, database connectors) as seen in the “integrations” directories.
• Use of containerization: With Dockerfiles present in both docs and server folders, containerization is a key deployment strategy.
• Extensibility: With a dedicated “plugins” guide and clear folder structures for integrations, the system has been architected with extension points.