Ctrip's Lumos: AI-Powered 'Code as Docs' Cuts Manual Documentation 80%
Ctrip's flight frontend team built Lumos, an AI-driven platform integrating CI/CD with Dify workflows to automatically generate and update documentation from code changes, creating a unified vector knowledge base across 74 repositories that reduces manual documentation effort by 80% and accelerates onboarding by 60%.
Background
As Ctrip's flight business grew rapidly, project complexity increased, leading to scattered information and outdated documentation. Project information was spread across heterogeneous systems — product requirements, technical designs, meeting notes, code implementations, merge requests, and postmortems — stored in project management tools, document repositories, code hosting platforms, and enterprise IM. This fragmentation created "information silos," increasing cognitive load, reducing search efficiency, and risking inconsistency.
Problem Analysis
2.1 Information Scattering and Retrieval Difficulties
Developers had to piece together context by jumping across systems: original requirements → technical designs → code iteration history → chat discussions. Keyword-based search returned noisy results and missed critical design decisions hidden in unstructured discussions or archived versions. Inconsistent document states across systems (e.g., deprecated designs still marked as valid) led to wrong decisions and defects.
2.2 Documentation Update Lag
In agile delivery, code iteration speed far exceeded manual documentation maintenance. Documentation was treated as low priority, often delayed or forgotten. Static documents couldn't reflect real-time code state — API changes without doc updates caused integration errors. Lack of bidirectional links between code and docs increased understanding cost and hindered code reviews.
2.3 Code Change Impact Hard to Track
In a highly coupled system, a local change could ripple unexpectedly. Developers relied on code search and personal experience, missing implicit dependencies via event buses, config files, or dynamic calls. Regression test scope was hard to define, raising test costs and production incidents. Non-functional impacts (e.g., performance regressions) required manual before/after comparison, which was slow and error-prone.
Solution: Three Strategies
Ctrip's flight frontend team proposed "Code as Docs" and built the Lumos platform with three strategies:
Unified Knowledge Base: Integrate code and requirements on one platform, using Git for version control and sync. All doc changes go through PR/MR, stored centrally in code repos — a single source of truth.
Automated Sync: Event-driven mechanism captures every code change and auto-generates/updates docs, ensuring real-time consistency.
Intelligent Analysis: Automated, quantitative impact assessment across business logic, performance, code standards. Results presented as structured reports for quick decision-making.
Technical Implementation
Overall architecture integrates CI/CD pipelines, Dify workflows, vector knowledge base, and intelligent Q&A.
4.1 AI-Driven "Code as Docs" Mode
4.1.1 Intelligent Analysis: Parsing Structure and Dependencies
Start from entry files (e.g., index.js, main.ts), use static analysis to extract module dependencies.
Analyze import statements to build module dependency graph.
Mine semantic information, combine with code comments to generate detailed functional descriptions.
Produce docs with function descriptions, I/O definitions, and dependencies.
Supplement with version history and change notes from historical versions.
4.1.2 Dynamic Mechanism: Change-Triggered Doc Updates
CI/CD Pipeline Trigger: On new Merge Request (MR), CI/CD automatically calls Dify service API to start code change analysis.
Dify Workflow Analysis: Based on MR IID, generates Markdown docs covering:
Product requirement description (extracted from MR description, task links, standardized fields)
Development logic breakdown (business logic impact analysis)
Code analysis (added/modified/deleted code snippets)
Impact assessment (performance metrics: TTI, bundle size, ESLint scores)
Standardized MR Description: Defined format (background, scope, performance metrics) improves AI analysis accuracy and team collaboration standards.
Doc Storage & Integration: Generated summaries stored as Markdown, integrated into vector knowledge base for retrieval and reuse.
4.1.3 Doc Optimization: Balancing Real-time and Accuracy
Automation for real-time: CI/CD triggers Dify on every change, drastically reducing update latency.
Manual adjustment for accuracy: Platform supports human edits to supplement complex logic missed by automation.
Unified standardization and flexibility: Standardized MR descriptions boost automation accuracy while retaining manual flexibility.
4.2 Knowledge Base Integration and Intelligent Retrieval
Generated Markdown docs are vectorized and stored in a knowledge base, enabling natural language queries for module functions, dependencies, and change impact assessments. Semantic search improves precision and supports complex queries.
Intelligent Q&A system combines vector retrieval with context-aware semantic analysis. Integrated with enterprise chat bots: developers ask questions in group chats, bot instantly returns answers with doc links. This significantly improves collaboration efficiency and problem-solving speed.
4.3 Code Change Tracking System
Comprehensive impact evaluation including performance metrics, code quality, and multi-dimensional analysis.
Performance Metrics Analysis: Real-time monitoring of FCP, TTI, CLS, JS bundle size changes. AI-generated performance reports pinpoint bottlenecks and suggest optimizations.
Code Quality Assessment: Static analysis tools (ESLint, SonarQube) combined with AI evaluate cyclomatic complexity, code duplication, potential vulnerabilities, code smells. AI generates quality reports for quick fixes.
Multi-dimensional Analysis: Modular AI tools for user behavior tracking, A/B testing evaluation, comprehensive impact analysis. Correlate performance metrics (server response time, API call frequency), UX metrics (dwell time, conversion), system health (CPU, memory). Foundation for future analysis extensions.
Practice and Application
5.1 Automated Document Generation
CI/CD + Dify workflow auto-generates docs on code changes, greatly improving update efficiency and sync.
5.2 Module Document Summary
Modular code parsing AI Agent generates module summaries from entry files, covering all modules' functions and dependencies. Helps developers quickly grasp core logic, reduces onboarding cost, aids cross-team collaboration.
5.3 Code Change Impact Analysis
Auto-tracks impact on business logic and performance metrics, generating detailed reports covering TTI and bundle size changes, helping developers quickly assess potential impact.
5.4 Intelligent Q&A and Real-time Collaboration
Integrated intelligent Q&A system and enterprise chat bots enable real-time info sharing and rapid problem resolution, boosting collaboration efficiency.
5.5 Practice Results
5.5.1 Scaled Adoption: From Flight Frontend to Entire R&D
Lumos platform self-developed by flight frontend team, now scaled across teams.
Connected 74 business repositories across 7 business groups/lines .
Generated 1,063 business and change documents total.
Unified cross-team, cross-tech-stack knowledge base coverage.
5.5.2 Knowledge Base Quality: From "Having Docs" to "Usable Docs"
Business Docs: Module analysis, technical implementation, requirement design — 989 docs .
Change Docs: CI/CD auto-generated code change analyses — 74 docs .
Top repos reach practical depth: highest single repo 126 docs ; 4 repos exceed 50 docs, providing ample context for AI Code Review and new hire onboarding.
Vector Knowledge Base Coverage: 51 repos synced, each with independent dataset for semantic retrieval. Uses platform-preconfigured embedding model balancing precision and speed.
Global AI Q&A: 5 core repos enabled global AI Q&A 2 high-frequency repos have dedicated chat bot entries for deep repo-level conversations.
5.5.3 Technical Architecture: Lumos-Skill Retrieval-Augmented Pipeline
Lumos knowledge retrieval productized as Lumos-Skill, integrated into AI Code Review pipelines for joint review of "business context + code changes". AI Reviewer automatically queries business knowledge base during review, compensating for pure code review's lack of business perspective.
5.5.4 Efficiency Gains: Paradigm Shift from Manual to Automation
Doc Maintenance Cost: Traditional mode required 20-30% extra time; Lumos auto-triggers workflow on MR merge, manual maintenance time reduced 80%+ .
New Hire Onboarding: New members build complete module cognition in 1-2 days via Lumos knowledge base, vs traditional "read code + ask seniors" — onboarding cycle shortened 60%+ .
Code Review Quality: With Lumos-Skill providing business context, review opinions' "business logic correctness" detection rate significantly improved — reviewers now assess change rationality and risks based on business background, not just code style.
Knowledge Precipitation: Tacit knowledge scattered in individuals' minds systematically collected and vectorized into shared organizational assets, transforming from "people leave, knowledge lost" to "knowledge grows with code".
Next Steps
Knowledge Base Upgrade: Retrieval to Reasoning — Introduce graph-based associations linking code entities, derived business rules, and change history into structured semantic network. Goal: AI understands not just single requirements but dependencies and evolution between requirements, providing richer business context for impact analysis.
Deep Integration of AI Code Review with Business Semantics — Beyond code-level defects, identify conflicts with existing business rules. Gradually cover security compliance, performance risks, cross-module business consistency. Evolve review suggestions from "code style hints" to "business risk diagnostics".
Harness Paradigm: Output Verification and Effect Measurement — Build quantitative evaluation system for AI output quality: precision and recall of requirement restoration docs, detection rate and false positive rate of Code Review. Cross-validate with human reviews to form measurement feedback loop, drive continuous model iteration, ensure AI output meets engineering quality standards.
Conclusion
Through deep integration of automation tools and intelligent technology, Ctrip's flight frontend team initially practiced the "Code as Docs" philosophy, achieving phased results in code change impact tracking and reverse requirement restoration. From solving their own doc pain points to Lumos platform serving multiple business groups' R&D systems, the team proved the feasibility and scalability of "Code as Docs" through engineering practice.
Next focus shifts from "capability building" to "quality convergence" — establishing systematic output verification under Harness paradigm, quantifying accuracy and completeness of requirement restoration docs, continuously measuring AI Code Review detection and false positive rates. Only with solid evaluation systems can AI-assisted R&D move from "usable" to "trustworthy", becoming a stable, reliable part of daily workflows.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Ctrip Technology
Official Ctrip Technology account, sharing and discussing growth.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
