A production-grade, full-stack boilerplate combining MongoDB, GraphQL, React 18, and Node.js 22 with Tailwind CSS 3 and TypeScript. Built with modern best practices, security-first architecture, and containerized deployment.
- React 18 with concurrent rendering and modern features
- Node.js 22 LTS with ES modules and latest performance improvements
- MongoDB with Mongoose ODM for flexible data modeling
- GraphQL with Apollo Server 4 for efficient API communication
- Tailwind CSS 3 for utility-first, responsive styling
- TypeScript throughout for type safety and better DX
- Helmet with strict Content Security Policy (no
unsafe-inlineneeded) - CORS configuration with environment-based origins
- JWT authentication ready
- Rate limiting and DDoS protection
- Input validation and sanitization
- Security headers optimized for modern browsers
- Docker multi-stage builds for optimized containers
- Docker Compose for complete development and production stacks
- Server-Side Rendering (SSR) for optimal SEO
- Health checks for monitoring and observability
- Graceful shutdown handling
- Compression and caching strategies
- Hot Module Replacement for instant development feedback
- ESLint and Prettier for code quality
- TypeScript strict mode configuration
- Path aliases for clean imports
- Environment-based configuration
- Node.js 22+ (LTS recommended)
- MongoDB 7+ (or use Docker Compose)
- Docker & Docker Compose (optional, for containerized development)
-
Clone the repository
git clone https://github.com/yourusername/mgrn-template.git cd mgrn-template -
Install dependencies
npm install
-
Set up environment
cp .env.example .env # Edit .env with your configuration -
Start MongoDB (if not using Docker)
# Using MongoDB locally mongod --dbpath /path/to/your/db # Or using MongoDB in Docker docker run -d -p 27017:27017 --name mongodb mongo:7.0
-
Start development servers
npm run dev
This starts:
- Vite dev server on http://localhost:3000 (React app with HMR)
- Node.js server on http://localhost:4000 (GraphQL API + SSR)
-
Open your browser
- Frontend: http://localhost:3000
- GraphQL Playground: http://localhost:4000/graphql
- Health Check: http://localhost:4000/health
For a complete containerized development environment:
# Start all services (MongoDB + App)
npm run docker:dev
# Or manually
docker-compose -f docker-compose.dev.yml up# Build both client and server
npm run build
# Start production server
npm start# Build and start production containers
npm run docker:run
# Or manually
docker-compose up -dFor production, ensure these environment variables are set:
NODE_ENV=production
MONGO_URI=mongodb://username:password@host:port/database
JWT_SECRET=your-256-bit-secret
CORS_ORIGIN=https://yourdomain.com
SSL_ENABLED=true
SSL_CERT_PATH=/path/to/cert.pem
SSL_KEY_PATH=/path/to/key.pemMGRN-Template/
βββ src/ # React frontend source
β βββ components/ # Reusable UI components
β β βββ Header.tsx # Navigation header
β β βββ Footer.tsx # Site footer
β βββ pages/ # Page components
β β βββ HomePage.tsx # Landing page
β β βββ DataPage.tsx # GraphQL demo page
β β βββ ErrorPage.tsx # Error boundary
β βββ App.tsx # Main app component
β βββ router.tsx # React Router configuration
β βββ apollo-client.ts # Apollo Client setup
β βββ entry-client.tsx # Client-side entry point
β βββ entry-server.tsx # Server-side entry point
β βββ index.css # Tailwind CSS imports
βββ server/ # Node.js backend source
β βββ config/ # Configuration management
β β βββ index.ts # Environment config
β βββ database/ # Database connection
β β βββ connect.ts # MongoDB connection
β βββ graphql/ # GraphQL schema & resolvers
β β βββ typeDefs.ts # GraphQL type definitions
β β βββ resolvers.ts # GraphQL resolvers
β βββ middleware/ # Express middleware
β β βββ helmet.ts # Security headers
β βββ render/ # SSR handling
β β βββ handler.ts # Server-side rendering
β βββ app.ts # Express app configuration
β βββ index.ts # Server entry point
βββ Dockerfile # Multi-stage Docker build
βββ docker-compose.yml # Production Docker Compose
βββ .dockerignore # Docker ignore patterns
βββ .env.example # Environment variables template
βββ tailwind.config.js # Tailwind CSS configuration
βββ postcss.config.js # PostCSS configuration
βββ vite.config.ts # Vite build configuration
βββ tsconfig.json # TypeScript config (client)
βββ tsconfig.server.json # TypeScript config (server)
βββ package.json # Dependencies and scripts
# Development
npm run dev # Start both client and server in development
npm run dev:client # Start only Vite dev server
npm run dev:server # Start only Node.js server with watch
# Building
npm run build # Build both client and server for production
npm run build:client # Build only React app
npm run build:server # Build only Node.js server
# Production
npm start # Start production server
# Docker
npm run docker:build # Build Docker image
npm run docker:run # Start production containers
npm run docker:dev # Start development containers
# Code Quality
npm run lint # Run ESLint
npm run type-check # Run TypeScript compiler checks- No
unsafe-inlinestyles thanks to Tailwind CSS compilation - Strict script sources with nonce support
- Font and image source restrictions
- Frame ancestors protection against clickjacking
- HSTS for HTTPS enforcement
- X-Frame-Options for iframe protection
- X-Content-Type-Options for MIME type sniffing prevention
- Permissions Policy for feature access control
- JWT token support (ready to implement)
- Secure cookie handling
- Rate limiting per IP
- Input validation and sanitization
- Vite for fast builds and HMR
- Code splitting with React Router
- Lazy loading for optimal bundle sizes
- Tailwind CSS purging for minimal CSS
- Image optimization ready
- Compression middleware for response optimization
- Static file caching with appropriate headers
- MongoDB indexing for query performance
- Connection pooling for database efficiency
- Memory usage monitoring
- SEO optimization with server-side rendering
- Faster initial page loads
- Social media sharing with proper meta tags
- Progressive enhancement
- Create page component in
src/pages/ - Add route to
src/router.tsx - Update navigation in
src/components/Header.tsx
- Define types in
server/graphql/typeDefs.ts - Implement resolvers in
server/graphql/resolvers.ts - Use in React components with Apollo Client
- Customize
tailwind.config.jsfor your design system - Add custom components in
src/index.css - Use Tailwind utilities throughout your React components
- Add variables to
.env.example - Update
server/config/index.tsfor new config options - Document in this README
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit changes:
git commit -am 'Add feature' - Push to branch:
git push origin feature-name - Submit a Pull Request
This project is licensed under the GPU 3 License - see the LICENSE file for details.
- React Team for the amazing framework
- Vercel for Vite and excellent tooling
- MongoDB for the flexible database
- Apollo GraphQL for the powerful API layer
- Tailwind Labs for the utility-first CSS framework
Built with β€οΈ for the modern web
Ready to build something amazing? π Mongo GraphQL React Node template repository