Coverage for src/local_deep_research/web/routes/route_registry.py: 82%
32 statements
« prev ^ index » next coverage.py v7.15.1, created at 2026-07-20 01:24 +0000
« prev ^ index » next coverage.py v7.15.1, created at 2026-07-20 01:24 +0000
1"""
2Route Registry - Central documentation of all application routes
3This file provides a single place to see all available routes across blueprints
5NOTE: This is primarily for documentation and reference purposes.
6The actual routes are defined in their respective blueprint files.
7To keep this in sync:
81. Update this file when adding/removing routes
92. Run tests to ensure URLs in tests match actual routes
103. Consider using get_all_routes() in tests to validate against actual Flask routes
11"""
13# Route patterns by blueprint
14from typing import Any # noqa: E402
16ROUTE_REGISTRY: dict[str, Any] = {
17 "research": {
18 "blueprint": "research_bp",
19 "url_prefix": None, # Routes at root level
20 "routes": [
21 ("GET", "/", "index", "Home/Research page"),
22 (
23 "POST",
24 "/api/start_research",
25 "start_research",
26 "Start new research",
27 ),
28 (
29 "GET",
30 "/api/research/<string:research_id>",
31 "get_research_details",
32 "Get research details",
33 ),
34 (
35 "GET",
36 "/api/research/<string:research_id>/logs",
37 "get_research_logs",
38 "Get research logs",
39 ),
40 (
41 "GET",
42 "/api/research/<research_id>/status",
43 "get_research_status",
44 "Get research status",
45 ),
46 (
47 "GET",
48 "/api/report/<string:research_id>",
49 "get_research_report",
50 "Get research report",
51 ),
52 (
53 "POST",
54 "/api/terminate/<string:research_id>",
55 "terminate_research",
56 "Stop research",
57 ),
58 (
59 "DELETE",
60 "/api/delete/<string:research_id>",
61 "delete_research",
62 "Delete research",
63 ),
64 ("GET", "/api/history", "get_history", "Get research history"),
65 (
66 "POST",
67 "/api/clear_history",
68 "clear_history",
69 "Clear all history",
70 ),
71 (
72 "GET",
73 "/progress/<string:research_id>",
74 "progress_page",
75 "Research progress page",
76 ),
77 (
78 "GET",
79 "/results/<string:research_id>",
80 "results_page",
81 "Research results page",
82 ),
83 (
84 "GET",
85 "/details/<string:research_id>",
86 "research_details_page",
87 "Research details page",
88 ),
89 ],
90 },
91 "api_v1": {
92 "blueprint": "api_blueprint",
93 "url_prefix": "/api/v1",
94 "routes": [
95 ("GET", "/", "api_documentation", "API documentation"),
96 ("GET", "/health", "health_check", "Health check"),
97 (
98 "POST",
99 "/quick_summary",
100 "api_quick_summary",
101 "Quick LLM summary",
102 ),
103 (
104 "POST",
105 "/generate_report",
106 "api_generate_report",
107 "Generate research report",
108 ),
109 (
110 "POST",
111 "/analyze_documents",
112 "api_analyze_documents",
113 "Analyze documents",
114 ),
115 ],
116 },
117 "history": {
118 "blueprint": "history_bp",
119 "url_prefix": "/history",
120 "routes": [
121 ("GET", "/", "history_page", "History page"),
122 ("GET", "/api", "get_history", "Get history data"),
123 (
124 "GET",
125 "/status/<string:research_id>",
126 "get_research_status",
127 "Get research status",
128 ),
129 (
130 "GET",
131 "/details/<string:research_id>",
132 "get_research_details",
133 "Get research details",
134 ),
135 (
136 "GET",
137 "/logs/<string:research_id>",
138 "get_research_logs",
139 "Get research logs",
140 ),
141 (
142 "GET",
143 "/log_count/<string:research_id>",
144 "get_log_count",
145 "Get log count",
146 ),
147 (
148 "GET",
149 "/history/report/<string:research_id>",
150 "get_report",
151 "Get research report",
152 ),
153 (
154 "GET",
155 "/markdown/<string:research_id>",
156 "get_markdown",
157 "Get markdown report",
158 ),
159 ],
160 },
161 "settings": {
162 "blueprint": "settings_bp",
163 "url_prefix": "/settings",
164 "routes": [
165 ("GET", "/", "settings_page", "Settings page"),
166 (
167 "POST",
168 "/save_all_settings",
169 "save_all_settings",
170 "Save all settings",
171 ),
172 (
173 "POST",
174 "/reset_to_defaults",
175 "reset_to_defaults",
176 "Reset to defaults",
177 ),
178 ("GET", "/api", "api_get_all_settings", "Get all settings"),
179 (
180 "GET",
181 "/api/<path:key>",
182 "api_get_setting",
183 "Get specific setting",
184 ),
185 ("POST", "/api/<path:key>", "api_update_setting", "Update setting"),
186 (
187 "DELETE",
188 "/api/<path:key>",
189 "api_delete_setting",
190 "Delete setting",
191 ),
192 ("POST", "/api/import", "api_import_settings", "Import settings"),
193 (
194 "GET",
195 "/api/categories",
196 "api_get_categories",
197 "Get setting categories",
198 ),
199 ("GET", "/api/types", "api_get_types", "Get setting types"),
200 (
201 "GET",
202 "/api/ui_elements",
203 "api_get_ui_elements",
204 "Get UI elements",
205 ),
206 (
207 "GET",
208 "/api/available-models",
209 "api_get_available_models",
210 "Get available models",
211 ),
212 (
213 "GET",
214 "/api/available-search-engines",
215 "api_get_available_search_engines",
216 "Get search engines",
217 ),
218 (
219 "GET",
220 "/api/warnings",
221 "api_get_warnings",
222 "Get settings warnings",
223 ),
224 (
225 "GET",
226 "/api/ollama-status",
227 "check_ollama_status",
228 "Check Ollama status",
229 ),
230 ],
231 },
232 "metrics": {
233 "blueprint": "metrics_bp",
234 "url_prefix": "/metrics",
235 "routes": [
236 ("GET", "/", "metrics_dashboard", "Metrics dashboard"),
237 ("GET", "/costs", "costs_page", "Costs page"),
238 ("GET", "/star-reviews", "star_reviews_page", "Star reviews page"),
239 ("GET", "/api/metrics", "api_metrics", "Get metrics data"),
240 (
241 "GET",
242 "/api/cost-analytics",
243 "api_cost_analytics",
244 "Get cost analytics",
245 ),
246 ("GET", "/api/pricing", "api_pricing", "Get pricing data"),
247 (
248 "GET",
249 "/api/metrics/research/<string:research_id>",
250 "api_research_metrics",
251 "Research metrics",
252 ),
253 (
254 "GET",
255 "/api/metrics/research/<string:research_id>/timeline",
256 "api_research_timeline_metrics",
257 "Timeline metrics",
258 ),
259 (
260 "GET",
261 "/api/metrics/research/<string:research_id>/search",
262 "api_research_search_metrics",
263 "Search metrics",
264 ),
265 (
266 "GET",
267 "/api/ratings/<string:research_id>",
268 "api_get_research_rating",
269 "Get research rating",
270 ),
271 (
272 "POST",
273 "/api/ratings/<string:research_id>",
274 "api_save_research_rating",
275 "Save research rating",
276 ),
277 (
278 "GET",
279 "/api/research-costs/<string:research_id>",
280 "api_research_costs",
281 "Get research costs",
282 ),
283 (
284 "GET",
285 "/journals",
286 "journal_quality",
287 "Journal quality dashboard",
288 ),
289 (
290 "GET",
291 "/api/journals",
292 "api_journal_quality",
293 "Get journal quality data",
294 ),
295 ],
296 },
297}
300def get_all_routes():
301 """Get a flat list of all routes across blueprints"""
302 all_routes = []
303 for blueprint_name, blueprint_info in ROUTE_REGISTRY.items():
304 prefix = blueprint_info["url_prefix"] or ""
305 for method, path, endpoint, description in blueprint_info["routes"]:
306 full_path = f"{prefix}{path}" if prefix else path
307 all_routes.append(
308 {
309 "method": method,
310 "path": full_path,
311 "endpoint": f"{blueprint_name}.{endpoint}",
312 "description": description,
313 "blueprint": blueprint_name,
314 }
315 )
316 return all_routes
319def get_routes_by_blueprint(blueprint_name):
320 """Get routes for a specific blueprint"""
321 if blueprint_name not in ROUTE_REGISTRY:
322 return []
324 blueprint_info = ROUTE_REGISTRY[blueprint_name]
325 prefix = blueprint_info["url_prefix"] or ""
326 routes = []
328 for method, path, endpoint, description in blueprint_info["routes"]:
329 full_path = f"{prefix}{path}" if prefix else path
330 routes.append(
331 {
332 "method": method,
333 "path": full_path,
334 "endpoint": endpoint,
335 "description": description,
336 }
337 )
338 return routes
341def find_route(path_pattern):
342 """Find routes matching a path pattern"""
343 all_routes = get_all_routes()
344 matching_routes = []
346 for route in all_routes:
347 if path_pattern.lower() in route["path"].lower():
348 matching_routes.append(route)
350 return matching_routes
353if __name__ == "__main__": 353 ↛ 355line 353 didn't jump to line 355 because the condition on line 353 was never true
354 # Example usage
355 print("All API routes:")
356 for route in get_all_routes():
357 if "/api" in route["path"]:
358 print(
359 f"{route['method']:6} {route['path']:40} - {route['description']}"
360 )