A comprehensive equestrian training and lesson management platform built with Next.js, Node.js, and PostgreSQL.
β FIXED: Main Server Implementation
- The
apps/api/src/server.ts
file now properly implements an Express server - All middleware, routes, and error handling are properly configured
- The application can now start and run successfully
- Comprehensive security measures are in place (CORS, Helmet, Rate Limiting)
- Proper graceful shutdown handling for database connections
- Homepage - Compelling hero section with call-to-action
- Services & Pricing - Dynamic lesson types and package pricing
- Horse Profiles - Individual horse information and availability
- Gallery - Photo and video showcase
- Events - Upcoming camps, shows, and special events
- Contact - Contact form and location information
- Registration & Intake - New student onboarding with e-signatures
- Lesson Booking - Real-time availability calendar
- Package Management - View and purchase lesson packages
- Progress Tracking - Instructor notes and skill development
- Payment History - Transaction records and receipts
- Calendar Management - Create recurring lesson templates
- Horse Management - Horse profiles, health records, availability
- Student Management - Student profiles, progress tracking
- Content Management - Upload photos, update pricing, manage testimonials
- Reports - Revenue, attendance, and utilization analytics
- Stripe Integration - Secure payment processing
- Lesson Packages - Pre-paid lesson bundles
- Merchandise - Branded products and gear
- Gift Certificates - Digital gift cards
- Responsive Design - Mobile-first approach
- Real-time Scheduling - Dynamic availability updates
- Email/SMS Notifications - Automated reminders
- Weather Integration - Weather-aware scheduling
- Social Media Integration - Instagram/Facebook feeds
- Next.js 14 - React framework with App Router
- TypeScript 5.3.3 - Type-safe development
- Tailwind CSS 3.4.0 - Utility-first styling
- Framer Motion 10.16.16 - Smooth animations
- React Hook Form 7.48.2 - Form management with Zod validation
- Axios 1.6.2 - HTTP client
- Lucide React 0.294.0 - Icon library
- React Calendar 4.6.0 - Calendar components
- React Dropzone 14.2.3 - File upload handling
- React Signature Canvas 1.0.6 - Digital signatures
- Node.js 18+ - JavaScript runtime
- Express.js 4.18.2 - Web framework with comprehensive middleware stack
- TypeScript 5.3.3 - Type-safe development
- Prisma 5.7.1 - Database ORM with comprehensive schema
- PostgreSQL - Primary database
- JWT (jsonwebtoken 9.0.2) - Authentication with role-based access
- Bcryptjs 2.4.3 - Password hashing
- Stripe 14.10.0 - Payment processing with webhooks
- Express Rate Limit 7.1.5 - Rate limiting
- Helmet 7.1.0 - Security headers
- CORS 2.8.5 - Cross-origin resource sharing
- Stripe - Payment processing with webhook handling
- Twilio 4.19.0 - SMS notifications
- Cloudinary 1.41.0 - Image/video storage
- WeatherAPI - Weather data integration
- Nodemailer 6.9.7 - Email notifications
- Mailchimp - Email marketing (configured but not implemented)
- AWS Lightsail - Hosting platform
- NGINX - Reverse proxy
- Let's Encrypt - SSL certificates
- PM2 - Process manager for Node.js
- Docker - Containerization (implied by deployment setup)
- Concurrently 8.2.2 - Run multiple commands
- Prettier 3.1.0 - Code formatting
- ESLint 8.56.0 - Code linting
- Lint-staged 15.2.0 - Pre-commit hooks
- Husky 8.0.3 - Git hooks
- TSX 4.6.2 - TypeScript execution
Frontend Architecture:
- Well-structured Next.js 14 application with App Router
- Comprehensive TypeScript implementation with proper type safety
- Modern React patterns with custom hooks and context providers
- Excellent component organization and reusability
- Proper form validation with React Hook Form + Zod
- Responsive design with Tailwind CSS
- Good separation of concerns between components and business logic
Backend Architecture:
- Comprehensive Prisma schema with proper relationships
- Well-implemented authentication and authorization system
- Role-based access control with multiple user types
- Proper input validation with Zod schemas
- Good error handling and logging patterns
- Comprehensive activity logging system
- Proper security middleware (Helmet, CORS, Rate Limiting)
Database Design:
- Well-normalized schema with proper relationships
- Comprehensive user management (students, guardians, instructors, admins)
- Detailed horse management with health records
- Flexible lesson scheduling system
- Proper payment and order tracking
- Good use of indexes for performance
Security Implementation:
- JWT-based authentication with proper token validation
- Password hashing with bcrypt
- Input sanitization and validation
- Rate limiting on authentication routes
- Proper CORS configuration
- Stripe webhook signature verification
- Activity logging for audit trails
Critical Issues:
- β RESOLVED: Main Server Implementation - Express server now properly implemented
- β RESOLVED: Application Startup - Server can now start and run successfully
High Priority Issues:
- Inconsistent Error Handling - Some routes lack proper error handling
- Missing Input Validation - Some endpoints don't validate all inputs
- Hardcoded Values - Some configuration values are hardcoded
- Missing API Documentation - No OpenAPI/Swagger documentation
- Incomplete Testing - No test files found in the codebase
Medium Priority Issues:
- Code Duplication - Some utility functions are duplicated
- Missing Environment Validation - No validation of required environment variables
- Incomplete Logging - Some operations lack proper logging
- Missing Health Checks - No health check endpoints
- Incomplete Error Messages - Some error messages could be more descriptive
Low Priority Issues:
- Code Comments - Some complex logic lacks documentation
- Type Definitions - Some types could be more specific
- Performance Optimization - Some database queries could be optimized
Immediate (Critical):
- β
COMPLETED: Express server implemented in
apps/api/src/server.ts
- β COMPLETED: Middleware stack configured (CORS, Helmet, Rate Limiting, Error Handling)
- β COMPLETED: Health check endpoints added
- π IN PROGRESS: Configure proper logging and monitoring
Short Term (High Priority):
- Add comprehensive input validation to all endpoints
- Implement proper error handling middleware
- Add API documentation with OpenAPI/Swagger
- Create comprehensive test suite
- Add environment variable validation
Medium Term:
- Optimize database queries and add proper indexing
- Implement caching strategy
- Add comprehensive logging and monitoring
- Implement proper backup and recovery procedures
- Add performance monitoring
Long Term:
- Implement microservices architecture if needed
- Add comprehensive CI/CD pipeline
- Implement proper monitoring and alerting
- Add comprehensive security auditing
- Implement proper disaster recovery procedures
- Environment Variables: Never commit
.env
files. Use.env.example
as templates. - JWT Secrets: Use strong, unique JWT secrets. Never use fallback secrets.
- Database Credentials: Rotate database passwords regularly.
- API Keys: Store sensitive API keys server-side only.
- Rate Limiting: Auth routes are rate-limited to prevent brute force attacks.
- CORS: Configured to allow only trusted origins.
- Input Validation: All inputs validated with Zod schemas.
- Error Logging: Sensitive data is sanitized before logging.
- JWT tokens with secure configuration
- Role-based access control (RBAC)
- Server-side route protection
- Middleware guards for sensitive endpoints
- Password hashing with bcrypt
- HTTPS enforcement in production
- Secure cookie configuration
- Input sanitization and validation
The Express server has been successfully implemented and is ready to run!
The apps/api/src/server.ts
file now includes:
- β Express Server Setup - Proper server initialization with TypeScript
- β Security Middleware - Helmet, CORS, rate limiting, and CSP headers
- β Environment Validation - Validates required environment variables on startup
- β All API Routes - Auth, user, public, student, admin, payment, and webhook routes
- β Error Handling - Comprehensive error handling middleware
- β
Health Check -
/health
endpoint for monitoring - β Graceful Shutdown - Proper Prisma disconnection on server termination
- β Production Ready - Environment-aware logging and configuration
- β
Correct Location:
apps/api/prisma/seed.ts
- Properly located and configured - β Comprehensive Data: Includes roles, lesson types, packages, forms, and admin user
- β
Duplicate Removed: Cleaned up duplicate seed file from
src/scripts/
- Node.js 18+
- PostgreSQL 14+
- npm or yarn
git clone <repository-url>
cd hearts4horses
npm install
# Database
DATABASE_URL="postgresql://username:password@localhost:5432/hearts4horses"
# JWT Secret
JWT_SECRET="your-super-secret-jwt-key-here"
# Stripe Configuration
STRIPE_SECRET_KEY="sk_test_your_stripe_secret_key"
STRIPE_WEBHOOK_SECRET="whsec_your_webhook_secret"
# Frontend URL
FRONTEND_URL="http://localhost:3000"
# Optional Integrations
CLOUDINARY_CLOUD_NAME="your-cloud-name"
CLOUDINARY_API_KEY="your-api-key"
CLOUDINARY_API_SECRET="your-api-secret"
TWILIO_ACCOUNT_SID="your-account-sid"
TWILIO_AUTH_TOKEN="your-auth-token"
MAILCHIMP_API_KEY="your-api-key"
OPENWEATHER_API_KEY="your-api-key"
# API Configuration
NEXT_PUBLIC_API_URL="http://localhost:4000"
# Weather API (WeatherAPI.com - HTTPS endpoint)
NEXT_PUBLIC_WEATHERAPI_KEY="your-weatherapi-key-here"
# Generate Prisma client
npm run db:generate
# Run migrations
npm run db:migrate
# Seed database with initial data
npm run db:seed
# Start both frontend and backend
npm run dev
# Or start individually
npm run dev:web # Frontend on http://localhost:3000
npm run dev:api # Backend on http://localhost:4000
hearts4horses/
βββ apps/
β βββ web/ # Next.js frontend
β β βββ app/ # App Router pages
β β βββ components/ # React components
β β βββ lib/ # Utilities and helpers
β βββ api/ # Express.js backend
β βββ src/
β β βββ routes/ # API routes
β β βββ middleware/ # Express middleware
β β βββ lib/ # Database and utilities
β β βββ scripts/ # Database seeds
β βββ prisma/ # Database schema
βββ packages/
β βββ shared/ # Shared TypeScript types
βββ package.json # Root package.json
POST /api/v1/auth/register
- User registrationPOST /api/v1/auth/login
- User loginGET /api/v1/auth/me
- Get current user
GET /api/v1/public/horses
- List horsesGET /api/v1/public/services
- Lesson types and pricingGET /api/v1/public/gallery
- Media galleryGET /api/v1/public/testimonials
- Customer testimonialsPOST /api/v1/public/contact
- Contact form submission
GET /api/v1/student/slots
- Available lesson slotsPOST /api/v1/student/bookings
- Book a lessonGET /api/v1/student/bookings
- Student's bookingsGET /api/v1/student/packages
- Student's packages
GET /api/v1/admin/horses
- Manage horsesPOST /api/v1/admin/templates
- Create lesson templatesPOST /api/v1/admin/slots/generate
- Generate availability slotsGET /api/v1/admin/students
- Manage studentsPOST /api/v1/admin/media/upload
- Upload content
POST /api/v1/payments/packages/checkout
- Create Stripe checkoutPOST /api/v1/webhooks/stripe
- Stripe webhook handler
-
Create Lightsail Instance
# Ubuntu 22.04 LTS # 2GB RAM, 1 vCPU minimum
-
Install Dependencies
sudo apt update && sudo apt upgrade -y curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt install -y nodejs nginx sudo npm i -g pm2
-
Clone and Build
cd /var/www git clone <repository-url> hearts4horses cd hearts4horses npm install npm run build
-
Set Up Environment
# Copy environment files cp apps/api/env.example apps/api/.env cp apps/web/.env.example apps/web/.env.local # Edit with your actual values nano apps/api/.env nano apps/web/.env.local
-
Database Setup
npm run db:generate npm run db:migrate npm run db:seed
-
Start Services
# Start API cd apps/api pm2 start "npm run start" --name hearts-api # Start Web cd ../web pm2 start "npm run start" --name hearts-web pm2 save pm2 startup
-
NGINX Configuration
# /etc/nginx/sites-available/hearts4horses server { listen 80; server_name hearts4horses.com www.hearts4horses.com; location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } } server { listen 80; server_name api.hearts4horses.com; location / { proxy_pass http://127.0.0.1:4000; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }
-
SSL Certificate
sudo apt install certbot python3-certbot-nginx sudo certbot --nginx -d hearts4horses.com -d www.hearts4horses.com sudo certbot --nginx -d api.hearts4horses.com
The color palette is defined in apps/web/tailwind.config.ts
:
- Barn Brown (#4B352A) - Primary color
- Copper (#CA7842) - Accent color
- Sage (#B2CD9C) - Muted color
- Butter (#F0F2BD) - Light accent
- Update horse information in the admin dashboard
- Modify lesson types and pricing via the admin interface
- Upload photos and videos through the media manager
- Customize testimonials and events
- 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
For technical support or questions:
- Create an issue in the repository
- Contact the development team
- Check the documentation
This project is licensed under the MIT License - see the LICENSE file for details.
Hearts4Horses - Making equestrian dreams come true, one lesson at a time. πβ¨