SISmanager is a Python-based project for managing Student Information Systems, focused on data import/export, deduplication, and backup of student records. It is designed for use in Dockerized environments and uses Poetry for dependency management.
- Data Import/Export: Import data from XLSX files and export to various formats
- Data Deduplication: Intelligent duplicate detection and removal with user confirmation options
- Backup Management: Automated backup creation, verification, and cleanup
- Repository Pattern: Clean separation of data access logic for maintainability
- Comprehensive Testing: Full unit and integration test coverage
- Dockerized Development: Consistent development environment using Docker and Docker Compose
- Configuration Management: Environment-based configuration with sensible defaults
SISmanager follows a modular architecture with clear separation of concerns:
CentralDBRepository: Handles all file I/O operations for the central CSV databaseXLSXImporter: Manages XLSX file import, processing, and data transformationBackupManager: Provides backup creation, verification, and cleanup functionalityconfig: Centralized configuration and logging management
- Import: XLSX files are read and processed with automatic orderCode generation
- Backup: Automatic backup creation before any data modifications
- Append: New data is appended to the central database
- Deduplicate: Intelligent duplicate detection with optional user confirmation
- Export: Data can be exported to XLSX with optional column filtering
- Docker and Docker Compose (recommended)
- OR Python 3.10+ and Poetry for local development
-
Clone the repository:
git clone <repo-url> cd SISmanager
-
Build and start the containers:
docker-compose up --build
-
Install Poetry if not already installed:
curl -sSL https://install.python-poetry.org | python3 - -
Install dependencies:
poetry install
-
Activate the virtual environment:
poetry shell
SISmanager uses environment variables for configuration. All configuration options have sensible defaults.
| Variable | Default | Description |
|---|---|---|
SISMANAGER_DATA_DIR |
./data |
Directory for data files |
SISMANAGER_BACKUP_DIR |
./data/backups |
Directory for backup files |
SISMANAGER_CENTRAL_DB_PATH |
./data/central_db.csv |
Path to central database file |
SISMANAGER_LOG_LEVEL |
INFO |
Logging level (DEBUG, INFO, WARNING, ERROR) |
SISMANAGER_DB_TYPE |
csv |
Database type (future: sqlite, postgresql) |
SISMANAGER_DB_URL |
"" |
Database connection URL (for future use) |
Create a .env file in the project root:
SISMANAGER_DATA_DIR=/custom/data/path
SISMANAGER_LOG_LEVEL=DEBUG
SISMANAGER_BACKUP_DIR=/custom/backup/pathfrom src.xlsx_importer import XLSXImporter
# Import an XLSX file
importer = XLSXImporter("data/orders.xlsx")
importer.process()
# Remove duplicates (with confirmation)
importer.remove_duplicates(mode="soft")
# Export to XLSX
importer.export_to_xlsx("output/exported_data.xlsx")from src.xlsx_importer import XLSXImporter
# Import only specific columns
columns_to_keep = ['idOrderPos', 'descrizioneMateriale', 'quantity']
importer = XLSXImporter("data/orders.xlsx", columns_to_keep=columns_to_keep)
importer.process()from src.central_db_repository import CentralDBRepository
import pandas as pd
# Create repository instance
repo = CentralDBRepository()
# Read current data
data = repo.read()
print(f"Current records: {len(data)}")
# Add new data
new_data = pd.DataFrame({
'orderCode': ['ORDER001'],
'quantity': [10]
})
repo.append(new_data)
# Export with column filtering
repo.export_to_xlsx("filtered_export.xlsx", columns=['orderCode', 'quantity'])from src.backup import BackupManager
# Create backup manager
backup_manager = BackupManager()
# Create backup
backup_manager.backup_central_db()
# Clean old backups (older than 30 days)
deleted_count, freed_space = backup_manager.delete_old_backups(days=30)
print(f"Deleted {deleted_count} old backups, freed {freed_space/1024/1024:.2f} MB")SISmanager includes comprehensive test coverage with both unit and integration tests.
# Run all tests
poetry run pytest
# Run only unit tests
poetry run pytest tests/unit/
# Run only integration tests
poetry run pytest tests/integration/
# Run tests with coverage report
poetry run pytest --cov=src --cov-report=html
# Run specific test file
poetry run pytest tests/unit/test_central_db_repository.py-
Unit Tests (
tests/unit/): Test individual components in isolationtest_central_db_repository.py: Database operationstest_xlsx_importer.py: XLSX import functionalitytest_backup_manager.py: Backup operationstest_config.py: Configuration management
-
Integration Tests (
tests/integration/): Test complete workflowstest_workflows.py: End-to-end import, backup, and export flows
-
Test Fixtures (
tests/fixtures/): Sample data files for testing
Current test coverage includes:
- ✅ 62 unit tests covering all core modules
- ✅ 9 integration tests covering complete workflows
- ✅ Error handling and edge cases
- ✅ Backup and rollback scenarios
- ✅ Data validation and integrity checks
The project maintains high code quality standards:
# Run all linting and formatting
poetry run bash lint.sh
# Individual tools
poetry run black src/ tests/ # Code formatting
poetry run pylint src/ tests/ # Code quality analysis
poetry run mypy src/ tests/ # Type checkingSISmanager/
├── pyproject.toml
├── poetry.lock
├── run.py # Application entry point (create this if missing)
├── config.py # Configuration
├── sismanager/ # Main package
│ ├── __init__.py
│ ├── models/
│ │ ├── __init__.py
│ │ ├── student.py
│ │ ├── part.py
│ │ └── money.py
│ ├── blueprints/
│ │ ├── __init__.py
│ │ ├── main/
│ │ │ ├── __init__.py
│ │ │ ├── routes.py
│ │ │ └── templates/
│ │ ├── importer/
│ │ │ ├── __init__.py
│ │ │ ├── routes.py
│ │ │ ├── forms.py
│ │ │ └── templates/
│ │ ├── calendar/
│ │ ├── materials/
│ │ └── money/
│ ├── services/
│ │ ├── __init__.py
│ │ ├── csv_service.py
│ │ ├── backup_service.py
│ │ └── import_service.py
│ ├── utils/
│ │ ├── __init__.py
│ │ ├── validators.py
│ │ └── helpers.py
│ ├── static/
│ │ ├── css/
│ │ ├── js/
│ │ └── img/
│ └── templates/
│ └── base.html
├── data/
│ ├── central_db.csv
│ ├── backups/
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ ├── fixtures/
│ ├── integration/
│ └── unit/
├── deployment/
│ ├── windows/
│ └── docker/
└── scripts/ # (optional, for CLI/test scripts)
└── run_xlsx_to_centraldb.py
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Make your changes and add tests
- Run the test suite:
poetry run pytest - Run linting:
poetry run bash lint.sh - Commit your changes:
git commit -am 'Add new feature' - Push to the branch:
git push origin feature/new-feature - Submit a pull request
- Chunked Processing: For large files, consider processing data in chunks
- Memory Usage: The system loads entire XLSX files into memory
- Backup Storage: Regular cleanup of old backups is recommended
- Progress Tracking: Import operations show progress bars for large files
# Place XLSX files in data/ directory
poetry run python src/run_xlsx_to_centraldb.pyfrom src.central_db_repository import CentralDBRepository
repo = CentralDBRepository()
# Remove duplicates with confirmation
duplicates_removed = repo.deduplicate(mode="soft")
print(f"Removed {duplicates_removed} duplicates")from src.central_db_repository import CentralDBRepository
repo = CentralDBRepository()
# Export specific columns for reporting
repo.export_to_xlsx(
"reports/monthly_report.xlsx",
columns=["orderCode", "descrizioneMateriale", "quantity"]
)- Import Errors: Check that XLSX files are in the correct format and accessible
- Permission Errors: Ensure the application has write access to data directories
- Memory Issues: For very large files, consider breaking them into smaller chunks
- Backup Failures: Check available disk space and file permissions
Logs are written to both console and sismanager.log file. Increase log level for debugging:
export SISMANAGER_LOG_LEVEL=DEBUG[Add your license information here]
For questions or issues, please:
- Check the troubleshooting section above
- Review existing issues in the repository
- Create a new issue with detailed information about your problem