|
| 1 | +import { |
| 2 | + DocsLayout, |
| 3 | + DocsCodeBlock, |
| 4 | + DocsPagination, |
| 5 | + TimeEstimate, |
| 6 | + TOCItem |
| 7 | +} from '@/components/docs' |
| 8 | + |
| 9 | +const tocItems: TOCItem[] = [ |
| 10 | + { id: 'dependencies', title: 'Dependency Graph', level: 2 }, |
| 11 | + { id: 'impact', title: 'Impact Analysis', level: 2 }, |
| 12 | + { id: 'style', title: 'Code Style', level: 2 }, |
| 13 | + { id: 'insights', title: 'Repository Insights', level: 2 }, |
| 14 | +] |
| 15 | + |
| 16 | +export function APIAnalysisPage() { |
| 17 | + return ( |
| 18 | + <DocsLayout toc={tocItems}> |
| 19 | + <div className="mb-8 pb-8 border-b border-white/10"> |
| 20 | + <div className="flex items-center gap-3 mb-4"> |
| 21 | + <TimeEstimate minutes={6} /> |
| 22 | + </div> |
| 23 | + <h1 className="text-4xl font-bold text-white mb-4">Analysis API</h1> |
| 24 | + <p className="text-xl text-gray-400"> |
| 25 | + Dependency graphs, impact analysis, code style, and repository insights. |
| 26 | + </p> |
| 27 | + </div> |
| 28 | + |
| 29 | + {/* Dependency Graph */} |
| 30 | + <h2 id="dependencies" className="text-2xl font-semibold text-white mt-12 mb-4">Dependency Graph</h2> |
| 31 | + |
| 32 | + <div className="flex items-center gap-3 p-3 bg-white/[0.02] border border-white/10 rounded-lg mb-4"> |
| 33 | + <span className="text-xs font-mono font-bold px-2 py-1 rounded text-green-400 bg-green-500/10"> |
| 34 | + GET |
| 35 | + </span> |
| 36 | + <code className="text-sm text-gray-300">/api/repos/{'{repo_id}'}/dependencies</code> |
| 37 | + </div> |
| 38 | + |
| 39 | + <p className="text-gray-300 mb-4"> |
| 40 | + Get the complete import/dependency graph for a repository. |
| 41 | + </p> |
| 42 | + |
| 43 | + <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mt-6 mb-2">Response</h4> |
| 44 | + <DocsCodeBlock language="json"> |
| 45 | +{`{ |
| 46 | + "nodes": [ |
| 47 | + { |
| 48 | + "id": "src/auth/middleware.py", |
| 49 | + "label": "middleware.py", |
| 50 | + "directory": "src/auth", |
| 51 | + "in_degree": 12, |
| 52 | + "out_degree": 3, |
| 53 | + "is_hub": true |
| 54 | + } |
| 55 | + ], |
| 56 | + "edges": [ |
| 57 | + { |
| 58 | + "source": "src/api/routes.py", |
| 59 | + "target": "src/auth/middleware.py", |
| 60 | + "type": "import" |
| 61 | + } |
| 62 | + ], |
| 63 | + "stats": { |
| 64 | + "total_files": 47, |
| 65 | + "total_edges": 89, |
| 66 | + "hub_files": ["src/utils/index.ts"], |
| 67 | + "leaf_files": ["src/config.py"], |
| 68 | + "circular_dependencies": [] |
| 69 | + } |
| 70 | +}`} |
| 71 | + </DocsCodeBlock> |
| 72 | + |
| 73 | + <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mt-6 mb-2">Example</h4> |
| 74 | + <DocsCodeBlock language="bash"> |
| 75 | +{`curl -H "Authorization: Bearer YOUR_API_KEY" \\ |
| 76 | + http://localhost:8000/api/repos/repo_abc123/dependencies`} |
| 77 | + </DocsCodeBlock> |
| 78 | + |
| 79 | + {/* Impact Analysis */} |
| 80 | + <h2 id="impact" className="text-2xl font-semibold text-white mt-12 mb-4">Impact Analysis</h2> |
| 81 | + |
| 82 | + <div className="flex items-center gap-3 p-3 bg-white/[0.02] border border-white/10 rounded-lg mb-4"> |
| 83 | + <span className="text-xs font-mono font-bold px-2 py-1 rounded text-green-400 bg-green-500/10"> |
| 84 | + GET |
| 85 | + </span> |
| 86 | + <code className="text-sm text-gray-300">/api/repos/{'{repo_id}'}/impact</code> |
| 87 | + </div> |
| 88 | + |
| 89 | + <p className="text-gray-300 mb-4"> |
| 90 | + Analyze the impact of changing a specific file. |
| 91 | + </p> |
| 92 | + |
| 93 | + <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mt-6 mb-2">Query Parameters</h4> |
| 94 | + <div className="overflow-x-auto mb-4"> |
| 95 | + <table className="w-full text-sm"> |
| 96 | + <thead> |
| 97 | + <tr className="border-b border-white/10"> |
| 98 | + <th className="text-left py-2 text-gray-400 font-medium">Parameter</th> |
| 99 | + <th className="text-left py-2 text-gray-400 font-medium">Type</th> |
| 100 | + <th className="text-left py-2 text-gray-400 font-medium">Required</th> |
| 101 | + <th className="text-left py-2 text-gray-400 font-medium">Description</th> |
| 102 | + </tr> |
| 103 | + </thead> |
| 104 | + <tbody className="text-gray-300"> |
| 105 | + <tr> |
| 106 | + <td className="py-2 font-mono text-blue-400">file</td> |
| 107 | + <td className="py-2 font-mono text-xs">string</td> |
| 108 | + <td className="py-2"><span className="text-amber-400">Yes</span></td> |
| 109 | + <td className="py-2">Path to the file to analyze</td> |
| 110 | + </tr> |
| 111 | + </tbody> |
| 112 | + </table> |
| 113 | + </div> |
| 114 | + |
| 115 | + <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mt-6 mb-2">Response</h4> |
| 116 | + <DocsCodeBlock language="json"> |
| 117 | +{`{ |
| 118 | + "file": "src/auth/middleware.py", |
| 119 | + "risk_level": "high", |
| 120 | + "risk_score": 0.85, |
| 121 | + "direct_dependents": [ |
| 122 | + "src/api/routes.py", |
| 123 | + "src/api/admin.py" |
| 124 | + ], |
| 125 | + "indirect_dependents": [ |
| 126 | + "src/main.py" |
| 127 | + ], |
| 128 | + "related_tests": [ |
| 129 | + "tests/test_auth.py" |
| 130 | + ], |
| 131 | + "test_coverage": { |
| 132 | + "has_tests": true, |
| 133 | + "test_count": 2 |
| 134 | + }, |
| 135 | + "recommendations": [ |
| 136 | + "High-impact file with 5 dependents", |
| 137 | + "Run tests before deploying changes" |
| 138 | + ] |
| 139 | +}`} |
| 140 | + </DocsCodeBlock> |
| 141 | + |
| 142 | + <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mt-6 mb-2">Example</h4> |
| 143 | + <DocsCodeBlock language="bash"> |
| 144 | +{`curl -H "Authorization: Bearer YOUR_API_KEY" \\ |
| 145 | + "http://localhost:8000/api/repos/repo_abc123/impact?file=src/auth/middleware.py"`} |
| 146 | + </DocsCodeBlock> |
| 147 | + |
| 148 | + {/* Code Style */} |
| 149 | + <h2 id="style" className="text-2xl font-semibold text-white mt-12 mb-4">Code Style</h2> |
| 150 | + |
| 151 | + <div className="flex items-center gap-3 p-3 bg-white/[0.02] border border-white/10 rounded-lg mb-4"> |
| 152 | + <span className="text-xs font-mono font-bold px-2 py-1 rounded text-green-400 bg-green-500/10"> |
| 153 | + GET |
| 154 | + </span> |
| 155 | + <code className="text-sm text-gray-300">/api/repos/{'{repo_id}'}/style</code> |
| 156 | + </div> |
| 157 | + |
| 158 | + <p className="text-gray-300 mb-4"> |
| 159 | + Analyze coding conventions and patterns in the repository. |
| 160 | + </p> |
| 161 | + |
| 162 | + <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mt-6 mb-2">Response</h4> |
| 163 | + <DocsCodeBlock language="json"> |
| 164 | +{`{ |
| 165 | + "naming": { |
| 166 | + "variables": "snake_case", |
| 167 | + "functions": "snake_case", |
| 168 | + "classes": "PascalCase", |
| 169 | + "confidence": 0.92 |
| 170 | + }, |
| 171 | + "patterns": { |
| 172 | + "async_style": "async/await", |
| 173 | + "error_handling": "try/except", |
| 174 | + "imports": "absolute" |
| 175 | + }, |
| 176 | + "type_system": { |
| 177 | + "type_hint_usage": 0.78, |
| 178 | + "common_types": ["Optional", "List", "Dict"] |
| 179 | + }, |
| 180 | + "common_imports": [ |
| 181 | + { "module": "fastapi", "count": 34 }, |
| 182 | + { "module": "pydantic", "count": 28 } |
| 183 | + ] |
| 184 | +}`} |
| 185 | + </DocsCodeBlock> |
| 186 | + |
| 187 | + {/* Repository Insights */} |
| 188 | + <h2 id="insights" className="text-2xl font-semibold text-white mt-12 mb-4">Repository Insights</h2> |
| 189 | + |
| 190 | + <div className="flex items-center gap-3 p-3 bg-white/[0.02] border border-white/10 rounded-lg mb-4"> |
| 191 | + <span className="text-xs font-mono font-bold px-2 py-1 rounded text-green-400 bg-green-500/10"> |
| 192 | + GET |
| 193 | + </span> |
| 194 | + <code className="text-sm text-gray-300">/api/repos/{'{repo_id}'}/insights</code> |
| 195 | + </div> |
| 196 | + |
| 197 | + <p className="text-gray-300 mb-4"> |
| 198 | + Get high-level insights and metrics about a repository. |
| 199 | + </p> |
| 200 | + |
| 201 | + <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mt-6 mb-2">Response</h4> |
| 202 | + <DocsCodeBlock language="json"> |
| 203 | +{`{ |
| 204 | + "overview": { |
| 205 | + "total_files": 142, |
| 206 | + "total_lines": 28500, |
| 207 | + "languages": { |
| 208 | + "TypeScript": 65, |
| 209 | + "Python": 42, |
| 210 | + "JavaScript": 35 |
| 211 | + } |
| 212 | + }, |
| 213 | + "architecture": { |
| 214 | + "pattern": "monolith with service layer", |
| 215 | + "entry_points": ["src/main.py", "src/cli.py"], |
| 216 | + "critical_files": [ |
| 217 | + "src/core/engine.py", |
| 218 | + "src/api/routes.py" |
| 219 | + ] |
| 220 | + }, |
| 221 | + "health": { |
| 222 | + "test_coverage_estimate": "partial", |
| 223 | + "documentation_coverage": 0.45, |
| 224 | + "circular_dependencies": 0 |
| 225 | + } |
| 226 | +}`} |
| 227 | + </DocsCodeBlock> |
| 228 | + |
| 229 | + <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mt-6 mb-2">Example</h4> |
| 230 | + <DocsCodeBlock language="bash"> |
| 231 | +{`curl -H "Authorization: Bearer YOUR_API_KEY" \\ |
| 232 | + http://localhost:8000/api/repos/repo_abc123/insights`} |
| 233 | + </DocsCodeBlock> |
| 234 | + |
| 235 | + <DocsPagination |
| 236 | + prev={{ title: 'Search API', href: '/docs/api/search' }} |
| 237 | + next={{ title: 'Architecture', href: '/docs/architecture' }} |
| 238 | + /> |
| 239 | + </DocsLayout> |
| 240 | + ) |
| 241 | +} |
0 commit comments