Skip to content

dnmore/client-tracker

Repository files navigation

Client Tracker

Next.js React Prisma PostgreSQL Stripe License

Client Tracker is a CRM-style application designed for freelancers and small consultancies to track leads, deals and revenue in one place.

Live Demo

Live Demo

  • No signup required
  • Safe demo environment
  • Read-only access

Table of Contents

Preview

Features

  • Full CRUD for leads and deals
  • Authentication with role-based access control (RBAC)
  • Secure demo environment (no user data required)
  • Server-side analytics and data aggregation
  • Subscription billing with Stripe (test mode)

Tech Stack

Frontend

  • Next.js (App Router)
  • React + TypeScript
  • Tailwind CSS
  • shadcn/ui

Backend / Infrastructure

  • Next.js Server Components & API Routes
  • Prisma ORM
  • PostgreSQL (Neon)
  • NextAuth (OAuth)
  • Stripe (Test Mode)

Authentication

  • NextAuth with Prisma adapter
  • OAuth providers (Google, GitHub)
  • Database session strategy

Authentication Modes

The application supports two distinct modes controlled via environment variables.

Demo Mode

  • OAuth providers disabled
  • Read-only access
  • Uses seeded demo account
NEXT_PUBLIC_DEMO_MODE=true
ENABLE_OAUTH=false

Ensure your demo user email is defined in prisma/seed.ts and seeded before running the app.

pnpm dlx prisma db seed

Full Mode

Enable OAuth providers:

NEXT_PUBLIC_DEMO_MODE=false
ENABLE_OAUTH=true

Role-Based Access Control

The application implements two roles:

OWNER

  • Full CRUD access
  • Access to analytics
  • Manage billing and subscriptions

VIEWER

  • Read-only access
  • Can view analytics
  • Cannot modify data or manage billing

Role Assignment

  • The first authenticated user is assigned the owner role
  • All subsequent users are assigned the viewer role

Permission Matrix

Action Owner Viewer
View leads
Create/edit leads
View deals
Create/edit deals
View analytics
Manage billing

Billing

Billing is implemented using Stripe (test mode).

Plans

Free — limited number of deals
Pro — unlimited deals

Enforcement Rules

  • Deals limit is enforced at creation time
  • Existing deals can always be viewed
  • Billing actions are restricted to Owners only

Analytics

The dashboard provides aggregated insights:

  • Total leads created
  • Total deals created
  • Deals won vs lost
  • Total Revenue

Analytics are computed server-side using database aggregation queries to ensure accuracy and consistency.


Running Locally

  1. Clone the repository and install dependencies
   git clone https://github.com/dnmore/client-tracker.git
   cd client-tracker
  1. Install dependencies
   pnpm install
  1. Environment variables

The application uses environment variables for configuration. Copy the example file .env.example and fill in the required values.

  1. Run database migrations
   pnpm prisma migrate dev
  1. Seed the database
   pnpm dlx prisma db seed
  1. Start the development server
   pnpm dev

The application will be available at:


http://localhost:3000

Contributions

Contributions are welcome. Feel free to open issues or submit pull requests.

License

MIT License

About

Full-stack CRM-style app built with Next.js, Prisma and PostgreSQL featuring OAuth authentication, RBAC, analytics , Stripe subscription billing. and Demo Mode.

Topics

Resources

Stars

Watchers

Forks

Contributors