A modern Next.js application for Ebrora, converting the existing static HTML site to a dynamic platform with a RAMS (Risk Assessment Method Statements) builder powered by OpenAI.
- Stack: Next.js 14+ (App Router), TypeScript, React 18
- Database: PostgreSQL (Supabase or Neon) with Prisma ORM
- Authentication: NextAuth.js with Googleh OAuth + email/password
- AI: OpenAI API for intelligent RAMS document generation
- Deployment: Vercel (London region)
- Styling: Custom CSS with Ebrora brand colors and typography
- Node.js 18.17.0 or higher
- npm or yarn package manager
- PostgreSQL database (Supabase or Neon recommended)
- Google OAuth credentials
- OpenAI API key (for RAMS Builder)
-
Clone the repository
git clone https://github.com/your-org/ebrora.git cd ebrora -
Install dependencies
npm install
-
Setup environment variables
cp .env.example .env.local
Fill in all required values in
.env.local:- Database connection string
- NextAuth credentials (generate with
openssl rand -base64 32) - Google OAuth credentials
- OpenAI API key
- Email configuration (SMTP)
- PayPal credentials
- Mailchimp API key
-
Setup Prisma
npm run prisma:generate npm run prisma:migrate npm run prisma:seed # Optional: populate test data -
Run development server
npm run dev
-
Type checking
npm run type-check
All environment variables must be set in .env.local. See .env.example for all available options.
DATABASE_URL- PostgreSQL connection stringNEXTAUTH_URL- NextAuth callback URLNEXTAUTH_SECRET- Generated secret key for NextAuthGOOGLE_CLIENT_ID- Google OAuth Client IDGOOGLE_CLIENT_SECRET- Google OAuth Client Secret
OPENAI_API_KEY- For RAMS Builder functionalityBLOB_READ_WRITE_TOKEN- Vercel Blob storage token for RAMS document uploads (create via Vercel Dashboard > Storage > Blob)OPENAI_MODEL- OpenAI model (default: gpt-4-turbo)SMTP_*- Email configurationPAYPAL_*- PayPal integrationMAILCHIMP_*- Newsletter integrationGA_MEASUREMENT_ID- Google Analytics (default: G-ZVPRYV7LNX)
- Create a new Postgres project at supabase.com
- Copy the connection string from the Supabase dashboard
- Set
DATABASE_URLin.env.local - Run migrations:
npm run prisma:migrate
- Create a new database at neon.tech
- Copy the connection string
- Set
DATABASE_URLin.env.local - Run migrations:
npm run prisma:migrate
- Install PostgreSQL locally
- Create a database:
createdb ebrora - Set
DATABASE_URL="postgresql://user:password@localhost:5432/ebrora" - Run migrations:
npm run prisma:migrate
# Generate Prisma client
npm run prisma:generate
# Create and run migrations
npm run prisma:migrate
# Reset database (development only)
npx prisma migrate reset
# Seed database with test data
npm run prisma:seed
# Open Prisma Studio (visual database explorer)
npx prisma studionpm run build
npm start- Push code to GitHub
- Connect repository to Vercel
- Set all environment variables in Vercel project settings
- Deploy from
mainbranch automatically
npm install -g vercel
vercelFollow the prompts to connect your project.
- All environment variables set in Vercel
- Database migrations applied
- Build succeeds locally and on Vercel
- Test authentication flows
- Verify API routes work
- Check analytics integration
- Test email notifications
- Verify RAMS Builder functionality
- Test PayPal integration (staging)
- Newsletter signup working
/
├── app/ # Next.js App Router
│ ├── (auth)/ # Authentication pages (login, signup)
│ ├── (admin)/ # Admin dashboard
│ ├── api/ # API routes
│ │ ├── auth/ # NextAuth configuration
│ │ ├── products/ # Product API endpoints
│ │ ├── rams/ # RAMS Builder API
│ │ ├── contact/ # Contact form API
│ │ ├── newsletter/ # Newsletter subscription
│ │ └── cron/ # Scheduled cron jobs
│ ├── products/ # Product pages
│ ├── rams/ # RAMS Builder pages
│ ├── blog/ # Blog pages (MDX)
│ ├── layout.tsx # Root layout
│ └── page.tsx # Home page
│
├── components/ # React components
│ ├── ui/ # Reusable UI components
│ ├── forms/ # Form components
│ ├── navigation/ # Navigation components
│ └── ...
│
├── lib/ # Utility functions
│ ├── auth.ts # NextAuth configuration
│ ├── db.ts # Prisma client
│ ├── email.ts # Email utilities
│ ├── openai.ts # OpenAI API wrapper
│ ├── stripe.ts # Payment processing
│ └── ...
│
├── prisma/ # Database schema
│ ├── schema.prisma # Schema definition
│ └── migrations/ # Migration files
│
├── public/ # Static assets
│ ├── images/
│ ├── fonts/
│ └── ...
│
├── styles/ # Global styles
│ ├── globals.css # Global styles
│ ├── variables.css # CSS variables
│ └── ...
│
├── types/ # TypeScript types
│ └── index.ts # Type definitions
│
├── .env.example # Environment variables template
├── .gitignore # Git ignore rules
├── next.config.mjs # Next.js configuration
├── package.json # Dependencies
├── postcss.config.js # PostCSS configuration
├── tsconfig.json # TypeScript configuration
├── vercel.json # Vercel deployment config
└── README.md # This file
- Primary Green:
#1B5745 - Secondary Green:
#1B5B50 - Gold/Accent:
#D4A44C - Text: Dark gray/black for body text
- Background: White/light gray
- Body: DM Sans
- Headings: Playfair Display
- AI-powered document generation using OpenAI
- Interactive form-based RAMS creation
- PDF export functionality
- Save and edit existing RAMs documents
- Product catalog with detailed descriptions
- Dynamic pricing and availability
- Shopping cart and checkout
- PayPal integration for payments
- Google OAuth login
- Email/password registration
- Password reset functionality
- User profile management
- Mailchimp integration
- Subscription forms across the site
- Campaign management
- Product management
- User management
- Order tracking
- Analytics and reporting
- MDX-based blog posts
- Search functionality
- Category filtering
- Related posts
POST /api/auth/signin- Sign inPOST /api/auth/signup- Sign upPOST /api/auth/forgot-password- Request password resetPOST /api/auth/reset-password- Reset password
GET /api/products- Get all productsGET /api/products/[id]- Get product by IDPOST /api/products- Create product (admin)PUT /api/products/[id]- Update product (admin)DELETE /api/products/[id]- Delete product (admin)
POST /api/rams/generate- Generate RAMS documentGET /api/rams/[id]- Get RAMS documentPOST /api/rams/[id]/export- Export as PDF
POST /api/contact- Submit contact form
POST /api/newsletter/subscribe- Subscribe to newsletter
GET /api/cron/cleanup- 12-hour cleanup job
# Run tests
npm test
# Run tests in watch mode
npm test -- --watch
# Generate coverage report
npm test -- --coveragenpm run dev # Start development server
npm run build # Build for production
npm start # Start production server
npm run lint # Run ESLint
npm run type-check # Run TypeScript type checker
npm run prisma:generate # Generate Prisma client
npm run prisma:migrate # Run database migrations
npm run prisma:seed # Seed database with initial data- Verify
DATABASE_URLis correct - Check database server is running
- Ensure network access is allowed for remote databases
- Try connecting with a database client to verify connectivity
NEXTAUTH_SECRETis required and must be uniqueNEXTAUTH_URLmust match deployment URL exactly- Clear cookies if authentication isn't working
- Run
npm installto ensure all dependencies are installed - Check for TypeScript errors with
npm run type-check - Verify all environment variables are set
- Clear
.nextfolder and rebuild
- Verify SMTP credentials are correct
- Check email logs in Vercel
- Test with a simple email first
- For Gmail, use app-specific password, not your account password
- Next.js Documentation
- Prisma Documentation
- NextAuth.js Documentation
- OpenAI API Documentation
- Vercel Documentation
- Create a feature branch:
git checkout -b feature/your-feature - Commit changes:
git commit -am 'Add feature' - Push to branch:
git push origin feature/your-feature - Submit a pull request
Copyright © 2024 Ebrora Ltd. All rights reserved.
For issues, questions, or feedback, please contact support@ebrora.com