From 9b0f5516181622958a3a03c9b70e15ce66771fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80?= <78488229+viktor138irk@users.noreply.github.com> Date: Mon, 11 May 2026 22:25:31 +0900 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20API=20=D0=B0=D0=BD=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B0=20GitHub=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/main.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/backend/main.py b/backend/main.py index d292b25..f1657c6 100644 --- a/backend/main.py +++ b/backend/main.py @@ -12,6 +12,7 @@ from backend.config_store import ( set_setting, ) from backend.openai_client import OpenAIConfigurationError, ask_ai +from backend.project_analyzer import analyze_github_project ROOT_DIR = Path(__file__).resolve().parent.parent FRONTEND_DIR = ROOT_DIR / 'frontend' @@ -40,6 +41,10 @@ class PromptTestRequest(BaseModel): task_type: str | None = None +class ProjectAnalyzeRequest(BaseModel): + repo_url: str + + @app.get('/') async def root(): index_file = FRONTEND_DIR / 'index.html' @@ -129,3 +134,21 @@ async def test_openai_connection(): 'model': result['model'], 'answer': result['answer'], } + + +@app.post('/api/projects/analyze') +async def analyze_project(payload: ProjectAnalyzeRequest): + repo_url = payload.repo_url.strip() + + if not repo_url.startswith('http'): + raise HTTPException(status_code=400, detail='Invalid repository URL') + + try: + analysis = analyze_github_project(repo_url) + except Exception as exc: + raise HTTPException(status_code=500, detail=str(exc)) from exc + + return { + 'success': True, + 'analysis': analysis.to_dict(), + }