Invoice Manager is based on the dashboard application from the official Next.js Learn course, which I extended with my own additions (listed below). It handles the invoice lifecycle (create, edit, track, and manage customers) with authentication, server-side streaming, pagination, and Zod validation. I built it to understand how Next.js handles data: server actions, dynamic rendering, and direct database queries.
My Additions
Customers Page: Wired up the customers page with search, showing each customer's invoice count and pending and paid totals.
Revenue From Real Invoices: The revenue chart sums paid invoices by month in SQL (GROUP BY month) instead of reading a static revenue table.
Client-Side Validation on Edit: A Zod check on the invoice amount runs in the edit form before it submits, on top of the server-side validation.
Rebranding: Invoice Manager name and logo, a landing page with a dashboard screenshot, and page metadata.
Vercel Analytics on the dashboard.
Key Features
Comprehensive CRUD Operations: Supports the creation, updating, and deletion of invoices with a user-friendly interface and robust backend logic.
Search and Pagination: Server-side search and pagination driven by URL search params, so results are shareable and bookmarkable.
Authentication: NextAuth credentials sign-in with bcrypt-hashed passwords; signed-out users are redirected away from the dashboard.
Data Validation: Utilizes Zod for client-side and server-side validation, ensuring data integrity.
Responsive Design: Built with TailwindCSS for adaptability across devices, offering a consistent user experience.
Technologies Used
TypeScript and React.js: Powers the frontend with a type-safe and interactive user experience.
Next.js: Facilitates server-side rendering and dynamic content generation, enhancing performance and scalability.
PostgreSQL: Serves as the reliable database solution for storing and managing invoice data.
NextAuth: Credentials-based authentication.
TailwindCSS: Ensures a clean, responsive, and aesthetically pleasing design.
Zod: Provides robust schema-based validation for data integrity.
Challenges and Solutions
Handling Data Relationships
Invoices belong to customers, so most screens join the two tables. I wrote those queries directly in SQL, with joins and aggregates (SUM, COUNT, GROUP BY), through @vercel/postgres.
Maintainability
The code is split into data fetching (app/lib/data.ts), server actions (app/lib/actions.ts), and UI components (app/ui), which keeps changes local and simplifies debugging.
Security Concerns
Given the sensitive nature of financial data, sign-in uses NextAuth with the credentials provider. Credentials are validated with Zod before the user lookup, passwords are stored as bcrypt hashes and checked with bcrypt.compare, and middleware keeps signed-out users out of the dashboard.