Skip to content
MllkmohaPublic

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

227 Commits

Folders and files

Repository files navigation

🚀 LeadFlow

The High-Performance CRM for Modern Sales Pipelines

Documentation • Report Bug • Request Feature

Next.js 16 TypeScript PostgreSQL Prisma Tailwind CSS


LeadFlow is a production-grade CRM designed to eliminate the chaos of lead management. Built with a focus on speed, type-safety, and an elite user experience, it transforms the way you track customer journeys from discovery to conversion 10/10.


🖼️ Project Preview

Dashboard

LeadFlow CRM Dashboard

Live Demo

LeadFlow CRM Demo


🎯 The Solution

Most CRMs are either too simple (spreadsheets) or too bloated (Enterprise software). LeadFlow hits the sweet spot:

  • Centralized Intelligence: Stop hunting for emails across threads. Every note and activity is linked to a single contact.
  • Visual Momentum: The Kanban pipeline makes it immediately obvious where leads are stalling and where the wins are.
  • Zero-Latency UX: By leveraging Next.js Server Components and TanStack Query, the app feels instantaneous.

✨ Professional Feature Set

Feature Engineering Implementation Business Value
Sales Pipeline Four-stage Kanban board with drag-and-drop using @dnd-kit/core Visualize the sales funnel at a glance.
Contact CRM Full CRUD with Zod-validated API route handlers Maintain a clean, high-integrity lead database.
Interaction Log One-to-many relationship: Contacts $\rightarrow$ Activities/Notes Never forget a detail from a client call.
Secure Auth GitHub OAuth $\rightarrow$ JWT Session $\rightarrow$ DB Sync Enterprise-grade security with zero-friction login.
Adaptive UI Tailwind 4 + shadcn/ui + Motion Professional look that works on mobile and desktop.

Dashboard

The dashboard displays key metrics and recent activity:

  • Activity/Contact Statistics: PostgreSQL raw SQL aggregates count records by stage and type.
  • Pipeline Counts: Derived in JavaScript from the contact stage aggregates, applying business logic for display.
  • Recent Records: Fetched with Prisma findMany queries, ordered by updated timestamps.

🏗️ Technical Architecture

System Design

LeadFlow utilizes a layered architecture to ensure scalability and maintainability:

graph TD
    A[Client Browser] -->|Request| B[Next.js App Router]
    B -->|SSR/RSC| C[Server Components]
    B -->|API Call| D[Next.js API Routes]
    C -->|Query| E[Prisma ORM]
    D -->|Query| E
    E -->|SQL| F[(PostgreSQL)]
    B -->|Identity| G[NextAuth.js / GitHub OAuth]
Loading

Engineering Decisions

  • Server Components (RSC): Used for the majority of the app to reduce the JavaScript bundle sent to the client, resulting in the 96 Performance score.
  • Prisma Projection: Instead of findMany(), I implement select blocks to fetch only necessary columns, reducing database I/O.
  • Zod Validation: Every entry point (API/Form) is guarded by Zod schemas to prevent data corruption.
  • Optimistic Updates: Leverages TanStack Query to make the UI feel instant even before the database confirms the change.

📂 Repository Blueprint

src/
├── app/
│   ├── (auth)/login/             # OAuth sign-in page and buttons
│   ├── (dashboard)/               # Authenticated application shell and pages
│   │   ├── dashboard/             # Stats, recent contacts, pipeline overview
│   │   ├── contacts/              # List, create, detail, edit, notes, delete
│   │   ├── pipeline/              # Drag-and-drop stage board
│   │   ├── activities/            # List, create, edit, complete, delete
│   │   └── settings/              # Profile name, theme, CSV export
│   ├── api/                       # Route handlers (JSON and CSV)
│   ├── actions/
│   │   └── auth.ts                # Only server action: sign out
│   ├── privacy/                   # Public privacy policy
│   ├── terms/                     # Public terms of service
│   ├── page.tsx                   # Public landing page
│   ├── layout.tsx                 # Fonts, providers, analytics
│   └── globals.css                # Tailwind 4 import + Deal Ledger tokens
├── components/
│   ├── dashboard/                 # StatCard, RecentContacts, PipelineOverview
│   ├── layout/                    # Sidebar, Header, BottomNav, CommandPalette
│   ├── legal/                     # LegalPageLayout
│   ├── ui/                        # Button, Card primitives
│   ├── delete-button.tsx          # Shared confirmation dialog
│   ├── providers.tsx              # Theme + React Query providers
│   ├── reveal.tsx                 # Motion reveal wrapper
│   └── theme-toggle.tsx           # Light/dark toggle
├── lib/
│   ├── prisma.ts                  # Prisma client + pg adapter + SSL
│   ├── validations/               # Zod schemas for contacts and activities
│   ├── csv.ts                     # CSV escaping and formula neutralization
│   ├── pagination.ts              # Page clamping helper
│   └── avatar.ts                  # Deterministic gradient selection
├── proxy.ts                       # Next.js 16 proxy: CSP nonce and headers
└── auth.ts                        # OAuth configuration

🚀 Setup & Deployment

Local Environment

  1. Clone & Install

    git clone https://github.com/Mllkmoha/LeadFlow.git
    cd LeadFlow/app
    npm install
  2. Configure .env

    DATABASE_URL="postgresql://USER:PASSWORD@HOST:5432/DB"
    AUTH_SECRET="generate with: npx auth secret"
    AUTH_GITHUB_ID=""
    AUTH_GITHUB_SECRET=""
    AUTH_GOOGLE_ID=""
    AUTH_GOOGLE_SECRET=""
  3. Sync Database

    • Development: Run npx prisma migrate dev to create and apply migrations during local development.
    • Production: Run npx prisma migrate deploy to apply committed migrations to a production database.
    • The repository contains prisma/migrations/0001_baseline.
    • Warning: Do not blindly run production migrations on a non-empty database until you have verified its migration history and baseline status.
  4. Launch

    npm run dev

📊 Roadmap

  • Automated Follow-ups: System-generated reminders for overdue activities.
  • Advanced Reporting: Conversion rate analytics and lead-velocity tracking.
  • CSV Import: Bulk import for enterprise data migration.
  • CSV Export: Contacts and activities export from Settings (notes excluded).

👨‍💻 The Engineer

Mohamed Rafik Mellouk Junior Full-Stack Web Developer

I specialize in building high-performance, type-safe web applications. LeadFlow is a testament to my commitment to performance engineering, accessibility, and clean architecture.

GitHub LinkedIn Portfolio

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages