How openedu-project/openedu-ai-core works
Project Type and Purpose
• This project is an advanced AI integration and backend service for the OpenEdu educational platform.
• Its primary goal is to provide robust AI-powered features such as intelligent agents, course generation, smart mind mapping, and slide-to-video conversion.
• The README specifies it’s a backend core built on FastAPI with integrations with multiple LLM providers (Azure OpenAI, AWS Bedrock, Google Cloud) and integration with various storage and messaging layers (MongoDB, Redis, Celery, etc.).
File Structure
• The top-level directory includes Docker and CI/CD configurations (.github/workflows, Dockerfile, docker-compose.yml), indicating a containerized deployment approach.
• The src directory is the heart of the project. It is organized into several clearly-separated parts:
• api/ – Contains API endpoints (controllers), middlewares, repositories, schemas, and hooks, suggesting an MVC-like separation for the web layer.
• core/ – Contains the core business logic including agents, features, tools, prompts, and utilities. This layer likely implements the educational AI capabilities.
• config/ – Holds configuration details for databases (e.g., MongoDB, Redis) and overall settings.
• libs/ – Contains shared libraries that support specific domains (chatbot, mindmap, slide-to-video conversion, summarization, etc.).
• models/ – Defines data structure models used across the system.
• tasks/ – Contains background tasks (likely using Celery) for asynchronous processing such as handling conversational workflows or cron jobs.
• tests/ – Includes unit, integration, and performance tests ensuring code quality.
• utils/ – Utility functions and helpers, supporting the overall application logic.
Core Components and Their Responsibilities
a. API Layer:
• Built with FastAPI (src/api), this layer includes various controllers for different features (agent, auth, chatbot, blog, course, etc.).
• Contains middlewares (e.g., error handling, CORS, static file serving) that handle cross-cutting concerns.
b. Business Logic Layer (Core):
• Implements the AI features and agents (src/core/agents, src/core/features) for tasks such as content generation, chat, and mind mapping.
• Uses various tools and integrations with LLM providers (src/core/llm_integration) and utilities for supporting business workflows.
c. Data Persistence and Repositories:
• The configuration under src/config/db and functionality in src/api/repos and models indicate use of databases such as MongoDB.
• Redis integration is also present for caching and task state management.
d. Asynchronous Tasks:
• Background processes are managed under src/tasks, handling tasks like blog generation, course processing, transcript extraction, etc.
• Likely leveraging Celery (as mentioned in README and requirements) and Redis for queue management.
e. Shared Libraries:
• Includes modules for specific functionalities (chatbot, mindmap, slide-to-video conversion, etc.) to facilitate reusability and separation of concerns.
f. Integration Points:
• External AI/ML providers integrated via modules under src/core/llm_integration and others.
• Communication with external storage systems and messaging mechanisms (e.g., Docker orchestration, API keys managed via environment variables).
Architectural Patterns/Design Principles
• Layered/MVC Architecture: Separation of controllers, services, and repositories.
• Service-Oriented: Each core feature (agent, chatbot, etc.) is encapsulated in specialized modules making it easier to extend.
• Asynchronous Task Processing: Background tasks are managed separately to avoid blocking the main API.
• Microservice-Ready: While all code is part of one repository, the separation between API, core processing, and asynchronous tasks facilitates scaling individual parts if needed.
• Containerization: Dockerfiles and docker-compose.yml indicate a design that supports containerization and modern DevOps practices.