A modern, role-based web dashboard built with Python and Flask to monitor user GPS coordinates in real-time. Locsent provides secure access for admins and users, logs location history, and uniquely utilizes Notion as a powerful, serverless backend.
↗️ Live Demo: locsent.vercel.app
|
- Live Interactive Map: Admins see all users on a single map, updating in real-time. Users see their own location on a personal map.
- Role-Based Access Control: Secure login system for
AdminandUserroles. - Admin Monitoring Dashboard:
- View, manage, and delete registered users.
- Fetch a user's location history, including IP Address, Device Info, and Battery Status.
- Export any user's complete location history as CSV, HTML, or PDF.
- Open any coordinate directly in Google Maps.
- Geofencing: Admins can define safe zones in Notion. The system will flash an alert on the dashboard if a user sends a location from inside a defined zone.
- Dynamic Admin Controls:
- Enable or Disable public sign-ups with the click of a button to secure your application.
- Notion as a Database: All user, location, geofence, and application settings data is stored and managed in a Notion workspace.
- Modern UI/UX:
- Clean, animated, and fully responsive design with a glassmorphism header.
- Supports both Dark Mode and Light Mode.
This guide explains how to use Locsent once it has been set up and is running.
- Login: Use the admin credentials you created manually in the
UsersNotion database. - View the Live Map: The main map on your dashboard shows the last known location of all registered users. Markers update automatically.
- Manage Geofences: To add, edit, or remove a geofence, simply edit the rows in your
Geofencesdatabase in Notion. The map will reflect these changes automatically. - Control User Sign-Up: In the "Admin Controls" panel, you can click the "Enable/Disable Sign-Up" button to control whether new users can register.
- Manage Users:
- View History: Click the "History" button next to any user to see their last 10 location logs, latest coordinates, and device info.
- Export Data: Click the "Export" button and choose a format (CSV, HTML, PDF) to download a user's complete location history.
- Delete User: Click the "Delete" button. You will be asked for confirmation before the user is permanently removed.
- Sign Up: If enabled by the admin, new users can create an account on the sign-up page.
- Login: Use your registered credentials to access the dashboard.
- View Your Map: Your dashboard features a personal map showing your current location and all the geofence zones defined by the administrator. Your marker will update periodically.
- Send Location Manually: Click the "Send Current Location" button to immediately log your coordinates and send them to the admin.
- Automatic Tracking: Your location is also sent automatically in the background every hour while you are logged in.
| Category | Technologies |
|---|---|
| Backend | Python, Flask, Flask-Login, Flask-Bcrypt, Flask-WTF |
| Database | Notion API |
| Frontend | HTML, CSS, JavaScript, Leaflet.js |
| PDF Generation | FPDF2 |
| Deployment | Vercel |
The project uses the Application Factory pattern with all Python files in the root for simplicity and to prevent import errors.
Locsent/
├── .env
├── .gitignore
├── README.md
├── app.py # The Application Factory
├── auth.py # Manages authentication
├── build.sh # Essential requirements for vercel
├── decorators.py # Custom decorators
├── extensions.py # Initializes extensions
├── models.py # Handles all communication with the Notion API
├── requirements.txt # Python package dependencies
├── routes.py # Defines application routes and view logic
├── run.py # The entry point to run the application
├── static/
│ ├── css/
│ │ └── style.css
│ └── js/
│ └── main.js
├── templates/
│ ├── admin_dashboard.html
│ ├── export_template.html
│ ├── layout.html
│ ├── login.html
│ ├── signup.html
│ └── user_dashboard.html
└── vercel.json
Follow these instructions to get a local copy up and running.
Your Notion workspace will act as your database. This is a critical step.
- Go to notion.so/my-integrations.
- Click "+ New integration". Name it "Locsent API".
- Copy the "Internal Integration Token". This is your
NOTION_API_KEY.
Create four new, empty databases in your Notion workspace with the exact properties shown below.
| Property Name | Property Type |
|---|---|
UserID |
Title |
Username |
Text |
Role |
Select |
PasswordHash |
Text |
| Property Name | Property Type |
|---|---|
LogID |
Title |
User |
Relation (linked to Users db) |
Timestamp |
Date |
Latitude |
Number |
Longitude |
Number |
IPAddress |
Text |
Battery |
Text |
DeviceInfo |
Text |
| Property Name | Property Type |
|---|---|
Name |
Title |
Latitude |
Number |
Longitude |
Number |
Radius |
Number |
| Property Name | Property Type |
|---|---|
Setting |
Title |
Value |
Text |
After creating it, add one row: Setting = SignUpEnabled, Value = true
You must give your API key permission to access each database.
- Open the
Usersdatabase page. - Click the
...menu in the top-right corner. - Click "Add connections" and search for your "Locsent API" integration.
- Repeat these steps for
Location_History,Geofences, andAppSettingsdatabases.
- Open each database page. The ID is in the URL:
notion.so/DATABASE_ID?v=... - Copy the IDs for all four databases.
git clone https://github.com/krupal-036/Locsent.git
cd Locsent# For Windows
python -m venv venv
venv\Scripts\activate
# For macOS/Linux
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txt- Create a file in the root directory named
.env. - Fill it with your keys and IDs.
# .env file
FLASK_SECRET_KEY='generate_a_long_random_string_for_security'
NOTION_API_KEY='secret_...'
NOTION_DATABASE_ID_USERS='your_users_database_id'
NOTION_DATABASE_ID_LOCATIONS='your_locations_database_id'
NOTION_DATABASE_ID_GEOFENCES='your_geofences_database_id'
NOTION_DATABASE_ID_SETTINGS='your_appsettings_database_id'- You must manually add your first
Adminuser in your NotionUsersdatabase. - To generate a secure password hash, create a temporary Python file (
hash_generator.py) and run it:# hash_generator.py from flask_bcrypt import Bcrypt password_to_hash = 'your_strong_admin_password' hashed_password = Bcrypt().generate_password_hash(password_to_hash).decode('utf-8') print(f'Your hashed password is:\n{hashed_password}')
python hash_generator.py
- Copy the resulting hash into the
PasswordHashcolumn in Notion. Set theRoletoAdmin.
python run.pyThe application will be available at http://127.0.0.1:5000.
This application is configured for easy deployment on Vercel.
- Push your project to your GitHub repository.
- Go to your Vercel Dashboard and import your
Locsentrepository. - In the project settings on Vercel, go to "Environment Variables" and add the same key-value pairs from your
.envfile. - Click "Deploy". Your application will be live!
This project is licensed under the MIT License — feel free to use and modify it.
Developed by Krupal Fataniya
Feel free to contribute or fork the project!
For any issues, feel free to ask Krupal. 😊
