Migration Guide: v0.7.x to v0.8.0¶
Complete guide for migrating from the old directory structure to the new src-layout.
Release Date: 2025-11-06 Breaking Changes: Yes Migration Effort: Low (15-30 minutes)
๐ Summary of Changes¶
Version 0.8.0 introduces a complete restructuring to adopt Python's standard src-layout. This brings better organization, clearer package boundaries, and follows Python best practices.
Major Changes¶
- All code moved to
src/codebase_rag/ - All old entry scripts removed
- Import paths updated
- New standardized entry points
- Backward compatibility removed
๐จ Breaking Changes¶
1. Entry Scripts Removed¶
Old (โ No longer works):
New (โ Use these instead):
# Direct module invocation
python -m codebase_rag # Start both services
python -m codebase_rag --web # Web only
python -m codebase_rag --mcp # MCP only
python -m codebase_rag --version
# After installation (pip install -e .)
codebase-rag # Main CLI
codebase-rag-web # Web server
codebase-rag-mcp # MCP server
2. Import Paths Changed¶
Old (โ No longer works):
from config import settings
from services.neo4j_knowledge_service import Neo4jKnowledgeService
from services.memory_store import MemoryStore
from core.app import create_app
from api.routes import router
from mcp_tools.utils import some_function
New (โ Use these instead):
from src.codebase_rag.config import settings
from src.codebase_rag.services.knowledge import Neo4jKnowledgeService
from src.codebase_rag.services.memory import MemoryStore
from src.codebase_rag.core.app import create_app
from src.codebase_rag.api.routes import router
from src.codebase_rag.mcp.utils import some_function
3. Directory Structure Changed¶
Old Structure (โ Removed):
codebase-rag/
โโโ api/ # โ Deleted
โโโ core/ # โ Deleted
โโโ services/ # โ Deleted
โโโ mcp_tools/ # โ Deleted
โโโ config.py # โ Deleted
โโโ main.py # โ Deleted
โโโ start.py # โ Deleted
โโโ start_mcp.py # โ Deleted
New Structure (โ Current):
codebase-rag/
โโโ src/
โ โโโ codebase_rag/ # โ
All code here
โ โโโ __init__.py
โ โโโ __main__.py
โ โโโ config/
โ โโโ server/
โ โโโ core/
โ โโโ api/
โ โโโ services/
โ โโโ mcp/ # Renamed from mcp_tools
โโโ pyproject.toml # โ
Updated
โโโ docs/
โโโ tests/
โโโ ...
4. Docker Changes¶
Dockerfile CMD changed:
๐ Migration Steps¶
For End Users (Docker Deployment)¶
If you're using Docker, no changes needed! Just pull the new image:
# Pull latest
docker pull royisme/codebase-rag:latest
# Or rebuild
docker-compose down
docker-compose pull
docker-compose up -d
For Developers (Local Development)¶
Step 1: Update Repository¶
# Pull latest changes
git pull origin main
# Or if on a branch
git fetch origin
git rebase origin/main
Step 2: Reinstall Package¶
# Remove old installation
pip uninstall code-graph -y
# Reinstall with new structure
pip install -e .
# Or with uv
uv pip install -e .
Step 3: Update Your Code¶
Update all import statements in your custom scripts/tools:
# Old imports (need to update)
from config import settings
from services.xxx import Yyy
# New imports
from src.codebase_rag.config import settings
from src.codebase_rag.services.xxx import Yyy
Find all files to update:
# Search for old imports in your codebase
grep -r "from config import" .
grep -r "from services\." .
grep -r "from core\." .
grep -r "from api\." .
grep -r "from mcp_tools\." .
Step 4: Update Entry Scripts¶
If you have custom scripts that call the server:
# Old
if __name__ == "__main__":
from start import main
main()
# New
if __name__ == "__main__":
from src.codebase_rag.server.web import main
main()
Or better, use the standard module invocation:
Step 5: Update MCP Configurations¶
If using MCP (Claude Desktop, Cursor, etc.):
Old claude_desktop_config.json:
{
"mcpServers": {
"codebase-rag": {
"command": "python",
"args": ["/path/to/codebase-rag/start_mcp.py"]
}
}
}
New:
{
"mcpServers": {
"codebase-rag": {
"command": "python",
"args": ["-m", "codebase_rag", "--mcp"],
"cwd": "/path/to/codebase-rag"
}
}
}
Or after installation:
๐งช Testing Your Migration¶
After migration, test all functionality:
1. Test Import Paths¶
# Test configuration import
from src.codebase_rag.config import settings
print(f"โ
Config: {settings.app_name}")
# Test service imports
from src.codebase_rag.services.knowledge import Neo4jKnowledgeService
print("โ
Services import successful")
2. Test Entry Points¶
# Test version
python -m codebase_rag --version
# Should output: codebase-rag version 0.8.0
# Test help
python -m codebase_rag --help
# Test web server (Ctrl+C to stop)
python -m codebase_rag --web
3. Test Docker¶
# Build test image
docker build -t codebase-rag:test .
# Run test container
docker run -p 8000:8000 -p 8080:8080 codebase-rag:test
# Check health
curl http://localhost:8080/api/v1/health
4. Run Tests¶
# Run test suite
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=src/codebase_rag --cov-report=html
๐ Common Issues¶
Issue 1: ModuleNotFoundError¶
Error:
Solution: Update import to new path:
Issue 2: start.py not found¶
Error:
Solution: Use new entry point:
Issue 3: Old imports in tests¶
Error:
Solution: Update test imports:
Issue 4: Docker container fails to start¶
Error:
Solution: Rebuild Docker image:
๐ฏ Benefits of New Structure¶
1. Standard Python Package¶
- โ Follows PyPA src-layout recommendations
- โ
Proper package namespace (
codebase_rag) - โ Cleaner imports
2. Better Organization¶
- โ
All source code in
src/ - โ Clear separation of concerns
- โ Logical service grouping
3. Easier Development¶
- โ
Standard entry points (
python -m codebase_rag) - โ Proper console scripts after installation
- โ No confusion about root vs package code
4. Improved Maintainability¶
- โ No duplicate code
- โ Clear module boundaries
- โ Easier to navigate for new contributors
๐ Additional Resources¶
๐ Need Help?¶
If you encounter issues not covered in this guide:
- Check Troubleshooting
- Check FAQ
- Open an issue on GitHub
- Ask in Discussions
Last Updated: 2025-11-06 Next Version: 0.9.0 (planned)