Objective
Replace spreadsheet tracking of field visits, orders and client loyalty with one platform.
Server-rendered app with role-guarded areas for administrators, field reps, coordinators, retail clients and analysts. A three-step visit form feeds purchase orders, validated orders credit loyalty points, and sales, price and inventory data export as CSV.
Challenges
- 01Five user roles needing different data and permissions in one app
- 02Visit forms must survive page reloads on unreliable mobile connections
- 03Quota progress and sales rollups across zones, SKUs and client tiers
How it was solved
- 01Server-side session and role checks on every protected page and API route
- 02Redux Toolkit state persisted locally across the three visit steps
- 03MongoDB aggregation pipelines scoped by company and zone
Results
- Validated orders credit loyalty points automatically
- Sales, price and inventory data exportable as CSV
Overview
PerfectApp connects field sales reps, coordinators, administrators and retail clients. Each role has a private area behind a public landing page.
Technical Implementation
Access Control
Next.js Pages Router with NextAuth.js credential sessions. Each protected page checks the role in getServerSideProps before loading data; API routes do too.
Multi-Company Data
Each user belongs to a company, which scopes queries and configuration (SKUs, competitors, promotions) within one deployment.
Visit Workflow
Reps record competitor prices with photos, inventory, the purchase order or reason for no purchase, and communication material execution. Photos go to Vercel Blob; submitting stores the visit and a pending order, and a summary is emailed.
Loyalty Points
Points are valued per client tier and SKU. Admins credit them on validation and can double them for clients over their monthly quota.
Features
- Rep dashboard with monthly quota progress
- Coordinator view: quota per rep and purchasing clients
- Client portal with points balance, promotional banners and rewards catalog
- Admin panel: order approval, prospect validation, monthly promotions and messages to reps
Technologies
- Next.js 14
- React
- JavaScript
- MongoDB
- Prisma
- NextAuth.js
- Redux Toolkit
- React Hook Form
- Zod
- Vercel Blob
- Nodemailer
- SCSS Modules
