How codestoryai/sidecar works
Main components
• Sidecar Core: This includes the central logic that ties together the various subsystems.
• Webserver/API Layer: Located under sidecar/src/bin (e.g., webserver.rs) and sidecar/src/webserver, this layer receives requests (e.g., from the Aide editor) and dispatches them to the underlying services.
• Agent and Agentic Modules: Found in sidecar/src/agent, sidecar/src/agentic. These modules define the AI “agent” behavior, including prompt generation, context parsing, and decision-making.
• Repository Mapping (Repomap): The repomap folder implements page rank and symbol mapping for the code base. Represent it as an independent module that processes code structure.
• LLM Clients: Both the “llm_client” and the “llm_prompts” directories (even if the latter is partly legacy) encapsulate the interfaces to various LLM providers (OpenAI, Anthropic, etc.). Include these as external service connectors.
• Logging and Reporting: The “logging” module and reporting subdirectories (under both llm_client and sidecar/src/reporting) provide instrumentation and feedback to track system performance.
• Database and Migrations: Several folders and SQL migration files appear in “llm_client/.sqlx” and “sidecar/migrations”. These represent the persistent data layer that stores model data, caches, or prompt history.
• Ancillary Tools: Additional modules such as repomap, chunking, git integration, and inline completion represent supporting functionalities that enhance the agent’s capabilities.
Relationships and interactions
• The Aide editor (an external consumer) communicates with Sidecar via a dedicated API (webserver layer).
• LLM Clients abstract the specifics of external providers; these components will interact with external APIs over the network.
• Data storage, logging, and reporting modules record interactions and metrics to support auditing, error tracking, and performance tuning.
• Cross-cutting functionalities like repo mapping and file analysis are separate services that are invoked as needed, often feeding data back into the higher-level agent logic.
Important architectural patterns and design principles
• Modular design: The project is broken into discrete libraries and binaries (e.g., separate crates such as “llm_client”, “llm_prompts”, “logging”, and “sidecar”).
• Pluggability and abstraction: Different LLM clients and tool implementations indicate that the system is designed for extensibility, where new providers or tools can be added with minimal changes.
• Separation of concerns: There is a clear division between request handling, AI agent control logic, tool execution, and reporting/logging.