How moyangzhan/langchain4j-aideepin works
Project type and purpose
• This is the backend service of “LangChain4j-AIDeepin,” an AI-powered productivity tool.
• It exposes REST APIs for both an end-user web client (chat, image generation, knowledge base, workflow) and an admin web client (system configuration, statistics, user/model/KB management).
• It’s implemented as a multi-module Maven project using Spring Boot.
File structure
• Top-level modules:
• adi-bootstrap – Bootstraps and configures the Spring Boot application (profiles, logging).
• adi-chat – Main REST API for user-side features (chat, drawing, KB, workflow, files).
• adi-admin – Admin REST API for management functions.
• adi-common – Shared domain, DTOs, entities, mappers, repositories, services, AOP, configuration, and plugin interfaces for models/embedding/graph/search.
• Deployment descriptors: Dockerfile under adi-bootstrap, docker-compose.yml + .env files.
• Resources: SQL DDL (docs/create.sql), MyBatis XML mappers, Spring YAML configs, logback.
README insights
• Technical stack: JDK17, Spring Boot 3.x, LangChain4j, LangGraph4j
• Databases: PostgreSQL + pgvector + Apache AGE (or Neo4j), Redis (for caching, rate-limit, SSE).
• External dependencies: AI platforms (OpenAI, DeepSeek, DashScope, QianFan, Ollama, ...), search engines (Google Custom Search), file storage (Aliyun OSS).
• Features: multi-session chat, image gen/edit, RAG via vector/graph search, custom workflows, usage/statistics tracking.
a. Main components:
• Frontends:
• User Web UI (Vue3/Vite/TypeScript)
• Admin Web UI (Vue3/Vite/TypeScript)
• API Services (Spring Boot):
• Bootstrap Module (entry point)
• Chat Module (controllers: ConversationController, DrawController, etc.)
• Admin Module (controllers: AdminUserController, StatisticController, SystemConfigController, etc.)
• Shared Common Module (layered: controllers → services → mappers → database)
• Databases:
• PostgreSQL (primary data, pgvector extension)
• Graph DB (Apache AGE on Postgres or Neo4j)
• Redis (caching, rate-limit, SSE streams)
• External Systems:
• AI Model Providers (OpenAI, DeepSeek, DashScope, QianFan, Ollama, …)
• Search Engines (Google Custom Search, future Bing/Baidu)
• File Storage (Aliyun OSS)
b. Relationships and data flow:
• UIs → REST endpoints (Chat & Admin modules)
• Modules → Common services → MyBatis mappers → DB
• Services → Redis (cache, pub/sub for SSE)
• Services → External AI platforms & search engines via HTTP clients
• Services → File operator context → Aliyun OSS or local FS
c. Architectural patterns & principles:
• Modular Maven multi-module structure
• Layered architecture: Controller → Service → Repository (MyBatis)
• Plugin / Strategy pattern for AI providers, embedding stores, graph stores, search engines
• AOP for logging, request validation, distributed locking
• Dependency injection via Spring Boot
• Docker-compose for environment orchestration
d. Key technologies:
• Spring Boot, Spring MVC, Spring Data Redis
• MyBatis (mapper XML under resources/mapper)
• pgvector & Apache AGE or Neo4j
• LangChain4j / LangGraph4j
• Maven multi-module build
• Docker, Docker Compose
Detail
• Essential modules (bootstrap, chat, admin, common).
• Plugin/strategy sub-components only if space permits (e.g., AIModelService implementations).
• Avoid over-simplification—represent the core flow: UI → Controller → Service → Mapper → DB → External.
• Persistence store and external dependency is visible.