feat: performance optimizations, schematic API, and branching setup#1
feat: performance optimizations, schematic API, and branching setup#1
Conversation
Backend: - Fix N+1 queries in communities, processes, ask context, skip chapter - Add 6 missing DB indexes (migration 0010) - Add pagination (limit/offset) to files, symbols, narratives repos and API routes - Expand moka cache capacity 100→500, add caching to files/symbols endpoints - Add HTTP Cache-Control middleware for GET routes - Add schematic API endpoint with lazy-load tree + expand + detail Frontend: - Add client-side fetch cache (cachedGet with 5min TTL) for read-heavy endpoints - Rewrite schematic pages: remove ELK.js (1.5MB), inline pure-TS layout engine (159 LOC) - Add vite-plugin-compression2 (brotli), manual chunk splitting (three, shiki, 3d-graph) - Lazy-load Shiki languages per file instead of all upfront CI/Infra: - Update CI to trigger on dev branch - Enable delete-branch-on-merge, adopt feature branch workflow Docs: - Add docs/OPTIMIZATIONS.md (12-item performance plan) - Add docs/SCHEMATIC_DESIGN.md (unified explorer design) - Add docs/adr/0002-unified-schematic-explorer.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request delivers a comprehensive suite of performance optimizations and introduces a powerful new schematic API to enhance the application's responsiveness and user experience. By addressing database inefficiencies, implementing robust caching strategies, and revamping the frontend architecture for the schematic view, the changes significantly improve data loading times and reduce client-side resource consumption. The new schematic API provides a unified, lazy-loaded, and interactive way to explore the codebase, laying the groundwork for more integrated features. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
Ensures all coding agents (Claude, Cursor, etc.) follow the feature branch workflow (feat/xxx → dev → main) and are aware of established performance patterns (pagination, caching, N+1 prevention). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
The pull request introduces significant performance optimizations across the backend API, addressing N+1 query problems, adding pagination, and expanding caching mechanisms. The new schematic API and its frontend rewrite are major improvements, replacing a heavy third-party library with a lean, custom solution. Database migrations for new indexes and client-side caching further enhance performance. The documentation for optimizations and the architectural decision record are excellent additions, providing clear rationale and future plans. However, there are a few minor issues related to error handling and a potential bug in the new schematic repository, as well as a stale entry in package.json.
| all_dirs.insert(dir_path.clone(), true); | ||
| nodes.push(SchematicNode { | ||
| id: dir_id.clone(), node_type: "directory".into(), | ||
| label: parts[i].to_string(), parent_id: Some(parent_id.clone()), |
There was a problem hiding this comment.
In the loop for creating intermediate directory nodes, parts[i].to_string() seems incorrect. parts is the split array of the full path, and i is the index of the current part being processed. It should likely be part.to_string() to use the current part variable from the for loop.
| label: parts[i].to_string(), parent_id: Some(parent_id.clone()), | |
| label: part.to_string(), parent_id: Some(parent_id.clone()), |
| WHERE s.id IN ({})", | ||
| placeholders.join(", ") | ||
| ); | ||
| let mut stmt = conn.prepare(&sql).unwrap(); |
There was a problem hiding this comment.
Using .unwrap() for conn.prepare can lead to a panic if the SQL statement is malformed or there's a database issue. It's generally safer to handle the Result explicitly, perhaps by mapping it to an ApiError.
| let mut stmt = conn.prepare(&sql).unwrap(); | |
| let mut stmt = conn.prepare(&sql).map_err(|e| ApiError::from(codeilus_core::error::CodeilusError::Database(Box::new(e))))?; |
| row.get::<_, i64>(4)?, | ||
| row.get::<_, Option<String>>(5)?, | ||
| )) | ||
| }).unwrap(); |
There was a problem hiding this comment.
Similar to the prepare call, using .unwrap() on stmt.query_map can cause a panic if the query execution fails. It's best to handle this Result explicitly to provide a more robust error response.
let rows = stmt.query_map(params.as_slice(), |row| {
Ok((
row.get::<_, String>(0)?,
row.get::<_, String>(1)?,
row.get::<_, String>(2)?,
row.get::<_, i64>(3)?,
row.get::<_, i64>(4)?,
row.get::<_, Option<String>>(5)?,
))
}).map_err(|e| ApiError::from(codeilus_core::error::CodeilusError::Database(Box::new(e))))?;| "sideEffects": [ | ||
| "./src/lib/schematic/elk-layout.ts" | ||
| ], |
Backend:
- Community color enrichment for directory nodes (dominant community)
- Grid layout for community overview, layered layout for symbol graphs
- Schematic expand returns subdirectories correctly
Frontend (6 new components, ~730 lines):
- SchematicTooltip: hover tooltips with node metadata
- SchematicDetailTabs: 5-tab detail panel (overview, source, relations, learn, notes)
- SchematicSourcePopup: floating source viewer on double-click
- SchematicContextMenu: right-click actions (view source, ask AI, annotations, etc.)
- SchematicKeyboardOverlay: keyboard shortcut reference (?)
- SchematicMinimap: viewport overview with click-to-pan
Unified page (/explore/schematic):
- Tree + Graph mode toggle with shared state
- Hover highlighting (connected edges + ghost nodes)
- Single click expand/select, double-click deep dive
- Right-click context menu per node type
- Keyboard shortcuts (1/2 modes, F fit, ? help, Esc close)
- Lazy loading via /api/v1/schematic endpoints
- Community sidebar with progress bars in graph mode
- Search highlighting across all nodes
Also:
- Strip ("name") prefix from module_summary narratives
- Grid layout for community nodes (was single row)
- computeFitToView utility in layout.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Legend toggle in toolbar with edge colors, node types, community swatches - SVG drop-shadow filter on hovered nodes - Rounded corners rx=8, fix minimap type error Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Root node shows "codeilus" instead of "."
- Tooltip shows "click to expand" hint for directories
- Detail panel shows helpful message when no narrative available
- Strip ("name") prefix from narratives in detail panel
- Fix minimap type error (community_color cast)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Backend: - Filter symbols by community_id when set (was loading ALL symbols) - Filter edges to intra-community only (JOIN on community_members) - Community 2: 241 symbols + 304 edges (was 5773 + 14252) Frontend: - Fix Source tab lazy loading (track sourceNodeId to detect node changes) - Root node shows "codeilus" instead of "." - Narrative fallback message when no AI explanation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests (31 passing): - 6 API tests: schematic, expand, detail, community filter - 7 tree mode tests: rendering, expand, detail panel, search, minimap - 3 graph mode tests: mode switch, sidebar, drill-down - 8 interaction tests: hover, right-click, keyboard, fit, legend, source tab - 7 TDD behavior tests: source code, progress, learn tab, copy, focus, expand Bug fixes: - Source code endpoint: handle absolute file paths (was "path traversal" error) - Schematic expand: use common-prefix normalization for any codebase path format - Clipboard copy: wrap in try/catch for headless environments Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
public, max-age=300) for all GET API routes/api/v1/schematicwith depth-limited lazy loading, expand, and detail endpointsapi.ts— 5min TTL for read-heavy endpoints (files, symbols, communities, narratives, chapters)devbranch, CI triggers on dev+main, delete-branch-on-merge enabledTest plan
cargo build && cargo clippy && cargo test— zero warnings, all 47 suites passGET /api/v1/symbols?limit=10&offset=0GET /api/v1/communitiesreturns data in 2 queries (not 1+N)Cache-Controlheader on GET responsescd frontend && pnpm build— verify brotli-compressed chunks created🤖 Generated with Claude Code