The live demo provides:
- Read-only access
- Seeded demo data
- No sign-up required
- Project Overview
- Features
- Screenshots
- Technology Stack
- Architecture Overview
- Folder Structure
- Installation
- Environment Variables
- Database Setup
- Running Locally
- Running Tests
- Deployment
- API Documentation
- Security Notes
- Performance Considerations
- Contributing Guidelines
- License
Client Tracker is a CRM-style application built for freelancers and small consultancies to manage leads, track deals, monitor revenue, and manage subscription billing from a single dashboard.
The application provides:
- Lead management
- Deal tracking
- Revenue analytics
- Role-based access control
- OAuth authentication
- Stripe subscription billing (test mode)
A public demo mode allows prospective users to explore the application using seeded read-only data without authentication.
- Full CRUD operations for leads
- Full CRUD operations for deals
- NextAuth authentication
- Google OAuth
- GitHub OAuth
- Database session strategy
Two application roles are supported.
- Full CRUD access
- View analytics
- Manage billing and subscriptions
- Read-only access
- View analytics
- Cannot modify data
- Cannot manage billing
- The first authenticated user becomes the
owner. - Subsequent users are assigned the
viewerrole.
| Action | Owner | Viewer |
|---|---|---|
| View leads | ✅ | ✅ |
| Create or edit leads | ✅ | ❌ |
| View deals | ✅ | ✅ |
| Create or edit deals | ✅ | ❌ |
| View analytics | ✅ | ✅ |
| Manage billing | ✅ | ❌ |
- Search
- Filtering
Supports a read-only demonstration mode.
Characteristics:
- OAuth disabled
- Seeded demo account
- Read-only UI
- No registration required
Configuration:
NEXT_PUBLIC_DEMO_MODE=true
ENABLE_OAUTH=falseStripe integration
Plans:
- Free
- Pro
Business rules:
- Free plan limits the number of deals
- Existing deals remain accessible
- Billing management restricted to Owners
Server-side aggregated analytics including:
- Total leads
- Total deals
- Won deals
- Lost deals
- Total revenue
- Next.js (App Router)
- React
- TypeScript
- Tailwind CSS
- shadcn/ui
- Next.js Server Components
- Next.js API Routes
- PostgreSQL
- Prisma ORM
- Neon
- NextAuth
- Prisma Adapter
- Google OAuth
- GitHub OAuth
- Stripe
- Jest
Browser
│
▼
Next.js App Router
│
├── Server Components
├── API Routes
│
▼
Prisma ORM
│
▼
PostgreSQL (Neon)
Authentication is handled by NextAuth.
Business metrics are calculated server-side using database aggregation queries.
Stripe is used for subscription billing.
The project is organized into the following major directories:
client-tracker/
│
├── tests/
├── app/
│ └── api
│ ├── auth
│ └── stripe
├── components/
├── lib/
├── prisma/
│ ├── schema.prisma
│ └── seed.ts
├── public/
│
├── types/
├── screenshots/
├── .env.example
├── package.json
└── README.md
Clone the repository:
git clone https://github.com/dnmore/client-tracker.gitNavigate into the project:
cd client-trackerInstall dependencies:
pnpm installCopy the example environment file.
cp .env.example .envPopulate all required values defined in:
.env.example
Demo Mode:
NEXT_PUBLIC_DEMO_MODE=true
ENABLE_OAUTH=falseFull Application:
NEXT_PUBLIC_DEMO_MODE=false
ENABLE_OAUTH=trueWhen Full Mode is enabled, OAuth providers must also be configured.
Run database migrations:
pnpm prisma migrate devSeed the database:
pnpm dlx prisma db seedWhen running Demo Mode, ensure the seeded demo user defined in:
prisma/seed.ts
has been created before starting the application.
Start the development server:
pnpm devApplication URL:
http://localhost:3000
The project uses Jest.
Current coverage includes:
- Landing page
- Dashboard page
- Validation
- Error handling
- Demo mode behavior
- Full mode behavior
Tests for:
verifySession- Authenticated session handling
- Redirect behavior when unauthenticated
Run the test suite:
pnpm testThe application is deployed on Vercel.
Typical deployment workflow:
- Push the repository to your Git provider.
- Import the project into Vercel.
- Configure all required environment variables.
- Deploy.
External services that must be configured:
- Neon Database
- Google OAuth
- GitHub OAuth
- Stripe
The application exposes API routes for authentication and Stripe payment processing.
The project exposes API routes under:
app/api/
/api/auth/[...nextauth]
Handles authentication using NextAuth with GitHub and Google OAuth.
/api/stripe/checkout
Handles Stripe checkout session
/api/stripe/webhook
Handles Stripe webhook events
Supported events:
checkout.session.completed- Updates the corresponding user plan from FREE to PRO.
customer.subscription.deleted- Updates the corresponding user plan from PRO to FREE.
/api/stripe/portal
Handles Stripe Customer Portal sessions, allowing users to manage their subscription.
Authentication is implemented using:
- NextAuth
- OAuth providers
- Database session strategy
Authorization is enforced through role-based access control (RBAC) with two roles:
- Owner
- Viewer
Demo Mode disables OAuth and exposes only seeded read-only data.
The application incorporates several performance optimizations:
- Uses
unstable_cacheto cache database queries powering the admin dashboard analytics and data tables.
- Uses
revalidateTagto invalidate cached data associated with specific cache tags. - Uses
revalidatePaththroughout admin server actions to refresh affected routes after data mutations.
- Implements a dedicated
loading.tsxwith an animated loader for the dashboard routes.
Contributions are welcome.
Please:
- Open an issue for bugs or feature requests.
- Fork the repository.
- Create a feature branch.
- Submit a pull request describing your changes.
Please ensure all existing tests continue to pass before submitting a pull request.
This project is licensed under the MIT License.