A modern, full-stack web application for Masinde Wanyonyi & Company Advocates, a premier law firm in Nairobi, Kenya. Built with the PERN stack (PostgreSQL, Express.js, React, Node.js) and deployed on Render.
- Frontend: React 19 + TypeScript + Vite + Tailwind CSS v4
- Backend: Node.js + Express.js + TypeScript
- Database: PostgreSQL with Prisma ORM
- Deployment: Render (both frontend and backend)
- Styling: Tailwind CSS v4 with custom design system
- State Management: React hooks and context
- Form Handling: React Hook Form with Zod validation
- Icons: Lucide React
- HTTP Client: Axios
- π¨ Modern Design: Clean, professional UI with responsive design
- π Type Safety: Full TypeScript implementation across the stack
- π± Mobile First: Responsive design optimized for all devices
- β‘ Performance: Optimized with Vite, code splitting, and lazy loading
- π‘οΈ Security: Rate limiting, input validation, and secure headers
- π§ Contact Forms: Integrated email notifications
- οΏ½οΈ Database: PostgreSQL with Prisma for type-safe database access
- π Deployment Ready: Configured for Render deployment
mwc-advocates/
βββ client/ # React frontend application
β βββ src/
β β βββ components/ # Reusable React components
β β β βββ layout/ # Layout components (Header, Footer, Layout)
β β β βββ ui/ # UI components (Button, Modal, etc.)
β β βββ pages/ # Page components
β β βββ services/ # API service layer
β β βββ types/ # TypeScript type definitions
β β βββ assets/ # Static assets (images, logos)
β β βββ App.tsx # Main application component
β βββ public/ # Public assets
β βββ package.json # Frontend dependencies
β
βββ server/ # Express.js backend application
β βββ src/
β β βββ controllers/ # Route controllers
β β βββ middleware/ # Express middleware
β β βββ routes/ # API route definitions
β β βββ services/ # Business logic services
β β βββ types/ # TypeScript type definitions
β β βββ utils/ # Utility functions and seed data
β β βββ app.ts # Express app configuration
β β βββ server.ts # Server entry point
β βββ prisma/ # Database schema and migrations
β β βββ schema.prisma # Prisma schema definition
β βββ generated/ # Generated Prisma client
β βββ package.json # Backend dependencies
β
βββ database/ # Database documentation and scripts
βββ docs/ # Additional documentation
βββ .gitignore # Git ignore rules
βββ README.md # Project documentation
βββ package.json # Root package.json for scripts
- Node.js 18+ (TypeScript and modern JS support)
- PostgreSQL 13+ (Database)
- Git (Version control)
git clone https://github.com/KristianHans04/mwc-advocates.git
cd mwc-advocates
git checkout PERNcd server
# Install dependencies
npm install
# Copy environment variables template
cp .env.example .env
# Edit .env file with your database credentials
# DATABASE_URL="postgresql://username:password@localhost:5432/mwc_advocates"
nano .env
# Generate Prisma client
npm run db:generate
# Run database migrations
npm run db:migrate
# Seed database with initial data
npm run db:seed
# Start development server
npm run devcd ../client
# Install dependencies
npm install
# Copy environment variables template
cp .env.example .env
# Edit .env file with your API URL
# VITE_API_BASE_URL=http://localhost:5000/api
nano .env
# Start development server
npm run dev- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- API Health Check: http://localhost:5000/health
- Database Studio:
npm run db:studio(in server directory)
npm run dev # Start development server with hot reload
npm run build # Build TypeScript to JavaScript
npm run start # Start production server
npm run db:generate # Generate Prisma client
npm run db:migrate # Run database migrations
npm run db:push # Push schema changes to database
npm run db:seed # Seed database with initial data
npm run db:studio # Open Prisma Studio (database GUI)
npm run type-check # Type check without emittingnpm run dev # Start development server with Vite
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLint
npm run type-check # Type check without emitting- Services: Legal service offerings
- Testimonials: Client testimonials and reviews
- ContactSubmissions: Contact form submissions
- FAQs: Frequently asked questions
- NewsletterSubscriptions: Email subscriptions
- BlogPosts: Legal insights and articles (future feature)
- Type Safety: Full TypeScript integration with Prisma
- Migrations: Version-controlled database schema changes
- Seeding: Initial data for development and testing
- Relations: Properly structured relational data
- Primary Green:
#0c3110(Brand color) - Yellow Accent:
#fbbf24(Buttons, highlights) - Text Colors: Dark gray hierarchy
- Background: White with subtle gray gradients
- Headings: Bold, professional hierarchy
- Body Text: Clean, readable sans-serif
- Responsive: Scales appropriately across devices
- Buttons: Multiple variants (primary, secondary, accent)
- Cards: Clean shadows with hover effects
- Forms: Professional styling with validation states
- Navigation: Fixed header with mobile hamburger menu
- Create PostgreSQL database on Render
- Note the database URL from Render dashboard
- Update production environment variables
- Connect GitHub repository to Render
- Create new Web Service
- Set build command:
cd server && npm install && npm run build - Set start command:
cd server && npm start - Add environment variables from
.env.example
- Create new Static Site on Render
- Set build command:
cd client && npm install && npm run build - Set publish directory:
client/dist - Add environment variables for production API URL
Backend (.env)
DATABASE_URL=postgresql://render_database_url
NODE_ENV=production
PORT=5000
FRONTEND_URL=https://your-frontend-url.onrender.com
JWT_SECRET=your-production-jwt-secret
SMTP_HOST=smtp.gmail.com
SMTP_USER=[email protected]
SMTP_PASS=your-app-password
CONTACT_EMAIL=[email protected]Frontend (.env)
VITE_API_BASE_URL=https://your-backend-url.onrender.com/api
VITE_APP_URL=https://your-frontend-url.onrender.comThe application supports email notifications for contact form submissions:
- Gmail Setup: Use Gmail SMTP with app passwords
- Environment Variables: Configure SMTP settings in
.env - Fallback: Contact forms work without email (saved to database)
- Rate Limiting: Prevents abuse of API endpoints
- Input Validation: Server-side validation with express-validator
- CORS Configuration: Properly configured for frontend domain
- Helmet: Security headers for Express.js
- Environment Variables: Sensitive data stored securely
- TypeScript: Full type safety across the stack
- Linting: ESLint configuration for code quality
- Error Handling: Comprehensive error handling and logging
- Validation: Client and server-side form validation
- Performance: Optimized builds and lazy loading
- Create feature branch from
PERN - Make changes with proper TypeScript types
- Test thoroughly on both frontend and backend
- Submit pull request with detailed description
This application is created specifically for Masinde Wanyonyi & Company Advocates. All rights reserved.
For technical support or deployment issues:
- Check the logs in Render dashboard
- Verify environment variables are set correctly
- Ensure database connection is working
- Review API endpoints in browser network tab