Skip to content

Repository files navigation

Next.js TypeScript Tailwind CSS NextAuth License

πŸš€ Partner Flow β€” Referral Partners Platform

A modern referral partner platform built for Aice Tangerang Selatan

Demo Documentation


πŸ“‹ Table of Contents


🎯 Overview

Partner Flow is a comprehensive referral partner platform designed for Aice in the Tangerang Selatan region. Built with Next.js for optimal performance and SEO, it enables businesses to manage their referral programs efficiently through a modern, intuitive interface.

Key Benefits

  • 🎯 Multi-Level Referral System - Partners can earn commissions from their referrals and their referrals' referrals
  • πŸ“Š Real-Time Analytics - Track referrals, commissions, and performance metrics in real-time
  • πŸ” Role-Based Access Control - Separate dashboards for partners and administrators
  • 🌐 Social Media Integration - Easy sharing across multiple platforms
  • πŸ“± Responsive Design - Works seamlessly on desktop, tablet, and mobile devices
  • πŸŒ™ Dark Mode Support - Built-in theme switching for user comfort

✨ Features

For Partners

  • 🏠 Personal Dashboard - View referral statistics, earnings, and performance metrics
  • πŸ”— Referral Link Generation - Unique referral codes for tracking
  • πŸ“€ Social Media Sharing - One-click sharing to Facebook, Twitter, LinkedIn, WhatsApp, and Email
  • πŸ“‹ Referral Tracking - Monitor referral status (pending, approved, rejected)
  • πŸ’° Commission Tracking - View earnings and commission history
  • πŸ“Š Performance Analytics - Detailed statistics on referral performance
  • 🎁 Referral Bonuses - Multi-level commission structure

For Administrators

  • πŸ‘₯ Partner Management - View and manage all registered partners
  • πŸ” Credential Access - View partner login credentials (with toggle)
  • πŸ“ Referral Approval - Approve or reject pending referrals
  • πŸ”„ Referral Conversion - Convert successful referrals to partners
  • πŸ“ˆ Platform Analytics - System-wide statistics and insights
  • πŸŽ›οΈ Activity Monitoring - Track recent platform activity
  • πŸ“Š Data Export - Export partner and referral data

Authentication

  • πŸ”‘ Email/Password Login - Traditional authentication method
  • 🌐 Google OAuth - Sign in with Google account
  • πŸ“ Registration Wizard - Step-by-step onboarding for new users
  • πŸ”’ Secure Sessions - JWT-based session management
  • πŸ›‘οΈ Protected Routes - Route-level access control

πŸ›  Tech Stack

Frontend

Backend Integration

  • Authentication: NextAuth.js 5.0 - Complete authentication solution
  • API: RESTful API integration with backend service
  • State Management: React Hooks and Context API

Development Tools

  • Package Manager: npm/yarn
  • Linting: ESLint
  • Code Formatting: Prettier (recommended)

πŸš€ Getting Started

Prerequisites

  • Node.js 18.x or higher
  • npm or yarn package manager
  • Backend API service running on configured port

Installation

  1. Clone the repository
git clone https://github.com/partner-flow/partner-flow-fe.git
cd partner-flow-fe
  1. Install dependencies
npm install
  1. Configure environment variables
cp .env.example .env

Edit .env file with your configuration:

# App Configuration
NEXT_PUBLIC_APP_URL="http://localhost:3000"
NEXT_PUBLIC_APP_NAME="Partner Flow"

# Backend API
NEXT_PUBLIC_BACKEND_URL="http://localhost:8080"

# Google OAuth (Optional)
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"

# NextAuth Configuration
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-key-here"
  1. Generate NextAuth secret
openssl rand -base64 32
  1. Run development server
npm run dev
  1. Open browser Navigate to http://localhost:3000

βš™οΈ Environment Variables

Variable Description Required Default
NEXT_PUBLIC_APP_URL Frontend application URL Yes http://localhost:3000
NEXT_PUBLIC_APP_NAME Application name Yes Partner Flow
NEXT_PUBLIC_BACKEND_URL Backend API URL Yes http://localhost:8080
GOOGLE_CLIENT_ID Google OAuth Client ID No -
GOOGLE_CLIENT_SECRET Google OAuth Client Secret No -
NEXTAUTH_URL NextAuth URL Yes http://localhost:3000
NEXTAUTH_SECRET NextAuth secret key Yes -

Google OAuth Setup (Optional)

  1. Go to Google Cloud Console
  2. Create a new OAuth 2.0 client ID
  3. Add authorized redirect URIs:
    • http://localhost:3000/api/auth/callback/google
    • https://yourdomain.com/api/auth/callback/google (for production)
  4. Copy Client ID and Client Secret to your .env file

πŸ“ Project Structure

partner-flow-fe/
β”œβ”€β”€ .env.example            # Environment variables template
β”œβ”€β”€ public/                 # Static assets
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                # Next.js App Router
β”‚   β”‚   β”œβ”€β”€ api/           # API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/      # Authentication endpoints
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ login/ # Login endpoint
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ register/ # Registration endpoint
β”‚   β”‚   β”‚   β”‚   └── onboarding/ # Onboarding endpoint
β”‚   β”‚   β”‚   └── partners/  # Partner endpoints
β”‚   β”‚   β”œβ”€β”€ auth/          # Authentication pages
β”‚   β”‚   β”‚   β”œβ”€β”€ login/     # Login page
β”‚   β”‚   β”‚   β”œβ”€β”€ register/  # Registration page
β”‚   β”‚   β”‚   └── onboarding/ # Onboarding wizard
β”‚   β”‚   β”œβ”€β”€ dashboard/     # Dashboard pages
β”‚   β”‚   β”‚   └── page.tsx   # Main dashboard
β”‚   β”‚   └── page.tsx       # Homepage
β”‚   β”œβ”€β”€ components/        # React components
β”‚   β”‚   β”œβ”€β”€ dashboard/     # Dashboard-specific components
β”‚   β”‚   β”‚   β”œβ”€β”€ stats-card.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ referral-tools.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ referrals-table.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ partners-table.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ referral-management.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ partner-dashboard.tsx
β”‚   β”‚   β”‚   └── admin-dashboard.tsx
β”‚   β”‚   β”œβ”€β”€ layouts/       # Layout components
β”‚   β”‚   β”‚   └── navbar.tsx
β”‚   β”‚   β”œβ”€β”€ providers/     # Context providers
β”‚   β”‚   β”‚   └── theme-provider.tsx
β”‚   β”‚   └── ui/            # UI components
β”‚   β”œβ”€β”€ config.ts          # Configuration file
β”‚   β”œβ”€β”€ lib/               # Utility libraries
β”‚   β”‚   └── auth.ts        # NextAuth configuration
β”‚   └── types/             # TypeScript type definitions
β”‚       └── next-auth.d.ts # NextAuth types
β”œβ”€β”€ package.json           # Dependencies
└── README.md             # This file

Note: The .agents folder is located at the parent directory (../.agents) and contains project documentation.

πŸ‘₯ User Roles

Partner Role

Default role for all new registrations

  • Automatically assigned during registration
  • Access to personal dashboard
  • Can create and share referral links
  • Track own referrals and earnings
  • Cannot view other partners' data
  • Cannot approve or reject referrals

Admin Role

Manually assigned by database administrators

  • Full platform access
  • View all partners and their data
  • View all referrals across the platform
  • Approve or reject pending referrals
  • Convert referrals to partners
  • View partner credentials (with toggle)
  • Access system-wide analytics

How to obtain admin role:

  1. Direct database manipulation: UPDATE users SET role = 'admin' WHERE email = '...'
  2. Backend API endpoint (if implemented)
  3. Initial seed data during database setup

Demo Accounts:

  • Partner: partner@example.com / partner123
  • Admin: admin@partnerflow.com / admin123

πŸ” Authentication

Login Methods

  1. Email/Password

    • Traditional authentication
    • Validates against backend API
    • JWT token generation
  2. Google OAuth

    • Sign in with Google account
    • Redirects to onboarding wizard for first-time users
    • Automatic profile creation

Session Management

  • JWT-based authentication
  • Secure session storage
  • Automatic token refresh
  • Session expiration handling

Protected Routes

All dashboard routes require authentication:

useEffect(() => {
  if (status === "unauthenticated") {
    router.push("/auth/login");
  }
}, [status, router]);

πŸ”Œ API Endpoints

Authentication

  • POST /api/auth/login - User login
  • POST /api/auth/register - User registration
  • POST /api/auth/onboarding - Complete onboarding
  • GET /api/auth/session - Get current session

Partners

  • GET /api/partners - Get all partners (admin only)
  • POST /api/partners/onboarding - Complete partner onboarding

Referrals

  • GET /api/referrals?partner_id={id} - Get partner referrals
  • GET /api/referrals - Get all referrals (admin only)
  • PUT /api/referrals/{id} - Update referral status (admin only)

πŸš€ Deployment

Vercel (Recommended)

  1. Push code to GitHub
  2. Import project in Vercel
  3. Configure environment variables
  4. Deploy

Manual Deployment

  1. Build the application
npm run build
  1. Start production server
npm start
  1. Configure reverse proxy (nginx example)
server {
    listen 80;
    server_name yourdomain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow the existing code style
  • Write meaningful commit messages
  • Add tests for new features
  • Update documentation as needed

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ“ž Support

For support, email support@partnerflow.com or open an issue in the repository.


Built with ❀️ for Aice Tangerang Selatan

Back to top

About

A modern referral partner platform built with multi-level referral system, real-time analytics, and role-based access control

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages