A modern, full-stack authentication starter built with Vite, React, Express, and PostgreSQL. This boilerplate provides a solid foundation for building web applications with complete authentication, user management, and a beautiful, responsive UI.
β¨ Features: Modular landing page components, comprehensive database scripts, automated setup tools, and production-ready authentication!
- Express.js server with ES modules
- PostgreSQL database with Prisma ORM
- JWT-based authentication (access + refresh tokens)
- Password hashing with bcrypt
- Email verification and password reset
- Role-based access control
- Rate limiting and security middleware
- Input validation with express-validator
- Email service with Nodemailer
- React 18 with modern hooks
- Vite for fast development and building
- Material-UI for beautiful, responsive design
- Modular Landing Page with 7 reusable components
- React Router for client-side routing
- TanStack Query for server state management
- React Hook Form with Yup validation
- Axios for API calls with interceptors
- Animated Components with smooth transitions
- ES Modules throughout the codebase
- ESLint configuration for code quality
- Jest for testing
- Concurrently for running dev servers
- Nodemon for server auto-restart
- Comprehensive Database Scripts for setup, seeding, backup/restore
- Automated Setup Tools for quick project initialization
- Sample Data with realistic user accounts and roles
simple-vite-react-express-auth/
βββ src/
β βββ client/ # React frontend
β β βββ public/ # Static assets
β β βββ src/
β β β βββ components/ # Reusable UI components
β β β β βββ landing/ # Modular landing page components
β β β βββ pages/ # Page components
β β β βββ contexts/ # React contexts
β β β βββ utils/ # Utilities and API calls
β β β βββ theme/ # Material-UI theme configuration
β β β βββ App.jsx # Main App component
β β β βββ main.jsx # Entry point
β β βββ index.html # HTML template
β β βββ vite.config.js # Vite configuration
β β
β βββ server/ # Node.js backend
β β βββ config/ # Configuration files
β β βββ controllers/ # Route handlers
β β β βββ auth.controller.js
β β β βββ user.controller.js
β β βββ middleware/ # Custom middleware
β β β βββ auth.middleware.js
β β β βββ errorHandler.middleware.js
β β β βββ notFound.middleware.js
β β βββ routes/ # Express routes
β β βββ services/ # Business logic
β β β βββ auth.service.js
β β β βββ email.service.js
β β βββ app.js # Express app
β β
β βββ shared/ # Shared utilities (if needed)
β
βββ prisma/
β βββ schema.prisma # Database schema
βββ tests/ # Test files
βββ scripts/ # Database and setup scripts
β βββ setup.js # Initial project setup
β βββ db-setup.js # Database configuration
β βββ seed.js # Sample data seeding
β βββ db-migrate.js # Smart migration handling
β βββ db-reset.js # Database reset utility
β βββ db-backup.js # Database backup utility
β βββ db-restore.js # Database restore utility
βββ backups/ # Database backups (auto-created)
βββ .env.example # Environment variables template
βββ package.json # Dependencies and scripts
- Node.js 18+ and npm 9+
- PostgreSQL database
# Clone the repository
git clone <your-repo-url>
cd simple-vite-react-express-auth
# Run automated setup
npm run setup
# Set up database
npm run db:setup
# Seed with sample data
npm run db:seed
# Start development
npm run dev
# Clone and install
git clone <your-repo-url>
cd simple-vite-react-express-auth
npm install
# Environment setup
cp .env.example .env
# Edit .env with your database URL and other settings
# Database setup
npm run db:migrate
npm run db:seed
# Start development
npm run dev
After seeding, you can use these accounts:
- Super Admin:
admin@saasStarter.com
/Admin123!
- Admin:
moderator@saasStarter.com
/Mod123!
- User:
john.doe@example.com
/User123!
The app will be available at:
- Frontend: http://localhost:5173
- Backend: http://localhost:3001
- API Health: http://localhost:3001/health
- Database Studio: Run
npm run db:studio
to open Prisma Studio
# Development
npm run dev # Start both frontend and backend
npm run dev:client # Start only frontend
npm run dev:server # Start only backend
# Building
npm run build # Build frontend for production
npm start # Start production server
# Setup & Database Management
npm run setup # Initial project setup
npm run db:setup # Complete database setup
npm run db:migrate # Smart migration handling
npm run db:migrate:dev # Run Prisma migrate dev
npm run db:migrate:reset # Reset all migrations
npm run db:migrate:status # Check migration status
npm run db:seed # Populate with sample data
npm run db:reset # Reset database and re-seed (β οΈ destructive)
npm run db:backup # Create database backup
npm run db:restore # Restore from backup
npm run db:generate # Generate Prisma client
npm run db:push # Push schema to database
npm run db:studio # Open Prisma Studio
# Testing
npm test # Run all tests
npm run test:watch # Run tests in watch mode
The landing page has been refactored into 7 modular, reusable components:
src/client/src/components/landing/
βββ HeroSection.jsx # Main hero with CTA buttons
βββ StatsSection.jsx # Animated statistics display
βββ FeaturesSection.jsx # Feature cards grid
βββ TestimonialsSection.jsx # Customer testimonials
βββ CTASection.jsx # Call-to-action section
βββ FAQSection.jsx # Frequently asked questions
βββ NewsletterSection.jsx # Email newsletter signup
βββ index.js # Barrel export for clean imports
- Modular Design: Each section is independently editable
- Smooth Animations: Fade-in effects and hover transitions
- Responsive Layout: Mobile-first design with Material-UI breakpoints
- Interactive Elements: Animated counters, expandable FAQs, form validation
- Modern Styling: Gradient backgrounds, glassmorphism effects, and micro-interactions
Comprehensive database scripts for development and production:
# Setup & Initialization
npm run setup # Complete project setup
npm run db:setup # Database configuration
npm run db:seed # Add sample data
# Development
npm run db:migrate # Smart migration handling
npm run db:studio # Open database GUI
# Backup & Restore
npm run db:backup # Create timestamped backup
npm run db:restore # Interactive restore from backup
# Maintenance
npm run db:reset # Reset and re-seed (β οΈ destructive)
After running npm run db:seed
, you'll have these test accounts:
Role | Password | Status | |
---|---|---|---|
Super Admin | admin@authstarter.com | Admin123! | β Verified |
Admin | moderator@authstarter.com | Mod123! | β Verified |
User | john.doe@example.com | User123! | β Verified |
User | jane.smith@example.com | User123! | β Verified |
User | sarah.chen@techstart.com | User123! | β Verified |
User | mike.rodriguez@devco.com | User123! | β Unverified |
- Production Protection: Destructive operations blocked in production
- Backup Management: Automatic timestamping and cleanup
- Error Handling: Comprehensive troubleshooting guidance
- Confirmation Prompts: Double confirmation for destructive operations
This project follows consistent naming patterns for better organization:
- Controllers:
*.controller.js
(e.g.,auth.controller.js
,user.controller.js
) - Services:
*.service.js
(e.g.,auth.service.js
,email.service.js
) - Middleware:
*.middleware.js
(e.g.,auth.middleware.js
,errorHandler.middleware.js
) - Routes: Standard naming (e.g.,
auth.js
,users.js
)
- Single package.json: Uses only the root-level
package.json
for dependency management - Single Prisma schema: Database schema is located at
prisma/schema.prisma
- ES Modules: All server code uses ES module syntax (
import/export
) - Consistent imports: All file imports reflect the new naming conventions
npm run dev # Start development servers
npm run db:studio # View/edit data in browser
# 1. Edit prisma/schema.prisma
# 2. Run migration
npm run db:migrate
# 3. Restart your app
npm run db:backup # Create safety backup
# Make your changes
npm run db:restore # Restore if needed
npm run db:reset # Reset everything
npm run dev # Start fresh
- Registration: User signs up with email/password
- Email Verification: Verification email sent (check console in dev)
- Login: JWT tokens issued (access + refresh)
- Protected Routes: Access token required
- Token Refresh: Automatic refresh when access token expires
- Password Reset: Email-based password reset flow
The frontend uses Material-UI with a clean, modern design:
- Login/Register pages with validation
- Dashboard with user information
- Profile page for updating user details
- Password reset flow
- Email verification handling
- Responsive layout with navigation
POST /api/auth/register
- User registrationPOST /api/auth/login
- User loginPOST /api/auth/logout
- User logoutPOST /api/auth/refresh-token
- Refresh access tokenPOST /api/auth/forgot-password
- Request password resetPOST /api/auth/reset-password
- Reset passwordGET /api/auth/verify-email/:token
- Verify emailGET /api/auth/profile
- Get user profile
GET /api/users
- Get all users (admin only)GET /api/users/:id
- Get user by IDPUT /api/users/:id
- Update userDELETE /api/users/:id
- Delete user (admin only)
- Helmet.js for security headers
- CORS configuration
- Rate limiting (100 requests per 15 minutes)
- Password hashing with bcrypt (12 rounds)
- JWT tokens with expiration
- Input validation and sanitization
- SQL injection protection via Prisma
- XSS protection via React's built-in escaping
Set these in production:
NODE_ENV=production
DATABASE_URL=your-production-db-url
JWT_SECRET=your-production-jwt-secret
CORS_ORIGIN=https://yourdomain.com
# ... other production settings
npm run build
npm start
Run the test suite:
npm test
Tests include:
- Authentication endpoints
- User management
- Middleware functionality
- Input validation
This starter provides a solid foundation. Consider adding:
- Subscription/billing (Stripe integration)
- Team/organization management
- File upload functionality
- Real-time features (WebSockets)
- Admin dashboard
- API documentation (Swagger)
- Monitoring and logging
- CI/CD pipeline
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - feel free to use this starter for your projects!
If you encounter any issues:
- Check the GitHub Issues
- Review the environment configuration
- Ensure PostgreSQL is running
- Check the console for error messages
# Connection problems
npm run db:setup # Validates connection and setup
# Migration issues
npm run db:migrate:status # Check migration status
npm run db:push # Force push schema (dev only)
# Reset if needed
npm run db:reset # Nuclear option - resets everything
- Database connection failed: Check if PostgreSQL is running and DATABASE_URL is correct
- Permission denied: Ensure database user has CREATE/DROP privileges
- Migration conflicts: Use
npm run db:migrate:reset
to reset migrations - Backup/restore fails: Install PostgreSQL client tools (
brew install postgresql
)
- Prisma Documentation
- Material-UI Documentation
- React 18 Documentation
- Vite Documentation
- PostgreSQL Documentation
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with modern web technologies
- Inspired by best practices from the React and Node.js communities
- Special thanks to all contributors and the open-source community
Happy building! π
π‘ Pro Tip: Start with
npm run setup
for the smoothest experience!