How ajliy97/ferrelect works
Project type and purpose
• This is a full-stack Next.js application (React on the front end + serverless backend API routes) that uses Tailwind CSS for styling and MongoDB for data persistence.
• It was scaffolded with create-next-app and is intended to render pages at the "/" route and serve a simple cards API at "/api/cards."
File structure
• Top-level directories:
• app/ – Next.js App Router pages and layout
• components/ – React UI components (Card, Navbar, Contact form, etc.)
• pages/api/ – Next.js API route(s), specifically cards.ts to CRUD cards
• lib/ – database utility (mongo.ts for MongoDB connection)
• public/ – static assets (including public/db folder)
• Configuration files:
• next.config.ts – Next.js config
• tsconfig.json – TypeScript config
• tailwind.config.js & postcss.config.mjs – Tailwind CSS setup
• eslint.config.mjs – linting rules
README
• Confirms it’s a Next.js project, describes how to run locally and deploy on Vercel.
Main components and relationships
a. Frontend layer (Next.js App Router)
• app/layout.tsx: global layout + globals.css
• app/page.tsx: home page
• components/: reusable UI (Card, Navbar, MobileNavbar, Contact)
• Styling: Tailwind via tailwind.config.js, global CSS in app/globals.css
b. API layer (Next.js Serverless Functions)
• pages/api/cards.ts: handles HTTP requests (GET/POST) for card data
c. Data layer (MongoDB)
• lib/mongo.ts: MongoClient wrapper, connects to a MongoDB instance
• public/db: (if used for a local JSON store or seed)
d. Deployment/Hosting
• Vercel (implied from README) runs both the frontend and serverless functions
e. External services
• next/font (Geist) for font optimization
• MongoDB Atlas (or self-hosted) for data persistence
Architectural patterns and design principles
• Separation of concerns: UI components vs. page-level routing vs. API routes vs. database logic
• Serverless pattern: Next.js API routes deployed as serverless functions
• App Router (file-based routing)
• CSS utility-first (Tailwind)
• Connection pooling and reuse in lib/mongo.ts