This is a complete Next.js conversion of the Flask/Python voice analysis system. The application provides user authentication via Google Sheets, client registration forms, and audio recording capabilities.
- π Email Authentication: Users login with email verified against Google Sheets
- π Client Registration Form: Comprehensive form collecting personal information and physical measurements
- ποΈ Audio Recording: 10-second voice recording with WAV conversion (4.1kHz, stereo, 16-bit)
- π Session Management: Secure session handling with automatic logout
- π Google Sheets Integration: Email verification and access control
- π¨ Modern UI: Beautiful gradient designs with smooth animations
- π± Responsive Design: Works perfectly on all devices
- Framework: Next.js 14+ (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- Session: iron-session
- Google API: googleapis
- Audio: Web Audio API
- Node.js 18+ and npm
- Google Cloud Platform project with Sheets API enabled
- Service account credentials for Google Sheets
- Backend API server (for processing submissions)
- Clone or navigate to the project directory
cd nextjs-app- Install dependencies
npm install- Configure Environment Variables
Create a .env.local file in the root directory:
# Backend API URL
NEXT_PUBLIC_BACKEND_URL=http://localhost:5001
# Google Sheets Configuration
SPREADSHEET_ID=your_spreadsheet_id_here
CREDENTIALS_JSON={"type":"service_account","project_id":"..."}
# Session Configuration (must be at least 32 characters)
SESSION_PASSWORD=your_complex_password_at_least_32_characters_longRefer to ENV_SETUP.md for detailed environment setup instructions.
npm run devThe application will be available at http://localhost:3000
npm run build
npm startnextjs-app/
βββ src/
β βββ app/
β β βββ api/
β β β βββ login/route.ts # Login API endpoint
β β β βββ logout/route.ts # Logout API endpoint
β β β βββ session/route.ts # Session check endpoint
β β β βββ upload-audio/route.ts # Audio upload endpoint
β β βββ login/
β β β βββ page.tsx # Login page
β β βββ thank-you/
β β β βββ page.tsx # Thank you page
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Main registration form
β β βββ globals.css # Global styles
β βββ lib/
β βββ audioRecorder.ts # Audio recording utility
β βββ googleSheets.ts # Google Sheets integration
β βββ session.ts # Session configuration
βββ public/
β βββ uploads/ # Uploaded audio files
βββ .env.local # Environment variables (not in git)
βββ ENV_SETUP.md # Environment setup guide
βββ package.json
- Login: User enters email β Verified against Google Sheets β Session created
- Registration: Authenticated user fills form β Records 10-second audio
- Submission: Audio uploaded to server β Data sent to backend API
- Completion: Redirect to thank you page β Auto-logout after 3 seconds
Your Google Sheet should have the following columns:
Name: User's full nameEmail: User's email addressDate: Registration/purchase dateExpire: Access status (TRUE = expired, FALSE = active)
GET /- Main registration form (requires authentication)GET /login- Login pageGET /thank-you- Thank you pagePOST /api/login- Login authenticationGET /api/logout- Logout and clear sessionGET /api/session- Check authentication statusPOST /api/upload-audio- Upload recorded audio
The application sends client data to the backend server at:
POST ${NEXT_PUBLIC_BACKEND_URL}/submit-client
- Sample Rate: 4100 Hz (4.1 kHz)
- Channels: 2 (Stereo)
- Bit Depth: 16-bit
- Duration: 10 seconds
- Format: WAV (converted from WebM)
- Session-based authentication with encrypted cookies
- HTTP-only cookies for session security
- Environment-based configuration
- Input validation on all forms
- Secure session expiration (1 hour)
- Ensure HTTPS in production (required for microphone access)
- Check browser permissions for microphone
- Try different browsers (Chrome, Firefox, Safari)
- Verify Google Sheets credentials in
.env.local - Check spreadsheet ID is correct
- Ensure service account has access to the sheet
- Check
public/uploads/directory permissions - Verify backend URL is correct
- Check network connectivity
The Python Flask application has been fully converted to Next.js:
| Flask Feature | Next.js Equivalent |
|---|---|
| Flask Routes | Next.js App Router API Routes |
| Jinja2 Templates | React Components (TSX) |
| Flask Sessions | iron-session |
| Python gspread | googleapis (Node.js) |
| Flask static files | Next.js public directory |
| Python audio processing | Web Audio API (client-side) |
Create a new directory in src/app/ with a page.tsx file:
export default function NewPage() {
return <div>New Page Content</div>;
}Create a new route.ts file in src/app/api/your-endpoint/:
import { NextRequest, NextResponse } from 'next/server';
export async function GET(request: NextRequest) {
return NextResponse.json({ message: 'Hello' });
}This project is part of the Voice Analysis System.
For issues or questions:
- Check the troubleshooting section
- Review environment configuration
- Check browser console for errors
- Verify backend server is running