Generated on 2025-07-02
Analysis of the ThyWill codebase identified significant cleanup opportunities across 153 Python files, 38 templates, and 20+ environment variables. The codebase shows good architectural patterns but has accumulated unused imports, functions, and incomplete features that can be cleaned up to improve maintainability.
- Total files analyzed: 153 Python files, 38 templates
- Files with issues: 123 (80.4%)
- Total unused imports: 386
- Total unused functions: 136
- Template utilization: 92% (35/38 actively used)
- Environment variables: 20 documented, 2 unused, 5 partially implemented
Most problematic files:
app.py: 43 unused imports (model re-exports from helpers)app_helpers/services/auth_helpers.py: 21 unused imports- Type annotations: 47 unused (
Optional,List,Dict,Any,Tuple) - Database imports: 38 unused (
Session,select,engine) - DateTime utilities: 32 unused (
datetime,timedelta)
Action: Systematic import cleanup, especially in main application file.
- PrayerSkip model: Field inconsistency
- Model defines:
user_id: str(models.py:204) - Query uses:
PrayerSkip.username == user.display_name(prayer_mode.py:254) - Creation uses:
user_id=user.display_name(prayer_mode.py:262) - FIX REQUIRED: Align field name with usage
- Model defines:
Prayer.flagged: Marked deprecated but still used throughout codebase- Action: Complete migration to PrayerAttribute system
User.prayer_style- Defined but never referencedUser.welcome_message_dismissed- Defined but never usedPrayer.project_tag- Defined but never usedAuthenticationRequest.verification_code- Defined but never accessedRole.permissions- JSON permissions system not implementedRole.description,Role.created_at,Role.created_by,Role.is_system_role- Never accessed
EXPORT_RATE_LIMIT_MINUTES- No code referencesEXPORT_CACHE_TTL_MINUTES- No code references
CHANGELOG_DEBUG- Used in changelog_routes.py:73
TEXT_ARCHIVE_COMPRESSION_AFTER_DAYS- Config exists, compression not implementedPRAYER_MODE_ENABLED- Config exists, mode switching not implementedREQUIRE_APPROVAL_FOR_EXISTING_USERS- Configured but inconsistently usedREQUIRE_INVITE_LOGIN_VERIFICATION- Configured but inconsistently usedREQUIRE_VERIFICATION_CODE- Partially implemented
Questions for product decisions:
- Admin routes: 17 unused functions - planned features?
- Archive routes: 6 unused functions - future functionality?
- Authentication routes: 15 unused functions - incomplete features?
- Prayer routes: 13 unused functions - abandoned features?
- Database helpers, validation functions, service utilities
- Many appear to be comprehensive implementations waiting for integration
Action: Review each unused function to determine if it should be integrated or removed.
Main Templates: admin.html, activity.html, feed.html, login.html, etc. Components: base.html, prayer_card.html, notification_badge.html, etc.
flagged_prayer.html- Not found in route analysisunflagged_prayer.html- Not found in route analysisinvite_tree.html- Found route but may be legacy
Action: Verify these 3 templates aren't used via HTMX or dynamic loading.
- Commented code: 91 instances of commented-out code blocks
- Unreachable code: 3 instances (code after return/raise statements)
- Development imports: Many test files have unused imports from refactoring
- GET Routes: 28
- POST Routes: 18
- DELETE Routes: 1
- Main App: 2 routes (health, test-share)
- General: 6 routes (menu, donate, export, etc.)
- Authentication: 13 routes across 4 modules
- Prayer: 11 routes across 4 modules
- User Management: 8 routes
- Admin: 4 routes
- Archive: 7 routes
- Fix PrayerSkip model field inconsistency - Critical bug
- Clean up app.py imports - Remove 43 unused imports
- Remove unused env vars - EXPORT_RATE_LIMIT_MINUTES, EXPORT_CACHE_TTL_MINUTES
- Add missing env var documentation - CHANGELOG_DEBUG
- Unused route handlers: Are these planned features or abandoned code?
- Partial auth features: Complete implementation or remove configuration?
- Text archive compression: Implement or remove from config?
- Role permissions system: Implement JSON permissions or remove unused fields?
- Import cleanup: Remove unused imports across all Python files
- Function review: Evaluate 136 unused functions for integration or removal
- Comment cleanup: Remove 91 commented-out code blocks
- Template verification: Confirm 3 potentially unused templates
- Database field cleanup: Remove or implement unused model fields
/home/wsl/thywill/app.py- 43 unused imports/home/wsl/thywill/app_helpers/services/auth_helpers.py- 21 unused imports/home/wsl/thywill/app_helpers/routes/admin_routes_backup.py- Backup file, can be removed- Test configuration files with unused imports from refactoring
- CLI utility modules with unused type annotations
- PrayerSkip: Fix field name inconsistency (CRITICAL)
- Prayer: Complete flagged field migration
- Role: Implement permissions system or remove unused fields
- User: Remove or implement unused fields (prayer_style, welcome_message_dismissed)
- Modular design: Clear separation between routes, services, models
- Good template organization: 92% utilization with component reuse
- Comprehensive feature set: Multi-device auth, text archives, prayer management
- Safety-first approach: Database protection, environment-based configuration
- Import management: Significant unused import accumulation
- Feature completion: Several partially implemented features
- Code documentation: Some features configured but not documented
- Consistency: Some model fields and usage patterns inconsistent
- Fix PrayerSkip model bug
- Clean up app.py imports
- Update .env.example (remove unused, add missing)
- Review 89 unused route handlers
- Decide on partial auth features
- Evaluate text archive compression needs
- Import cleanup across all files
- Function usage review
- Comment and dead code removal
- Database field optimization
The codebase demonstrates excellent architectural patterns and active development. The "dead code" largely represents incomplete features rather than abandoned functionality, suggesting a healthy development process with forward planning. Cleanup will significantly improve maintainability while preserving the strong modular design.