Complete reorganization of project documentation to improve discoverability, navigation, and maintainability. All documentation has been restructured into a clear, role-based hierarchy. ## Major Changes ### New Directory Structure - Created `docs/api/` for API documentation - Created `docs/admin/` with subdirectories: - `admin/configuration/` - Configuration guides - `admin/deployment/` - Deployment guides - `admin/security/` - Security documentation - `admin/monitoring/` - Monitoring and analytics - Created `docs/development/` for developer documentation - Created `docs/guides/` for user-facing guides - Created `docs/reports/` for analysis reports and summaries - Created `docs/changelog/` for detailed changelog entries (ready for future use) ### File Organization #### Moved from Root Directory (40+ files) - Implementation notes → `docs/implementation-notes/` - Test reports → `docs/testing/` - Analysis reports → `docs/reports/` - User guides → `docs/guides/` #### Reorganized within docs/ - API documentation → `docs/api/` - Administrator documentation → `docs/admin/` (with subdirectories) - Developer documentation → `docs/development/` - Security documentation → `docs/admin/security/` - Telemetry documentation → `docs/admin/monitoring/` ### Documentation Updates #### docs/README.md - Complete rewrite with improved navigation - Added visual documentation map - Organized by role (Users, Administrators, Developers) - Better categorization and quick links - Updated all internal links to new structure #### README.md (root) - Updated all documentation links to reflect new structure - Fixed 8 broken links #### app/templates/main/help.html - Enhanced "Where can I get additional help?" section - Added links to new documentation structure - Added documentation index link - Added admin documentation link for administrators - Improved footer with organized documentation links - Added "Complete Documentation" section with role-based links ### New Index Files - Created README.md files for all new directories: - `docs/api/README.md` - `docs/guides/README.md` - `docs/reports/README.md` - `docs/development/README.md` - `docs/admin/README.md` ### Cleanup - Removed empty `docs/security/` directory (moved to `admin/security/`) - Removed empty `docs/telemetry/` directory (moved to `admin/monitoring/`) - Root directory now only contains: README.md, CHANGELOG.md, LICENSE ## Results **Before:** - 45+ markdown files cluttering root directory - Documentation scattered across root and docs/ - Difficult to find relevant documentation - No clear organization structure **After:** - 3 files in root directory (README, CHANGELOG, LICENSE) - Clear directory structure organized by purpose and audience - Easy navigation with role-based organization - All documentation properly categorized - Improved discoverability ## Benefits 1. Better Organization - Documentation grouped by purpose and audience 2. Easier Navigation - Role-based sections (Users, Admins, Developers) 3. Improved Discoverability - Clear structure with README files in each directory 4. Cleaner Root - Only essential files at project root 5. Maintainability - Easier to add and organize new documentation ## Files Changed - 40+ files moved from root to appropriate docs/ subdirectories - 15+ files reorganized within docs/ - 3 major documentation files updated (docs/README.md, README.md, help.html) - 5 new README index files created - 2 empty directories removed All internal links have been updated to reflect the new structure.
7.7 KiB
Implementation Summary: Default Data Seeding Fix
✅ Issue Resolved
Problem: Default client and project were being re-created after deletion during updates from version 3.2.2 to 3.2.3.
Solution: Implemented a persistent flag-based tracking system to ensure default data is only seeded on fresh database installations.
📋 Changes Made
1. Core Implementation
app/utils/installation.py - Added Tracking Methods
-
Method:
is_initial_data_seeded()- Returnsbool- Checks if initial database data has been created
- Returns
Falsefor new installations
-
Method:
mark_initial_data_seeded()- ReturnsNone- Marks that initial data has been created
- Stores timestamp in
installation.json - Persists across restarts and updates
2. Database Initialization Scripts Updated
docker/init-database.py
- Imports
InstallationConfig - Checks flag before creating default project/client
- Only creates defaults if:
- Flag is not set AND
- No projects exist in database
- Marks flag after seeding or if projects exist
docker/init-database-enhanced.py
- Imports
InstallationConfigwith proper path handling - Checks project count via SQL query
- Conditional default data creation based on flag
- Marks flag appropriately
docker/init-database-sql.py
- Imports
InstallationConfigwith proper path handling - Separates base SQL (admin, settings) from default data SQL
- Only executes default data SQL if:
- Flag is not set AND
- Project count is 0
- Marks flag after seeding
3. Test Coverage
tests/test_installation_config.py - Added 3 New Tests
-
test_initial_data_seeding_tracking()- ✅ Verifies flag defaults to
False - ✅ Verifies
mark_initial_data_seeded()sets flag toTrue - ✅ Verifies flag persists across
InstallationConfiginstances
- ✅ Verifies flag defaults to
-
test_initial_data_seeding_persistence()- ✅ Verifies flag is written to
installation.json - ✅ Verifies timestamp is recorded
- ✅ Verifies file format is correct
- ✅ Verifies flag is written to
-
test_initial_data_seeding_default_value()- ✅ Verifies new installations default to
False
- ✅ Verifies new installations default to
Test Results: All 10 tests pass (3 new + 7 existing)
4. Documentation
Created: docs/DEFAULT_DATA_SEEDING.md
Comprehensive documentation including:
- Behavior overview (old vs new)
- Implementation details
- Testing instructions
- Troubleshooting guide
- Reset/recovery procedures
- Migration notes
Created: DEFAULT_DATA_SEEDING_FIX_CHANGELOG.md
Detailed changelog including:
- Problem description
- Solution explanation
- Files modified
- Testing performed
- Migration path
- Backward compatibility notes
🎯 Behavior Changes
Before (v3.2.2)
1. User deletes "Default Client" and "General" project
2. Container restarts or updates
3. ❌ Default client and project are RECREATED
4. User has to delete them again
After (v3.2.3+)
1. Fresh installation → Creates defaults → Sets flag
2. User deletes defaults → Flag remains set
3. Container restarts or updates → Flag is checked → ✅ Defaults NOT recreated
4. User's choice is respected permanently
📊 Configuration File
data/installation.json
{
"telemetry_salt": "...",
"installation_id": "...",
"setup_complete": true,
"initial_data_seeded": true,
"initial_data_seeded_at": "2025-10-23 09:12:34.567890"
}
✅ Verification Checklist
- InstallationConfig methods added
- All 3 database initialization scripts updated
- Unit tests added (3 new tests)
- All tests pass (10/10)
- No linter errors
- Documentation created
- Changelog created
- Backward compatible
- No breaking changes
🔧 Technical Details
Logic Flow
# During database initialization
installation_config = get_installation_config()
if not installation_config.is_initial_data_seeded():
# First time initialization
if project_count == 0:
# Truly fresh database
create_default_client()
create_default_project()
installation_config.mark_initial_data_seeded()
else:
# Database has projects, just mark as seeded
installation_config.mark_initial_data_seeded()
else:
# Already seeded before, skip
print("Initial data already seeded, skipping...")
State Machine
┌─────────────────────┐
│ Fresh Installation │
│ (no projects) │
└──────┬──────────────┘
│
├── Create defaults
├── Set flag = true
│
▼
┌─────────────────────┐
│ Flag Set = True │
│ (seeded) │
└──────┬──────────────┘
│
├── User deletes defaults
├── Flag remains true
│
▼
┌─────────────────────┐
│ Next Restart │
│ Check flag = true │
└──────┬──────────────┘
│
└── Skip creation ✅
🚀 Deployment
For Existing Installations (Upgrading from v3.2.2)
- Pull latest code (v3.2.3+)
- Restart container
docker-compose restart - First startup:
- System detects existing projects
- Sets
initial_data_seeded = true - Does NOT create defaults
- Result: Previously deleted defaults remain deleted ✅
For Fresh Installations
- Deploy v3.2.3+
- First startup:
- System detects no projects
- Creates "Default Client" and "General"
- Sets
initial_data_seeded = true
- User can delete defaults
- Defaults will never be recreated ✅
🐛 Troubleshooting
Issue: Flag Not Being Set
Symptoms: Default data keeps being created
Check:
# Check if file exists and is writable
ls -la data/installation.json
# Check file contents
cat data/installation.json | grep initial_data_seeded
Fix:
# Ensure directory is writable
chmod 755 data/
chmod 644 data/installation.json
Issue: Need to Reset Defaults
Solution 1 - Remove flag:
# Edit installation.json and remove initial_data_seeded lines
nano data/installation.json
Solution 2 - Fresh start:
# Complete reset
docker-compose down -v
rm data/installation.json
docker-compose up -d
📈 Benefits
- ✅ User Control: Users can delete defaults without them reappearing
- ✅ Predictable Behavior: Once deleted, stays deleted
- ✅ Update Safety: Updates respect user's data choices
- ✅ Zero Migration: Works automatically on upgrade
- ✅ Backward Compatible: No manual intervention needed
🔗 Related Files
Modified Files
app/utils/installation.pydocker/init-database.pydocker/init-database-enhanced.pydocker/init-database-sql.pytests/test_installation_config.py
Created Files
docs/DEFAULT_DATA_SEEDING.mdDEFAULT_DATA_SEEDING_FIX_CHANGELOG.mdIMPLEMENTATION_SUMMARY_DEFAULT_DATA_SEEDING.md(this file)
✨ Summary
Status: ✅ COMPLETE AND TESTED
The default data seeding behavior has been successfully fixed. Users who delete the default client and project will no longer see them re-created during updates or restarts. The implementation uses a persistent flag in the installation configuration that tracks whether initial data has been seeded, providing predictable and user-friendly behavior across all scenarios.
Version: 3.2.3+
Date: October 23, 2025
Tests: 10/10 passing
Linter: No errors
Backward Compatible: Yes ✅