File size: 3,407 Bytes
f0b765c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Scripts Directory

This directory contains organized scripts for various development, deployment, and maintenance tasks.

## Directory Structure

### `utilities/`
Development and maintenance utility scripts:
- **`backup_and_analyze.py`** - Creates timestamped backups and analyzes codebase structure
- **`view_analysis.py`** - Views and filters analysis results
- **`cleanup_cache.py`** - Removes Python cache files and temporary artifacts
- **`validate_gitignore.py`** - Validates and updates .gitignore rules
- **`archive_migration_files.py`** - Archives completed migration files

### `deployment/`
Deployment and production setup scripts:
- **`create_user_indexes.py`** - Creates necessary database indexes for user authentication
- **`start.sh`** - Application startup script for deployment environments

### `maintenance/`
Ongoing maintenance and analysis scripts:
- **`run_analysis.sh`** - Wrapper script for running backup and analysis processes

## Usage

### Running Full Analysis
```bash
# Run complete backup and analysis
./scripts/maintenance/run_analysis.sh

# Or run directly with Python
python3 scripts/utilities/backup_and_analyze.py
```

### Viewing Results
```bash
# Show analysis summary
python3 scripts/utilities/view_analysis.py summary

# Show files of specific type
python3 scripts/utilities/view_analysis.py type migration
python3 scripts/utilities/view_analysis.py type python_cache

# Show files with specific suggested action
python3 scripts/utilities/view_analysis.py action archive
python3 scripts/utilities/view_analysis.py action delete

# Show dependency information
python3 scripts/utilities/view_analysis.py deps
python3 scripts/utilities/view_analysis.py deps app.py
```

## File Types Detected

- **python_source**: Regular Python source files
- **python_test**: Python test files (test_*.py, *_test.py)
- **python_cache**: Cache files (__pycache__, *.pyc)
- **documentation**: Markdown, text, and documentation files
- **configuration**: JSON, YAML, config files
- **migration**: Migration and rollback scripts
- **backup**: Backup files
- **deployment**: Deployment-related files
- **data**: Database and data files
- **unknown**: Unrecognized file types

## Suggested Actions

- **keep**: File should be retained as-is
- **move**: File should be moved to different location
- **archive**: File should be moved to archive directory
- **delete**: File can be safely deleted
- **consolidate**: File may be redundant and should be merged
- **rename**: File should be renamed for consistency

## Output Files

- **`analysis_report.json`**: Complete analysis results in JSON format
- **`backups/codebase_backup_YYYYMMDD_HHMMSS/`**: Timestamped backup directory
- **`backups/codebase_backup_YYYYMMDD_HHMMSS/backup_manifest.json`**: Backup metadata

## Requirements Addressed

This infrastructure addresses the following requirements from the codebase cleanup specification:

- **Requirement 1.1**: Clean and organized codebase structure analysis
- **Requirement 1.2**: File organization and Python project conventions analysis

## Safety Features

- **Automatic backups**: Complete codebase backup before any analysis
- **Exclusion patterns**: Excludes virtual environments, git, and cache directories from backup
- **Dependency tracking**: Maps import relationships to prevent breaking changes
- **Rollback capability**: Backup manifest enables easy restoration if needed