MapMyIP is a modern, full-stack web application that detects your public IP address and visualizes your approximate geographic location on an interactive map. Built with Flask and Leaflet.js, it combines a powerful backend with a beautifully designed responsive frontend that works seamlessly on desktop and mobile devices.
- Features
- Architecture Overview
- Tech Stack
- Quick Start
- Configuration
- Project Structure
- Contributing
- License
- IP Detection: Automatically detects visitor's IP, handling proxies and load balancers
- Interactive Mapping: Real-time geolocation visualization using Leaflet.js and OpenStreetMap
- Detailed Information: City, region, country, timezone, ISP/ASN, and coordinates
- Responsive Design: Desktop sidebar layout and mobile bottom sheet interface
- Dark/Light Theme: Automatic OS detection with manual toggle support
- Performance: Skeleton loading states, optimized API session reuse, smooth animations, and database caching to reduce external API calls
- Transparency: Includes disclaimers about IP geolocation accuracy and VPN/proxy usage
βββββββββββββββββββββββββββββββββββββββββββββββ
β Client (Browser) β
β βββββββββββββββββββββββββββββββββββββββββ β
β β HTML / CSS / JS (UI Layer) β β
β β β’ Triggers API call β β
β β fetch('/ip-details') β β
β ββββββββββββββββ¬βββββββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββββββ
β HTTP Request
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββ
β Flask Application (API Layer) β
β βββββββββββββββββββββββββββββββββββββββββ β
β β routes.py (Controller Layer) β β
β β β’ Parses request β β
β β β’ Extracts client IP β β
β β β’ Calls service layer β β
β β β’ Returns JSON response β β
β ββββββββββββββββ¬βββββββββββββββββββββββββ β
β β β
β ββββββββββββββββΌβββββββββββββββββββββββββ β
β β services/ip_service.py β β
β β (Business Logic Layer) β β
β β β’ Cache-first strategy β β
β β 1. Check DB (cache hit?) β β
β β 2. If miss β call external API β β
β β 3. Persist result in DB β β
β β β’ Data normalization β β
β β β’ Error handling & fallback β β
β ββββββββββββββββ¬βββββββββββββββββββββββββ β
β β β
β ββββββββββββββββΌβββββββββββββββββββββββββ β
β β queries/ip_queries.py β β
β β (Data Access Layer) β β
β β β’ Abstract DB operations β β
β β β’ Insert / Fetch IP records β β
β ββββββββββββββββ¬βββββββββββββββββββββββββ β
β β β
β ββββββββββββββββΌβββββββββββββββββββββββββ β
β β models.py (ORM Layer) β β
β β β’ IPDetails schema (SQLAlchemy) β β
β ββββββββββββββββ¬βββββββββββββββββββββββββ β
β β β
β ββββββββββββββββΌβββββββββββββββββββββββββ β
β β extensions.py β β
β β β’ Initializes DB (SQLAlchemy) β β
β ββββββββββββββββ¬βββββββββββββββββββββββββ β
ββββββββββββ¬βββββββββββββββββββββββ¬ββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββ
β PostgreSQL (Persistence Layer) β β External Service (IPInfo API) β
β β’ Stores cached IP data β β β’ Provides IP geolocation data β
β β’ Reduces redundant API calls β β β’ Network-bound dependency β
ββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββ
| Layer | Technology |
|---|---|
| Frontend | HTML5, CSS3, JavaScript |
| Backend | Python 3, Flask |
| Database | PostgreSQL |
| API | IPInfo |
- Python 3.8 or higher
- IPInfo API token (free tier: ipinfo.io)
# Clone the repository
git clone https://github.com/AdityaKarun/mapmyip.git
cd mapmyip
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env and add your IPInfo token
# Run the application
python run.py
# Open http://localhost:5000 in your browser- Visit ipinfo.io
- Sign up for a free account (10,000 API calls/month)
- Copy your API token from the dashboard
- Add it to your
.envfile:
IPINFO_TOKEN=your_token_here- Install PostgreSQL on your system or use a cloud service (e.g., Heroku Postgres, AWS RDS)
- Create a database for the application
- Add the database connection URL to your
.envfile:
DATABASE_URL=postgresql://<DB_USER>:<DB_PASSWORD>@<DB_HOST>:<DB_PORT>/<DB_NAME>For production deployments, use environment variables provided by your hosting platform.
mapmyip/
β
βββ app/
β βββ __init__.py # App factory & database setup
β βββ extensions.py # Flask extensions (SQLAlchemy)
β βββ models.py # Database models (IPDetails)
β βββ routes.py # API endpoints
β βββ queries/
β β βββ ip_queries.py # Database query functions
β βββ services/
β β βββ ip_service.py # IPInfo integration & caching logic
β βββ static/
β β βββ css/
β β β βββ style.css # Responsive styles & themes
β β βββ js/
β β βββ script.js # Interactive features
β βββ templates/
β βββ index.html # Main template
β
βββ .env.example # Environment template
βββ .gitignore # Git ignore rules
βββ LICENSE # Project license
βββ Procfile # Deployment configuration
βββ README.md # Project documentation
βββ requirements.txt # Python dependencies
βββ run.py # Entry point
Contributions are welcome! Fork the repository, create a feature branch, make your changes, and submit a pull request.
This project is open source and available under the MIT License. See the LICENSE file for details.

