From c1b1cbdede923c7431afd4d14658cdaf6d76d18f Mon Sep 17 00:00:00 2001 From: Ishtiyaque alam Date: Sun, 14 Dec 2025 14:16:12 +0530 Subject: [PATCH 1/4] Fixed the Landing Page UI issue and Making the Analyze repository consistent untill user analyzes a repositories --- backend/app/api/v1/repositories.py | 24 +++++++++++++++++++ backend/database/__init__.py | 0 frontend/src/App.tsx | 8 +++---- .../contributors/ContributorsPage.tsx | 6 +++-- .../src/components/dashboard/Dashboard.tsx | 6 +++-- .../src/components/landing/LandingPage.tsx | 8 ++++--- .../src/components/pages/AnalyticsPage.tsx | 23 ++++++++++++------ .../src/components/pages/PullRequestsPage.tsx | 11 ++++++--- 8 files changed, 65 insertions(+), 21 deletions(-) create mode 100644 backend/app/api/v1/repositories.py create mode 100644 backend/database/__init__.py diff --git a/backend/app/api/v1/repositories.py b/backend/app/api/v1/repositories.py new file mode 100644 index 00000000..9b1abd3b --- /dev/null +++ b/backend/app/api/v1/repositories.py @@ -0,0 +1,24 @@ +from fastapi import APIRouter, HTTPException +from pydantic import BaseModel +from app.services.codegraph.repo_service import RepoService +import traceback + +router = APIRouter(prefix="/api", tags=["repositories"]) + +class RepoRequest(BaseModel): + repo_url: str + +@router.post("/repo-stats") +async def analyze_repository(request: RepoRequest): + print(f" repo aa gayi : {request.repo_url}") + + try: + result = await RepoService().index_repo(request.repo_url) + return { + "message": "Repository indexed successfully", + "repository": request.repo_url, + "stats": result + } + except Exception as e: + print(traceback.format_exc()) + raise HTTPException(status_code=500, detail=str(e)) from e \ No newline at end of file diff --git a/backend/database/__init__.py b/backend/database/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 9f70aa6c..e3c7ec11 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -161,11 +161,11 @@ function App() { } > } /> - } /> + } /> } /> - } /> - } /> - } /> + } /> + } /> + } /> } /> } /> } /> diff --git a/frontend/src/components/contributors/ContributorsPage.tsx b/frontend/src/components/contributors/ContributorsPage.tsx index d0ee0e2f..53608218 100644 --- a/frontend/src/components/contributors/ContributorsPage.tsx +++ b/frontend/src/components/contributors/ContributorsPage.tsx @@ -2,12 +2,14 @@ import React, { useEffect, useState } from 'react'; import { motion } from 'framer-motion'; import { toast } from 'react-hot-toast'; import ContributorCard from './ContributorCard'; +import LandingPage from '../landing/LandingPage'; interface Props { repoData: any; // Fetched repository stats + setRepoData?: (data: any) => void; } -const ContributorsPage: React.FC = ({ repoData }) => { +const ContributorsPage: React.FC = ({ repoData, setRepoData }) => { const [contributors, setContributors] = useState([]); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); @@ -27,7 +29,7 @@ const ContributorsPage: React.FC = ({ repoData }) => { }; if (!repoData) { - return
No data available. Please analyze a repository first.
; + return {})} />; } if (loading) { diff --git a/frontend/src/components/dashboard/Dashboard.tsx b/frontend/src/components/dashboard/Dashboard.tsx index a758cdc8..a2315827 100644 --- a/frontend/src/components/dashboard/Dashboard.tsx +++ b/frontend/src/components/dashboard/Dashboard.tsx @@ -4,14 +4,16 @@ import { toast } from 'react-hot-toast'; import { Users, GitPullRequest, MessageSquare, Activity, Github, Slack } from 'lucide-react'; import StatCard from './StatCard'; import BotIntegration from '../integration/BotIntegration'; +import LandingPage from '../landing/LandingPage'; interface Props { repoData: any; // Fetched repository stats + setRepoData?: (data: any) => void; // Function to pass data to parent } -const Dashboard: React.FC = ({ repoData }) => { +const Dashboard: React.FC = ({ repoData,setRepoData }) => { if (!repoData) { - return
No data available. Please analyze a repository first.
; + return {})} />; } const handleNewIntegration = () => { diff --git a/frontend/src/components/landing/LandingPage.tsx b/frontend/src/components/landing/LandingPage.tsx index 0b586566..f583279b 100644 --- a/frontend/src/components/landing/LandingPage.tsx +++ b/frontend/src/components/landing/LandingPage.tsx @@ -5,10 +5,12 @@ import { toast } from 'react-hot-toast'; import { useNavigate } from 'react-router-dom'; interface Props { - setRepoData: (data: any) => void; // Function to pass data to parent + setRepoData?: (data: any) => void; + message: string; } -const LandingPage: React.FC = ({ setRepoData }) => { +const LandingPage: React.FC = ({ setRepoData, message }) => { + const safeSetRepoData = setRepoData ?? (() => {}); const [repoUrl, setRepoUrl] = useState(''); const [loading, setLoading] = useState(false); const navigate = useNavigate(); @@ -21,7 +23,7 @@ const LandingPage: React.FC = ({ setRepoData }) => { setLoading(true); try { const response = await axios.post('http://localhost:8000/api/repo-stats', { repo_url: repoUrl }); - setRepoData(response.data); // Pass fetched data to parent + safeSetRepoData(response.data); toast.success('Repository stats fetched successfully!'); navigate('/dashboard'); // Navigate to dashboard } catch (error) { diff --git a/frontend/src/components/pages/AnalyticsPage.tsx b/frontend/src/components/pages/AnalyticsPage.tsx index 7a7a1968..b46edc83 100644 --- a/frontend/src/components/pages/AnalyticsPage.tsx +++ b/frontend/src/components/pages/AnalyticsPage.tsx @@ -1,5 +1,5 @@ - import React from 'react'; +import LandingPage from '../landing/LandingPage'; import { BarChart3, TrendingUp, @@ -115,13 +115,22 @@ const pieData = [ const COLORS = ['#0088FE', '#00C49F', '#FFBB28']; interface Props { - repoData: any; + repoData: any; + setRepoData?: (data: any) => void; } -const AnalyticsPage: React.FC = ({ repoData }) => { - if (!repoData || !repoData.pull_requests) { - return
No data available. Please analyze a repository first.
; - } +const AnalyticsPage: React.FC = ({ repoData, setRepoData }) => { + if (!repoData) { + return {})} />; + } + if (!repoData.pull_requests) { + return ( +
+ No data available for pull requests. Please analyze a repository + first. +
+ ); + } const [selectedRange, setSelectedRange] = React.useState('Last Week'); const [activeIndex, setActiveIndex] = React.useState(0); @@ -349,7 +358,7 @@ const AnalyticsPage: React.FC = ({ repoData }) => { ); -} +}; const renderActiveShape = (props: any) => { const { diff --git a/frontend/src/components/pages/PullRequestsPage.tsx b/frontend/src/components/pages/PullRequestsPage.tsx index 1859f501..7d56dd97 100644 --- a/frontend/src/components/pages/PullRequestsPage.tsx +++ b/frontend/src/components/pages/PullRequestsPage.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import LandingPage from '../landing/LandingPage'; import { motion } from 'framer-motion'; interface PullRequest { @@ -17,11 +18,15 @@ interface PullRequest { interface Props { repoData: { pull_requests: { details: PullRequest[] } } | null; + setRepoData?: (data: any) => void; } -const PullRequestsPage: React.FC = ({ repoData }) => { - if (!repoData || !repoData.pull_requests) { - return
No data available. Please analyze a repository first.
; +const PullRequestsPage: React.FC = ({ repoData, setRepoData }) => { + if (!repoData) { + return {})} />; + } + if (!repoData.pull_requests) { + return
No data available for pull requests. Please analyze a repository first.
; } const prs = repoData.pull_requests.details; From f95e631704c8c8687b7eef3dd9b96b23b92027a0 Mon Sep 17 00:00:00 2001 From: Ishtiyaque alam Date: Sun, 14 Dec 2025 14:19:58 +0530 Subject: [PATCH 2/4] Minor changes --- backend/app/api/v1/repositories.py | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 backend/app/api/v1/repositories.py diff --git a/backend/app/api/v1/repositories.py b/backend/app/api/v1/repositories.py deleted file mode 100644 index 9b1abd3b..00000000 --- a/backend/app/api/v1/repositories.py +++ /dev/null @@ -1,24 +0,0 @@ -from fastapi import APIRouter, HTTPException -from pydantic import BaseModel -from app.services.codegraph.repo_service import RepoService -import traceback - -router = APIRouter(prefix="/api", tags=["repositories"]) - -class RepoRequest(BaseModel): - repo_url: str - -@router.post("/repo-stats") -async def analyze_repository(request: RepoRequest): - print(f" repo aa gayi : {request.repo_url}") - - try: - result = await RepoService().index_repo(request.repo_url) - return { - "message": "Repository indexed successfully", - "repository": request.repo_url, - "stats": result - } - except Exception as e: - print(traceback.format_exc()) - raise HTTPException(status_code=500, detail=str(e)) from e \ No newline at end of file From 2d3ee19486135425365d7f8eecb848b9d5c166e2 Mon Sep 17 00:00:00 2001 From: Ishtiyaque-Alam <154577460+Ishtiyaque-Alam@users.noreply.github.com> Date: Sun, 14 Dec 2025 15:09:45 +0530 Subject: [PATCH 3/4] Update frontend/src/App.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- frontend/src/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index e3c7ec11..ebd8d11a 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -160,7 +160,7 @@ function App() { isAuthenticated ? : } > - } /> + } /> } /> } /> } /> From 41d5a6c18cb4ee13d95d448d918226765d137f54 Mon Sep 17 00:00:00 2001 From: Ishtiyaque alam Date: Mon, 15 Dec 2025 12:08:23 +0530 Subject: [PATCH 4/4] Props fixed --- frontend/src/components/contributors/ContributorsPage.tsx | 2 +- frontend/src/components/dashboard/Dashboard.tsx | 2 +- frontend/src/components/landing/LandingPage.tsx | 4 ++-- frontend/src/components/pages/AnalyticsPage.tsx | 2 +- frontend/src/components/pages/PullRequestsPage.tsx | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/contributors/ContributorsPage.tsx b/frontend/src/components/contributors/ContributorsPage.tsx index 53608218..195081fc 100644 --- a/frontend/src/components/contributors/ContributorsPage.tsx +++ b/frontend/src/components/contributors/ContributorsPage.tsx @@ -29,7 +29,7 @@ const ContributorsPage: React.FC = ({ repoData, setRepoData }) => { }; if (!repoData) { - return {})} />; + return {})} message="Please analyze a repository first to get started." />; } if (loading) { diff --git a/frontend/src/components/dashboard/Dashboard.tsx b/frontend/src/components/dashboard/Dashboard.tsx index a2315827..1a084a13 100644 --- a/frontend/src/components/dashboard/Dashboard.tsx +++ b/frontend/src/components/dashboard/Dashboard.tsx @@ -13,7 +13,7 @@ interface Props { const Dashboard: React.FC = ({ repoData,setRepoData }) => { if (!repoData) { - return {})} />; + return {})} message="Please analyze a repository first to get started." />; } const handleNewIntegration = () => { diff --git a/frontend/src/components/landing/LandingPage.tsx b/frontend/src/components/landing/LandingPage.tsx index f583279b..e015fe7c 100644 --- a/frontend/src/components/landing/LandingPage.tsx +++ b/frontend/src/components/landing/LandingPage.tsx @@ -9,7 +9,7 @@ interface Props { message: string; } -const LandingPage: React.FC = ({ setRepoData, message }) => { +const LandingPage: React.FC = ({ setRepoData, message="Enter a GitHub repository URL to analyze its stats." }) => { const safeSetRepoData = setRepoData ?? (() => {}); const [repoUrl, setRepoUrl] = useState(''); const [loading, setLoading] = useState(false); @@ -42,7 +42,7 @@ const LandingPage: React.FC = ({ setRepoData, message }) => { >

Welcome to Devr.AI

-

Enter a GitHub repository URL to analyze its stats.

+

{message}

= ({ repoData, setRepoData }) => { if (!repoData) { - return {})} />; + return {})} message='Please analyze a repository first to get started.' />; } if (!repoData.pull_requests) { return ( diff --git a/frontend/src/components/pages/PullRequestsPage.tsx b/frontend/src/components/pages/PullRequestsPage.tsx index 7d56dd97..764cc39a 100644 --- a/frontend/src/components/pages/PullRequestsPage.tsx +++ b/frontend/src/components/pages/PullRequestsPage.tsx @@ -23,7 +23,7 @@ interface Props { const PullRequestsPage: React.FC = ({ repoData, setRepoData }) => { if (!repoData) { - return {})} />; + return {})} message='Please analyze a repository first to get started.' />; } if (!repoData.pull_requests) { return
No data available for pull requests. Please analyze a repository first.
;