A comprehensive Flask-based web application for managing users and IT assets with role-based access control, external database integration, and comprehensive reporting capabilities.
A small gesture, a big support! Buy me a coffee β if you appreciate my work. Thanks in advance!
- Administrator: Manages user accounts, roles, and permissions
- Manager: Creates events, accesses reports, and edits materials/users
- Reader: Read-only access to reports and asset/user lists
- Support for multiple asset types: computers, monitors, peripherals, and phones
- Link/unlink assets to users with full audit trail
- Soft delete with trash bin functionality
- Real-time conflict detection when assets are already assigned
- Connect to external user directories (LDAP/AD)
- GLPI inventory system integration
- Auto-completion for user and asset creation
- Fallback to manual entry when external systems unavailable
- Step-by-step wizard for asset assignment/unassignment
- Visual conflict detection with current asset ownership
- Complete audit trail with timestamps and user tracking
- Bulk operations support
- Filter by department, name, date ranges
- Historical movement tracking
- PDF export with formatted data
- Visual analytics with pie charts for asset distribution
- Asset distribution by model, type, and department
- Bootstrap 5 responsive design
- FontAwesome icons
- Intuitive navigation
- Mobile-friendly interface
- Backend: Flask 2.x (Latest Stable)
- Authentication: Flask-Security
- Database: MySQL (bd_userslinker)
- Frontend: Bootstrap 5 + FontAwesome (Free)
- Templates: Jinja2
- Charts: JavaScript charting library for pie charts
- Python 3.8+
- MySQL 5.7+ or MariaDB 10.3+
- pip (Python package installer)
- Virtual environment (recommended)
git clone https://github.com/yourusername/userslinker.git
cd userslinker# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activatepip install -r requirements.txtIn the setup folder update this values
MYSQL_HOST=localhost
MYSQL_USER=root
MYSQL_PASSWORD=your_password_here
MYSQL_DB=bd_userslinker
Create a MySQL database named bd_userslinker and configure your connection settings.
CREATE DATABASE bd_userslinker;Create a bdd.json file in the root directory (outside web-accessible folder) with your external database configurations:
{
"users": {
"connect": {
"host": "your-ldap-server",
"user": "username",
"password": "password",
"db": "database_name",
"table": "users_table"
},
"fields": {
"GivenName": "first_name",
"Surname": "last_name",
"Username": "username",
"email": "email_address",
"Title": "job_title",
"Department": "department",
"Site": "location"
}
},
"computers": {
"connect": {
"host": "glpi-server",
"user": "username",
"password": "password",
"db": "glpi_db",
"table": "glpi_computers"
},
"fields": {
"name": "name",
"serial": "serial",
"otherserial": "otherserial"
}
}
// ... similar configuration for monitors, peripherals, phones
}python manage.py db init
python manage.py db migrate
python manage.py db upgradepython create_admin.py# Development mode
export FLASK_ENV=development
python app.py
# Production mode
export FLASK_ENV=production
python app.pyThe application will be available at http://localhost:5000
Stores application users and their roles
id(INT, PRIMARY KEY, AUTO_INCREMENT)GivenName(VARCHAR(45))Surname(VARCHAR(45))user(VARCHAR(100))password(VARCHAR(255))email(VARCHAR(255))role(VARCHAR(45))
Stores end-users who receive assets
id(INT, PRIMARY KEY, AUTO_INCREMENT)GivenName(VARCHAR(45))Surname(VARCHAR(45))Username(VARCHAR(100))Title(VARCHAR(200))Department(VARCHAR(45))Site(LONGTEXT)date_create(DATETIME)date_mod(DATETIME)date_delete(DATETIME)is_delete(TINYINT(1))app_management_user(VARCHAR(100))
Each asset table contains:
id(INT, PRIMARY KEY, AUTO_INCREMENT)name(VARCHAR(255))serial(VARCHAR(255))otherserial(VARCHAR(255))Username(VARCHAR(255))date_create(DATETIME)date_mod(DATETIME)date_delete(DATETIME)is_delete(TINYINT(1))is_linked(TINYINT(1))app_management_user(VARCHAR(100))
Audit trail for all asset movements
id(INT, PRIMARY KEY, AUTO_INCREMENT)app_management_id(INT)users_id(INT)computers_id(INT)monitors_id(INT)peripherals_id(INT)phones_id(INT)date_mod(DATETIME)is_linked(TINYINT(1))is_delete(TINYINT(1))app_management_user(VARCHAR(100))
- Navigate to
http://localhost:5000 - Login with administrator credentials
- The system will test external database connections (if configured)
- Create additional users and assign roles
- Go to "Create Event" from the main menu
- Select or create a user
- Choose to link or unlink assets
- Follow the step-by-step wizard
- Review and confirm changes
- Access "Lists" menu for asset/user management
- Search, edit, add, or delete items
- Use trash bin for soft deletes
- Permanently delete items from trash when needed
- Navigate to "Reports" section
- Apply filters (department, date range, etc.)
- View historical data and movements
- Export to PDF or view charts
- Analyze asset distribution patterns
# Flask configuration
FLASK_ENV=development|production
SECRET_KEY=your-secret-key-here
# Database configuration
DATABASE_URL=mysql://username:password@host:port/bd_userslinker
# External database configuration path
EXTERNAL_DB_CONFIG=/path/to/bdd.json- The
bdd.jsonfile contains sensitive database credentials and should never be accessible via web browser - Use strong passwords for database connections
- Implement SSL/TLS in production
- Regular backup of the main database
- Monitor access logs for security issues
The application performs automatic health checks on:
- Main database connectivity
- External database connections (if configured)
- File system permissions
- Regular MySQL database backups
- Configuration file backups
- Log file rotation and archival
- Database indexing on frequently queried fields
- Connection pooling for external databases
- Caching for frequently accessed data
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 style guidelines
- Add comprehensive comments for beginners
- Include unit tests for new features
- Update documentation for changes
This project is licensed under the MIT License - see the LICENSE file for details.
userslinker/
βββ app.py # Main application entry point
βββ config.py # Application configuration
βββ requirements.txt # Python dependencies
βββ bdd.json # External DB config (not in repo)
βββ models/ # Database models
β βββ __init__.py
β βββ user.py # User models
β βββ asset.py # Asset models
β βββ history.py # History/audit models
βββ views/ # Application routes
β βββ __init__.py
β βββ auth.py # Authentication routes
β βββ admin.py # Admin functionality
β βββ events.py # Event management
β βββ reports.py # Reporting features
β βββ api.py # API endpoints
βββ templates/ # Jinja2 templates
β βββ base.html
β βββ auth/
β βββ admin/
β βββ events/
β βββ reports/
βββ static/ # Static files
β βββ css/
β βββ js/
β βββ images/
βββ utils/ # Utility functions
β βββ __init__.py
β βββ database.py # DB helper functions
β βββ external_db.py # External DB integration
β βββ reporting.py # Report generation
βββ tests/ # Unit tests
βββ __init__.py
βββ test_models.py
βββ test_views.py
βββ test_utils.py
The manager can access the following functions:
- Create an event: manage links between users and equipment
- Lists: view users and equipment
- Reports: generate reports and statistics
Create an event
This is the most important function. You must follow the steps to assign (link) or retrieve (unlink) equipment for a given user.
Lists
Allows you to view the equipment inventory and create, edit, or delete objects.
Reports
- Report by department: Generates a detailed report of users and their equipment by department.
- Filter by department (required)
- Filter by period (optional)
- Display of linked equipment
- History of movements
- Report by user: Generates a detailed report for a specific user.
- Dynamic user search
- Complete history (all dates)
- Currently linked equipment
- Detailed statistics
- Report by equipment type: Analysis of distribution and usage by equipment type.
- Pie charts
- Detailed statistics
- Utilization rates
- Breakdown by department
- Activity report: analysis of movements and activities over a given period.
- Activity timeline
- Statistics by manager
- Trend charts
- Detailed export
The reader can access the following functions:
- Lists: view users and equipment.
- Reports: generate reports and statistics.
The reader does not have editing rights to lists.
Built with β€οΈ using Flask, Bootstrap, and modern web technologies