A Docker-based setup utility for integrating with India's Digipin geospatial addressing system API.
Digipin is India's nationwide geo-coded addressing system developed by the Department of Posts in collaboration with IIT Hyderabad and NRSC, ISRO. It provides precise location identification by dividing India into approximately 4m x 4m grids, with each grid assigned a unique 10-character alphanumeric code based on latitude and longitude coordinates.
- Precision: Identifies locations within 4m x 4m accuracy
- Coverage: Works across all Indian regions including rural, remote, and urban areas
- Privacy-Focused: No personal data storage, only geographic coordinates
- Offline Capability: Functions without internet connectivity once generated
- Open Source: Programming logic available in public domain
- Coordinates Coverage: Longitude 63.5-99.5°E, Latitude 2.5-38.5°N
This repository simplifies the setup and deployment of applications that integrate with the Digipin API by providing:
- Containerized Environment: Pre-configured Docker setup for Digipin API integration
- Easy Configuration: Environment variables and configuration templates
- Development Ready: Local development environment with hot-reload capabilities
- Production Deployment: Optimized production-ready containers
- API Documentation: Integrated API documentation and examples
- Health Checks: Built-in monitoring and health check endpoints
Perfect for applications requiring:
- Delivery Services: Precise location-based delivery in India
- Emergency Services: Quick location identification for first responders
- Government Services: Efficient service delivery with accurate addressing
- Logistics: Improved supply chain management with precise coordinates
- Rural Development: Addressing solutions for areas without traditional addresses
- Navigation Systems: Integration with mapping and navigation applications
-
Clone this repository:
git clone git@github.com:alfa-intellitech/digipin-api-docker.git
-
cd digipin-api-docker folder:
cd digipin-api-docker -
Create environment file:
cp .env.example .env # Edit .env file as needed -
Start the setup:
docker-compose up -d
-
Access the API:
- API: http://localhost:5000
- API Documentation: http://localhost:5000/api-docs
# Start only the DigiPin API
docker-compose up -d digipin-api# Start with nginx reverse proxy
docker-compose --profile production up -d# Start with Redis for caching
docker-compose --profile with-cache up -d# Start with both nginx and redis
docker-compose --profile production --profile with-cache up -dKey environment variables you can configure in .env:
NODE_ENV: Set toproductionfor production deploymentPORT: Port the API will run on (default: 5000)- Additional variables as per the DigiPin application requirements
Your project directory should look like this:
digipin-api-docker/
├── docker-compose.yml
├── Dockerfile
├── .env
├── nginx/
│ └── nginx.conf
└── logs/ (created automatically)
Note: The DigiPin source code is automatically cloned during the Docker build process.
Once running, you can test the API:
curl "http://localhost:5000/api/digipin/encode?latitude=12.9716&longitude=77.5946"curl "http://localhost:5000/api/digipin/decode?digipin=4P3-JK8-52C9"# All services
docker-compose logs -f
# Specific service
docker-compose logs -f digipin-apidocker-compose restart digipin-apidocker-compose downdocker-compose down
docker-compose build --no-cache
docker-compose up -d- SSL/TLS: For production, configure SSL certificates in the nginx configuration
- Environment: Set
NODE_ENV=productionin your.envfile - Monitoring: Consider adding monitoring services like Prometheus or health check endpoints
- Backup: If using Redis, configure appropriate persistence settings
- Security: Review and customize nginx security headers and rate limiting
The setup includes health checks. You can verify service health:
docker-compose psIf port 5000 is already in use, modify the port mapping in docker-compose.yml:
ports:
- "3000:5000" # Use port 3000 insteadIf you encounter build issues, try:
docker-compose build --no-cache --force-rmFor high-traffic scenarios, you can scale the API service:
docker-compose up -d --scale digipin-api=3Note: You'll need to configure nginx load balancing for multiple API instances.
- The Dockerfile runs the application as a non-root user
- Nginx includes basic security headers
- Rate limiting is configured in nginx
- Consider implementing additional security measures for production deployments