GovLink is a comprehensive Next.js-based digital government platform designed to revolutionize citizen-government interactions. Built with modern web technologies, it provides a unified interface for citizens, government agents, departments, and administrators to access various government services efficiently.
GovLink bridges the digital divide between citizens and government services by providing a centralized, accessible platform that offers:
- Digital Service Delivery: Streamlined online government services
- Appointment Management: Intelligent booking system with QR code integration
- Real-time Communication: Chat functionality with AI-powered RAG bot
- Multi-level Administration: Role-based access control for different user types
- Document Management: Secure file handling and verification
- Multi-language Support: Internationalization with i18next
- Analytics & Reporting: Comprehensive dashboards for insights
- Citizens: Access services, book appointments, chat with agents
- Agents: Manage appointments, communicate with citizens, handle service requests
- Departments: Oversee agents, manage services, configure department settings
- Administrators: System-wide management, user oversight, system configuration
- JWT-based authentication for all user types
- Role-based access control (RBAC)
- Password encryption with bcrypt
- Rate limiting for API security
- Account verification and email notifications
- QR code generation for appointment passes
- Email notifications with QR code attachments
- Department-specific appointment slots
- Agent-specific booking options
- Real-time availability checking
- RAG (Retrieval-Augmented Generation) chatbot
- LangChain integration for intelligent responses
- OpenAI and Tavily search capabilities
- Context-aware government service assistance
- Multi-language support (English, Sinhala, Tamil)
- Language detection and switching
- Localized content for better accessibility
- Department analytics dashboards
- Agent performance tracking
- User engagement metrics
- Service usage statistics
- AWS S3 (R2) integration for file storage
- Secure file upload and download
- Document verification workflows
- Profile picture management
- Framework: Next.js 15.4.5 with React 19
- Styling: Tailwind CSS 4 with custom components
- UI Components: Radix UI primitives
- Animations: Framer Motion
- Theme: Next-themes for dark/light mode
- Icons: Lucide React
- Runtime: Node.js with TypeScript
- Database: MongoDB with Mongoose ODM
- Authentication: JWT with bcryptjs
- File Storage: AWS S3 (R2) with S3 SDK v3
- Email Service: Nodemailer
- AI/ML: LangChain, OpenAI, Tavily Search
- Language: TypeScript 5
- Linting: ESLint with Next.js config
- Build Tool: Next.js with Turbopack
- Package Manager: npm
- Version Control: Git
- Platform: Netlify (with Azure VM support)
- Analytics: Vercel Analytics & Speed Insights
- Environment: Multi-environment support (dev, prod)
govlink/
βββ src/ # Source code
β βββ app/ # Next.js app router
β β βββ admin/ # Admin dashboard & management
β β βββ agent/ # Agent portal & features
β β βββ department/ # Department management
β β βββ user/ # Citizen portal
β β βββ api/ # API routes & serverless functions
β β βββ account-suspended/ # Suspension handling
β β βββ feedback/ # Feedback system
β β βββ ragbot/ # AI chatbot interface
β βββ components/ # Reusable React components
β β βββ adminSystem/ # Admin-specific components
β β βββ agent/ # Agent portal components
β β βββ department/ # Department components
β β βββ user/ # User/citizen components
β β βββ Icons/ # Custom icon components
β βββ lib/ # Utility libraries & services
β β βββ auth/ # Authentication middleware
β β βββ i18n/ # Internationalization
β β βββ models/ # Database schemas
β β βββ services/ # Business logic services
β β βββ tools/ # Utility tools
β β βββ utils/ # Helper functions
β βββ types/ # TypeScript type definitions
βββ public/ # Static assets
βββ scripts/ # Database migration & utility scripts
βββ .github/ # CI/CD workflows & templates
βββ docs/ # Documentation files
Before you begin, ensure you have the following installed:
- Node.js: Version 18.0 or higher
- npm: Version 8.0 or higher
- MongoDB: Local instance or MongoDB Atlas
- Git: For version control
Create a .env.local file in the root directory with the following variables:
# Database
MONGODB_URI=mongodb://localhost:27017/govlink
# or MongoDB Atlas
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/govlink
# JWT Authentication
JWT_SECRET=your-super-secret-jwt-key-min-32-characters
# AWS S3 (R2) Configuration
R2_ACCESS_KEY_ID=your-r2-access-key
R2_SECRET_ACCESS_KEY=your-r2-secret-key
R2_BUCKET_NAME=your-bucket-name
R2_ENDPOINT=https://your-account-id.r2.cloudflarestorage.com
# Email Configuration (Nodemailer)
EMAIL_FROM=noreply@govlink.lk
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-password
# OpenAI API (for RAG bot)
OPENAI_API_KEY=your-openai-api-key
# Tavily Search API (for RAG bot)
TAVILY_API_KEY=your-tavily-api-key
# Application URLs
NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXT_PUBLIC_API_URL=http://localhost:3000/api
# Rate Limiting
RATE_LIMIT_MAX=100
RATE_LIMIT_WINDOW=900000-
Clone the repository:
git clone https://github.com/XFire2025/govlink.git cd govlink -
Install dependencies:
npm install
-
Set up environment variables:
cp .env.example .env.local # Edit .env.local with your configuration -
Set up MongoDB:
- Install MongoDB locally or use MongoDB Atlas
- Create a database named
govlink - Update the
MONGODB_URIin your.env.local
-
Run database migrations (optional):
npm run migrate:departments
-
Start the development server:
npm run dev
-
Open your browser: Navigate to http://localhost:3000
npm run dev- Start development server with Turbopacknpm run build- Build the application for productionnpm run start- Start the production servernpm run lint- Run ESLint for code qualitynpm run seed:departments- Seed initial department datanpm run migrate:departments- Run department migrations
-
Clone the repository:
git clone https://github.com/XFire2025/govlink.git cd govlink -
Set up environment variables:
cp .env.docker.example .env # Edit .env with your configuration -
Start all services:
docker-compose up -d
-
Access the application:
- GovLink App: http://localhost:3000
- MongoDB: localhost:27017
- MongoDB Express (optional): http://localhost:8081
# Development with hot reload
docker-compose up
# Production with optimized build
docker-compose --profile production up -d
# With MongoDB Express for database management
docker-compose --profile development up -d
# With Redis caching
docker-compose --profile cache up -d
# With Nginx reverse proxy
docker-compose --profile production up -dCreate a .env file based on .env.docker.example:
# Required variables
JWT_SECRET=your-super-secret-jwt-key-must-be-at-least-32-characters-long
OPENAI_API_KEY=your-openai-api-key
TAVILY_API_KEY=your-tavily-api-key
# AWS S3/R2 Configuration
R2_ACCESS_KEY_ID=your-access-key
R2_SECRET_ACCESS_KEY=your-secret-key
R2_BUCKET_NAME=your-bucket
R2_ENDPOINT=https://your-account.r2.cloudflarestorage.com
# Email Configuration
EMAIL_HOST=smtp.gmail.com
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-password# Start development environment
docker-compose up
# View logs
docker-compose logs -f govlink-app
# Execute commands in container
docker-compose exec govlink-app npm run build
# Stop services
docker-compose down
# Clean up volumes (β οΈ This will delete data)
docker-compose down -v# Build and start production services
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
# Scale the application
docker-compose up -d --scale govlink-app=3
# View production logs
docker-compose logs -f --tail=100| Service | Port | Description | Profile |
|---|---|---|---|
govlink-app |
3000 | Next.js application | default |
mongodb |
27017 | MongoDB database | default |
mongo-express |
8081 | Database admin UI | development |
redis |
6379 | Caching layer | cache |
nginx |
80, 443 | Reverse proxy | production |
All services include health checks:
# Check service status
docker-compose ps
# View health status
docker inspect govlink-app | grep Health -A 10Docker volumes ensure data persistence:
mongodb_data: Database filesgovlink_uploads: User uploaded filesredis_data: Cache data (if using Redis)nginx_logs: Web server logs
# Rebuild containers
docker-compose build --no-cache
# View container logs
docker-compose logs govlink-app
# Access container shell
docker-compose exec govlink-app sh
# Reset everything
docker-compose down -v
docker system prune -a- Automatic deployments from GitHub
- Environment variable configuration
- Custom domain support
- Serverless functions support
- Complete deployment guide available in
DEPLOYMENT.md - CI/CD pipeline with GitHub Actions
- Custom server configuration
- SSL certificate setup
- Use the provided
docker-compose.yml - Containerized application with MongoDB
- Easy scaling and environment management
NODE_ENV=development
NEXT_PUBLIC_APP_URL=http://localhost:3000NODE_ENV=production
NEXT_PUBLIC_APP_URL=https://your-domain.comWe welcome contributions from the community! Here's how you can help:
-
Fork the repository
git fork https://github.com/XFire2025/govlink.git
-
Create a feature branch
git checkout -b feature/your-feature-name
-
Make your changes
- Follow the existing code style
- Add tests for new features
- Update documentation as needed
-
Commit your changes
git commit -m "feat: add your feature description" -
Push to your branch
git push origin feature/your-feature-name
-
Open a Pull Request
- Provide a clear description of your changes
- Link any related issues
- Ensure all tests pass
- Use TypeScript for all new code
- Follow the existing naming conventions
- Add JSDoc comments for functions
- Use Tailwind CSS for styling
- Follow the component structure patterns
- All PRs are reviewed using CodeRabbit AI
- Maintainers will review your changes
- Address any feedback or requested changes
- Once approved, your PR will be merged
- Admin RBAC Documentation: Role-based access control details
- Deployment Guide: Complete Azure VM deployment instructions
- QR Code Implementation: QR code system documentation
- API Documentation: Available in individual route files under
src/app/api/
GovLink features an advanced AI chatbot powered by:
- LangChain: For conversation flow and context management
- OpenAI GPT: For natural language understanding and generation
- Tavily Search: For real-time information retrieval
- Custom Knowledge Base: Government-specific information and procedures
- Context-aware responses about government services
- Multi-language support for better accessibility
- Real-time information retrieval
- Integration with appointment booking system
- Escalation to human agents when needed
POST /api/auth/admin- Admin authenticationPOST /api/auth/agent/login- Agent loginPOST /api/auth/department/login- Department loginGET /api/auth/*/me- Get current user profile
GET /api/admin/admins- List all admins (Super Admin only)POST /api/admin/admins- Create new adminGET /api/admin/agents- List all agentsPOST /api/admin/agents- Create new agent
GET /api/admin/departments- List all departmentsPOST /api/admin/departments- Create new departmentPUT /api/admin/departments/[id]- Update departmentDELETE /api/admin/departments/[id]- Delete department
GET /api/department/agents- Get department agentsPOST /api/department/agents- Create new agentPUT /api/department/agents/[id]- Update agentDELETE /api/department/agents/[id]- Deactivate agent
GET /api/user/departments- Get all active departmentsGET /api/user/departments/[id]/agents- Get department agentsPOST /api/ragbot- Chat with AI assistant
- JWT Authentication: Secure token-based authentication
- Password Encryption: bcrypt with salt rounds
- Rate Limiting: API request throttling
- Input Validation: Comprehensive request validation
- CORS Protection: Cross-origin request security
- Environment Variables: Secure configuration management
- Role-Based Access: Granular permission system
- Vercel Analytics: User engagement tracking
- Speed Insights: Performance monitoring
- Custom Dashboards: Role-specific analytics
- Error Tracking: Comprehensive error logging
- Performance Metrics: API response time monitoring
# Check MongoDB service status
sudo systemctl status mongod
# Restart MongoDB
sudo systemctl restart mongod
# Check MongoDB logs
sudo tail -f /var/log/mongodb/mongod.log- Ensure all required environment variables are set
- Check for typos in variable names
- Verify
.env.localis in the root directory - Restart the development server after changes
# Clear Next.js cache
rm -rf .next
# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
# Check for TypeScript errors
npm run build# Kill process using port 3000
npx kill-port 3000
# Or use different port
npm run dev -- -p 3001- Enable Turbopack in development:
npm run dev(already configured) - Use Next.js Image component for optimized images
- Implement proper caching strategies
- Monitor bundle size with
@next/bundle-analyzer
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Project Wiki
- Security: Report security issues to security@govlink.lk
This project is licensed under the MIT License - see the LICENSE file for details.
- Multi-role authentication system
- Department and agent management
- Basic appointment booking
- Admin dashboard
- QR code integration
- Email notification system
- RAG chatbot integration
- Multi-language support
- Mobile application
- Advanced analytics
- Payment gateway integration
- Document verification system
- API rate limiting improvements
- Multi-tenant architecture
- Advanced reporting
- Audit logging
- SSO integration
- Advanced security features
- Next.js Team: For the amazing React framework
- MongoDB: For the flexible database solution
- Tailwind CSS: For the utility-first CSS framework
- OpenAI: For AI integration capabilities
- Netlify: For deployment and hosting
- Government of Sri Lanka: For the project inspiration and requirements
Built with β€οΈ by the GovLink Team
π Website β’ π Documentation β’ π Report Bug β’ β¨ Request Feature