Modular Architecture
In this chapter, we dive into the heart of the FANA LLM Framework's design philosophy—its modular architecture.
Modular Architecture
In the development of the FANA LLM Framework, we embrace a modular architecture approach to ensure our application is scalable, maintainable, and understandable. This architecture allows individual components or features to be developed, tested, and debugged independently, leading to a more robust and agile development process.
Why Modular Architecture?
Scalability: Modules can be independently scaled depending on demand for specific functionalities, allowing for efficient use of resources.
Maintainability: Changes in one module can be made with minimal impact on others, making it easier to manage updates and bug fixes.
Reusability: Common functionalities are abstracted into modules that can be reused across different parts of the application, reducing code duplication.
Collaboration: Teams can work on different modules simultaneously without significant conflicts, enhancing team productivity.
Backend Modularization
Our backend modules are organized under the src/
directory, ensuring that each logical component of our backend functionality is encapsulated within its own namespace. Key modules include:
API Modules:
api_auth.py
: Handles API authentication.api_routes.py
: Manages API endpoints routing.api_validate_key.py
: Validates API keys.
Chat Modules:
chat_groq.py
: Routes for chat API endpoints (Groq-based).chat_history_supabase.py
: Manages chat history using Supabase.chat_openai.py
: Routes for chat API endpoints (OpenAI-based).
Content Modules:
content_fetcher.py
: Finds the most similar content using cosine similarity.db_supabase.py
: Interacts with Supabase for retrieval-augmented generation (RAG).
Embedding and Text Processing:
embedding.py
: Generates and retrieves embeddings for RAG.text_process.py
: Manages text logic when no triggers are found.
Image and Vision Modules:
image_diffusion_openai.py
: Generates images using OpenAI.image_process.py
: Orchestrates all image processing logic.image_vision_claude.py
: Manages image vision API endpoints (Claude-based).image_vision_openai.py
: Manages image vision API endpoints (OpenAI-based).
Logging:
logging_setup.py
: Configures and manages logging for the system.
Socket.IO:
socketio_event_handler.py
: Handles Socket.IO events.socketio_instance.py
: Manages Socket.IO instances.
Speech and Translation Modules:
speech_openai.py
: Manages speech-to-text processing using OpenAI.translate_openai.py
: Manages multi-language translation using OpenAI.translate_groq.py
: Manages multi-language translation using Groq.
Storage:
storage_azureblob.py
: Uploads images to Azure Blob Storage.
System and Task Management:
system_prompt.py
: Generates and manages system-level prompts.task_determination.py
: Handles main LLM orchestration tasks.
Trigger Modules:
triggers_check.py
: Manages triggers API endpoints.triggers_generate.py
: Manages triggers generation endpoints.triggers_greetings.py
: Manages greeting triggers.triggers_regenerate.py
: Manages triggers regeneration endpoints.
Infrastructure as Code (IAC) for Scalability
We utilize Infrastructure as Code (IAC) practices to automate the provisioning and management of our infrastructure, ensuring that our environment is reproducible, scalable, and consistent. Our IAC setup includes:
Terraform Scripts: Define and manage our cloud resources in a declarative manner.
Docker Configurations: Ensure that our application can be consistently deployed across any environment.
Project Structure
Summary
The modular architecture not only supports the rapid development and deployment of new features but also ensures that our system remains flexible and robust against the challenges of evolving user requirements and technological advancements. By documenting our architecture, we aim to provide a clear roadmap for current and future developers, fostering an environment of transparency and continuous improvement.
Last updated