This document describes the folder structure of the LLM Backend Framework.
The project is organized into several key directories:
├── api/ # API layer with FastAPI
│ ├── v1/ # Versioned APIs
│ ├── middleware/ # API middleware components
│ ├── app.py # API application configuration
│ └── __init__.py # API initialization
├── src/ # Source code
│ ├── chat_engine.py # Chat engine implementation
│ ├── config_injector.py # Dependency injection setup
│ ├── base/ # Core framework pieces
│ │ ├── brains/ # Brain interface and variants
│ │ └── components/ # Modular building blocks
│ │ ├── llms/ # LLM client implementations
│ │ ├── memories/ # Conversation memory backends
│ │ ├── embeddings/ # Embedding generators
│ │ ├── tools/ # Tool implementations
│ │ └── vector_databases/ # Vector DB integrations
│ ├── experts/ # Domain-specific chat experts
│ │ ├── qna/ # Q&A expert implementation
│ │ └── rag_bot/ # Retrieval‑augmented generation expert
│ └── common/ # Shared utilities
├── tests/ # Test directory
├── docs/ # Documentation
├── app.py # FastAPI application entry point
├── cli.py # Command-line interface
├── Dockerfile # Docker configuration
├── Makefile # Build and development commands
├── pyproject.toml # Python project configuration
└── requirements.txt # Project dependencies
The API layer handles HTTP requests and responses using FastAPI:
api/v1/- Versioned API endpointsapi/middleware/- Custom middleware componentsapi/app.py- FastAPI application configurationapi/__init__.py- API initialization
src/chat_engine.py- Chat engine implementation for message processingsrc/config_injector.py- Dependency injection configuration
src/base/brains/- Brain interfaces and variantssrc/base/components/- Core componentsllms/- LLM client implementationsmemories/- Conversation memory implementationsembeddings/- Embedding generatorstools/- Tool implementationsvector_databases/- Vector database integrationsREADME.md- Components documentation
- Domain-specific experts built on top of the base layer
qna/- Question answering expertrag_bot/- Retrieval‑augmented generation expert
- Shared utilities and models
- Configuration management
- Logging setup
- Unit tests
- Integration tests
- Test fixtures and utilities
api.md- API documentationfolder_structure.md- This document
The application follows a layered architecture:
-
API Layer
- Handles HTTP requests/responses
- Input validation
- Error handling
- Middleware processing
-
Base Layer
- Brain abstractions and component factories
- Chat engine integration
-
Experts
- Domain-specific logic built on the base layer
-
Common Layer
- Shared utilities
- Configuration management
- Logging
This structure promotes:
- Clear separation of concerns
- Modularity and extensibility
- Easy testing and maintenance
- Consistent error handling
- Comprehensive logging