A fully Dockerized MERN (MongoDB, Express, React, Node.js) stack application for trek booking and management.
Frontend → Next.js (App Router) + Tailwind CSS
Backend → Express.js + Node.js with JWT authentication
Database → MongoDB with authentication
Services → Docker Compose orchestration
Before running this project on a new machine, ensure you have:
- Docker (v20.10+) - Install Docker
- Docker Compose (v2.0+) - Usually included with Docker Desktop
- Git - For cloning the repository
- ~2GB of free disk space for Docker images and volumes
docker --version
docker compose --versiongit clone https://github.com/Crazz-Zaac/geletrekking.git
cd geletrekkingcd docker
docker compose up -d --buildThis command will:
- Build the frontend (Next.js)
- Build the backend (Express.js)
- Start MongoDB with authentication
- Start Mongo Express (database admin UI)
- Automatically seed the superadmin user
| Service | URL | Credentials |
|---|---|---|
| Frontend | http://localhost:3000 | - |
| Backend API | http://localhost:5000 | - |
| Mongo Express | http://localhost:8081 | sherap / sherap123 |
Use the credentials you set in SUPERADMIN_EMAIL and SUPERADMIN_PASSWORD to login
cd docker
docker compose downTo also remove data volumes:
docker compose down -v- Node.js v18+ and npm/pnpm
- MongoDB running locally on port 27017
# Root directory
npm install
# Backend dependencies
cd backend
npm install --legacy-peer-deps
# Frontend dependencies
cd ../frontend
npm installCreate/update .env files:
- Copy
backend/.env.exampletobackend/.env - Fill in your configuration values
backend/.env (for local development):
# MongoDB Configuration (no URL encoding needed!)
MONGO_USERNAME=your_username
MONGO_PASSWORD=your_password
MONGO_HOST=localhost # Use 'localhost' for local, 'mongo' for Docker
MONGO_PORT=27017
MONGO_DATABASE=geletrekking
MONGO_AUTH_SOURCE=admin
# Application Config
SUPERADMIN_EMAIL=superadmin@geletrekking.com
SUPERADMIN_PASSWORD=your_password
NODE_ENV=development
JWT_SECRET=your_jwt_secret_key_here
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_app_password
FRONTEND_URL=http://localhost:3000
ALLOWED_ORIGINS=http://localhost:3000From the root directory:
# Run both backend and frontend concurrently
npm run devOr run them separately:
# Terminal 1 - Backend
cd backend
npm run dev
# Terminal 2 - Frontend
cd frontend
npm run devFrontend: http://localhost:3000 Backend: http://localhost:5000
geletrekking/
├── backend/ # Express.js server
│ ├── config/ # Database, Cloudinary config
│ ├── controllers/ # Route handlers
│ ├── models/ # MongoDB schemas
│ ├── routes/ # API endpoints
│ ├── middleware/ # Auth, role-based middleware
│ ├── utils/ # Helper functions
│ ├── server.js # Entry point
│ ├── superadminSeeder.js # Creates superadmin user
│ ├── entrypoint.sh # Docker entry script
│ └── .env # Environment variables
│
├── frontend/ # Next.js application
│ ├── app/ # App Router pages
│ ├── components/ # Reusable UI components
│ ├── hooks/ # Custom React hooks
│ ├── lib/ # Utilities & API client
│ └── next.config.mjs
│
├── docker/ # Docker configuration
│ ├── Dockerfile.backend # Backend image
│ ├── Dockerfile.frontend # Frontend image
│ ├── docker-compose.yml # Orchestration
│ └── nginx.conf # Production Nginx config
│
└── README.md # This file
- ✅ JWT Authentication - Secure user login and token management
- ✅ Role-Based Access Control - Superadmin, admin, and user roles
- ✅ MongoDB Authentication - Database security with credentials
- ✅ Auto-Seeding - Superadmin user created on first run
- ✅ Email Integration - Gmail SMTP for notifications
- ✅ Responsive UI - Tailwind CSS for modern design
- ✅ Production Ready - Dockerized Next.js + backend services
- ✅ Database Admin UI - Mongo Express for easy data management
✅ RECOMMENDED: Use individual MongoDB components (automatically URL-encoded)
# MongoDB Configuration
MONGO_USERNAME=sherap
MONGO_PASSWORD=P@ssw0rd! # Special characters handled automatically!
MONGO_HOST=mongo # 'mongo' for Docker, 'localhost' for local
MONGO_PORT=27017
MONGO_DATABASE=geletrekking
MONGO_AUTH_SOURCE=admin
# MongoDB initialization (Docker only)
MONGO_INITDB_ROOT_USERNAME=sherap
MONGO_INITDB_ROOT_PASSWORD=P@ssw0rd!
# Server Configuration
NODE_ENV=development
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
FRONTEND_URL=http://localhost:3000
# Authentication
JWT_SECRET=your_jwt_secret_key_here
SUPERADMIN_EMAIL=superadmin@geletrekking.com
SUPERADMIN_PASSWORD=sherap
# Email Configuration
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_app_password
# Database Admin (Mongo Express)
ME_CONFIG_BASICAUTH_USERNAME=sherap
ME_CONFIG_BASICAUTH_PASSWORD=sherap123
ME_CONFIG_MONGODB_SERVER=mongo
ME_CONFIG_MONGODB_PORT=27017# Only use if you need full control over connection string
MONGO_URI=mongodb://sherap:P%40ssw0rd%21@mongo:27017/geletrekking?authSource=admin# Backend logs
docker logs geletrekking-backend -f
# MongoDB logs
docker logs geletrekking-mongo -f
# All services
docker logs -fdocker exec -it geletrekking-mongo mongosh -u sherap -p 'P@ssw0rd!' --authenticationDatabase admin geletrekkingcd docker
docker compose down -v
docker compose up -d --builddocker compose psIssue: Authentication failed error when connecting to MongoDB
Solution:
- Ensure
MONGO_URIincludes URL-encoded credentials (@ =%40, ! =%21) - Rebuild containers:
docker compose down -v && docker compose up -d --build
Issue: Backend can't connect to MongoDB
Solution:
- Use
mongoas hostname (not localhost) in Docker environment - Verify
.envfile is inbackend/directory - Check MongoDB container is running:
docker ps | grep mongo
Issue: Port 3000, 5000, or 27017 already in use
Solution:
# Find process using port
lsof -i :3000
# Or change ports in docker-compose.ymlIssue: Can't login with superadmin credentials
Solution:
- Check backend logs:
docker logs geletrekking-backend - Verify
.envhasSUPERADMIN_EMAILandSUPERADMIN_PASSWORD - Recreate containers:
docker compose down -v && docker compose up -d --build
Issue: MongoDB URI fails with special characters like @ or !
Solution:
- RECOMMENDED: Use individual MongoDB variables (
MONGO_USERNAME,MONGO_PASSWORD) - encoding is automatic! - LEGACY: If using
MONGO_URI, manually URL-encode special characters:@→%40!→%21:→%3A- Example:
P@ssw0rd!becomesP%40ssw0rd%21
For production:
- Update environment variables in
.env - Set
NODE_ENV=productionin backend.env - Remove port mappings or use a reverse proxy
- Enable HTTPS/SSL
- Update
ALLOWED_ORIGINSwith production domains - Change default passwords
- Set strong
JWT_SECRET - Update
FRONTEND_URLto production domain
Backend API runs on http://localhost:5000
Main routes:
POST /api/auth/login- User loginPOST /api/auth/register- User registrationGET /api/treks- List all treksGET /api/about- About page contentGET /api/gallery- Gallery itemsPOST /api/admin/...- Admin routesPOST /api/superadmin/...- Superadmin routes
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes
- Commit:
git commit -m "Add your feature" - Push:
git push origin feature/your-feature - Open a Pull Request
This project is private and owned by Crazz-Zaac.
For issues or questions, contact the development team or create an issue on GitHub.