import { prisma } from '@tpmjs/db'; import { Badge } from '@tpmjs/ui/Badge/Badge'; import { Button } from '@tpmjs/ui/Button/Button'; import { Container } from '@tpmjs/ui/Container/Container'; import Link from 'next/link'; import { AppHeader } from '../components/AppHeader'; import { HeroSection } from '../components/home/HeroSection'; async function getHomePageData() { try { // Fetch stats in parallel const [packageCount, toolCount, featuredTools, categoryStats] = await Promise.all([ // Total package count prisma.package.count(), // Total tool count prisma.tool.count(), // Top 6 featured tools by quality score prisma.tool.findMany({ orderBy: [{ qualityScore: 'desc' }, { package: { npmDownloadsLastMonth: 'desc' } }], take: 6, select: { id: true, exportName: true, description: true, qualityScore: true, package: { select: { npmPackageName: true, category: true, npmDownloadsLastMonth: true, isOfficial: true, }, }, }, }), // Category distribution for stats (group by package category) prisma.package.groupBy({ by: ['category'], _count: { _all: true, }, }), ]); return { stats: { packageCount, toolCount, categoryCount: categoryStats.length, }, featuredTools, categories: categoryStats.slice(0, 5).map((c) => ({ name: c.category, count: c._count._all, })), }; } catch (error) { console.error('Failed to fetch homepage data:', error); return { stats: { packageCount: 0, toolCount: 0, categoryCount: 0, }, featuredTools: [], categories: [], }; } } export default async function HomePage(): Promise { const data = await getHomePageData(); return (
{/* Hero Section - Dithered Design */} {/* Featured Tools Section */}

Featured Tools

Top-rated tools from our registry. Sorted by quality score and community adoption.

{data.featuredTools.length > 0 ? (
{data.featuredTools.map((tool) => (

{tool.package.npmPackageName} ({tool.exportName})

{tool.package.isOfficial && ( Official )}

{tool.description}

{tool.package.category}
Quality:{' '} {tool.qualityScore ? Number(tool.qualityScore).toFixed(2) : 'N/A'} {tool.package.npmDownloadsLastMonth?.toLocaleString() || '0'} downloads/mo
))}
) : (

No tools available yet. Check back soon!

)}
{/* Publish Your Tool Section */}

Publish Your AI Tool

Share your tool with the AI community. Automatic discovery, quality scoring, and seamless integration with popular AI frameworks.

🚀

Quick Setup

Add one keyword to package.json and publish to NPM

âš¡

Auto Discovery

Your tool appears on tpmjs.com within 15 minutes

📊

Quality Metrics

Automatic scoring based on docs, downloads, and stars

{/* Footer */}
); }