CountLeaf is a Next.js web application that analyzes webpages and counts their word content. It's built with TypeScript and uses server-side processing to fetch and parse web content.
pnpm run dev- Start development serverpnpm run build- Build for productionpnpm run start- Start production serverpnpm run lint- Run ESLint
Using convex for database
- Frontend: Single-page React application (
src/pages/index.tsx) with form-based URL input and results display - API Layer: Next.js API routes in
src/pages/api/ - Business Logic: Utility functions in
src/lib/actions.ts
src/pages/index.tsx- Main UI component with form, loading states, and results displaysrc/lib/actions.ts- Core word counting logic using Cheerio for HTML parsingsrc/pages/api/webcrawler.ts- API endpoint that fetches HTML content from URLssrc/styles/Home.module.css- Component-specific styling
- User enters URL in frontend form
- Frontend calls
countWordsFromUrl()fromactions.ts - Action function calls
/api/webcrawlerendpoint with URL - API route fetches HTML content from the target URL
- HTML is parsed using Cheerio to extract text content
- Words are counted and result returned to frontend
- cheerio: HTML parsing and manipulation
- axios: HTTP client (installed but not actively used)
- lucide-react: Icon components
- clsx: Conditional CSS class utility
- CSS Modules for component-specific styles
- Custom CSS animations and transitions
- No external CSS framework (previously removed Tailwind CSS)
- Space Mono font family for typography
The application uses TypeScript path aliases (@/* maps to ./src/*) configured in tsconfig.json. The webcrawler API endpoint currently has minimal error handling and could be enhanced for production use.
