Next.js API routes with MySQL and HubSpot integration for managing contacts, tasks, and team collaboration.
-
Contact Management
- Sync contacts with HubSpot
- Track contact interactions
- Manage contact details and history
- Automated contact updates
-
Task Management
- Create and assign tasks
- Track task progress
- Set deadlines and priorities
- Task notifications
-
Team Collaboration
- Team member management
- Role-based access control
- Activity tracking
- Team performance metrics
-
HubSpot Integration
- Two-way contact sync
- Deal tracking
- Email integration
- Contact activity logging
- Install dependencies:
npm install
- Create
.env
file:
# Database Configuration
MYSQL_HOST=localhost
MYSQL_USER=root
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=contact_pipeline
# HubSpot Configuration
HUBSPOT_API_KEY=your_hubspot_api_key
HUBSPOT_CLIENT_ID=your_client_id
HUBSPOT_CLIENT_SECRET=your_client_secret
# Authentication
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=7d
# Email (Optional)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your_email@gmail.com
SMTP_PASS=your_app_password
- Initialize Database:
# Run Prisma migrations
npx prisma migrate dev
# Seed initial data (optional)
npx prisma db seed
- Start server:
npm run dev
POST /api/auth/register
- Register new user with email verificationPOST /api/auth/login
- User login with JWT tokenPOST /api/auth/logout
- Invalidate JWT tokenGET /api/auth/me
- Get current user profile
GET /api/contacts
- Get all contacts with paginationPOST /api/contacts
- Create new contactPUT /api/contacts/:id
- Update contact detailsDELETE /api/contacts/:id
- Delete contactPOST /api/contacts/sync
- Sync contacts with HubSpotGET /api/contacts/:id/activities
- Get contact activity history
GET /api/tasks
- Get all tasks with filtersPOST /api/tasks
- Create new taskPUT /api/tasks/:id
- Update task status/detailsDELETE /api/tasks/:id
- Delete taskGET /api/tasks/assigned
- Get assigned tasksGET /api/tasks/created
- Get created tasks
GET /api/team
- Get all team membersPOST /api/team
- Add new team memberPUT /api/team/:id
- Update team member role/statusDELETE /api/team/:id
- Remove team memberGET /api/team/stats
- Get team performance stats
GET /api/settings
- Get user settingsPUT /api/settings
- Update user preferencesPOST /api/settings/validatepassword
- Validate passwordPUT /api/settings/hubspot
- Update HubSpot integration settings
- Framework: Next.js
- Database: MySQL with Prisma ORM
- Authentication: JWT with refresh tokens
- Integration: HubSpot API
- Email: Nodemailer with SMTP
- Validation: Zod
- Testing: Jest & Supertest
- API routes are in
/pages/api
- Database schema in
/prisma/schema.prisma
- HubSpot integration in
/lib/hubspot
- Authentication in
/lib/auth
- Types in
/types
- Build the application:
npm run build
- Start production server:
npm start
- For database migrations in production:
npx prisma migrate deploy