Refactor Monolith to Modular Architecture

Break down a monolithic file into clean, maintainable modules.

category:modernization
refactor
architecture
modularization
backend
0

Prompt

You are refactoring a legacy monolithic file.

Goal: split this file into a small set of cohesive modules.

Rules:
- Group code by responsibility (auth, data access, domain logic, helpers)
- Extract reusable functions from duplicated inline logic
- Create clear public interfaces (exported functions/types only)
- Avoid circular dependencies
- Add comments explaining module boundaries

Return:
- Proposed folder structure
- New module files (with code)
- Updated imports in the original entry point.