Skip to content

AdityaKarun/mapmyip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MapMyIP

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.

Screenshots

Loading Page

Loading Screen Preview

Home Page

Home Page Preview

πŸ“– Table of Contents


✨ Features

  • 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

πŸ—οΈ Architecture Overview

                                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                β”‚         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          β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Layer Technology
Frontend HTML5, CSS3, JavaScript
Backend Python 3, Flask
Database PostgreSQL
API IPInfo

πŸš€ Quick Start

Prerequisites

  • Python 3.8 or higher
  • IPInfo API token (free tier: ipinfo.io)

Setup

# 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

βš™οΈ Configuration

Getting an IPInfo API Token

  1. Visit ipinfo.io
  2. Sign up for a free account (10,000 API calls/month)
  3. Copy your API token from the dashboard
  4. Add it to your .env file:
IPINFO_TOKEN=your_token_here

Setting up PostgreSQL Database

  1. Install PostgreSQL on your system or use a cloud service (e.g., Heroku Postgres, AWS RDS)
  2. Create a database for the application
  3. Add the database connection URL to your .env file:
DATABASE_URL=postgresql://<DB_USER>:<DB_PASSWORD>@<DB_HOST>:<DB_PORT>/<DB_NAME>

For production deployments, use environment variables provided by your hosting platform.


πŸ“‚ Project Structure

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

🀝 Contributing

Contributions are welcome! Fork the repository, create a feature branch, make your changes, and submit a pull request.


πŸ“„ License

This project is open source and available under the MIT License. See the LICENSE file for details.


Made with ❀️ by Aditya Karun

About

Detect your IP address and visualize your geographic location on an interactive map. A Flask-powered web app with PostgreSQL caching, responsive design, real-time geolocation data, and dark/light theme support.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors