A professional, feature-rich Python-based contact management system with a clean command-line interface, data persistence, and comprehensive validation. Perfect for learning Python development best practices or managing your contacts efficiently.
| Features | Installation | Usage | Development | Contributing |
# Clone the repository
git clone https://github.com/pyenthusiasts/Contact-Manager.git
cd Contact-Manager
# Run directly (no installation needed)
python run.py
# Clone the repository
git clone https://github.com/pyenthusiasts/Contact-Manager.git
cd Contact-Manager
# Install in development mode
pip install -e .
# Run from anywhere
contact-manager
# Clone and install
git clone https://github.com/pyenthusiasts/Contact-Manager.git
cd Contact-Manager
pip install .
# Run
contact-manager
# From the project directory
python -m contact_manager
# Build image
docker build -t contact-manager .
# Run container
docker run -it --rm -v $(pwd)/data:/app/data contact-manager
# Or use docker-compose
docker-compose up
# Unix/Linux/macOS
./scripts/setup_dev.sh
# Windows
scripts\setup_dev.bat
When you run the application without arguments, you’ll see an interactive menu:
==================================================
CONTACT MANAGER v2.0
==================================================
1. Add New Contact
2. Search Contacts
3. Display All Contacts
4. Update Contact
5. Delete Contact
6. Export Contacts
7. View Statistics
8. Exit
==================================================
Enter your choice (1-8): 1
--- Add New Contact ---
Enter name: John Doe
Enter email: john.doe@example.com
Enter phone number: 123-456-7890
Enter address (optional): 123 Main Street, New York, NY 10001
Enter notes (optional): Important client from ABC Corp
Contact 'John Doe' added successfully!
Search supports partial matching and is case-insensitive:
Enter your choice (1-8): 2
--- Search Contacts ---
Enter search query (name/email/phone): john
Found 2 contact(s):
--------------------------------------------------------------------------------
1. Name: John Doe, Email: john.doe@example.com, Phone: 123-456-7890, Address: 123 Main Street, New York, NY 10001, Notes: Important client from ABC Corp
2. Name: Johnny Smith, Email: johnny@example.com, Phone: 555-1234
--------------------------------------------------------------------------------
Enter your choice (1-8): 3
================================================================================
Contacts List (5 total)
================================================================================
1. Name: John Doe, Email: john.doe@example.com, Phone: 123-456-7890, Address: 123 Main Street, New York, NY 10001
2. Name: Jane Smith, Email: jane@example.com, Phone: 987-654-3210
...
================================================================================
Enter your choice (1-8): 4
--- Update Contact ---
Enter email of contact to update: john.doe@example.com
Current details: Name: John Doe, Email: john.doe@example.com, Phone: 123-456-7890
Enter new values (press Enter to keep current value):
Name [John Doe]: John M. Doe
Email [john.doe@example.com]:
Phone [123-456-7890]: +1-123-456-7890
Address [123 Main Street, New York, NY 10001]:
Notes [Important client from ABC Corp]: VIP client
Contact 'John M. Doe' updated successfully!
Enter your choice (1-8): 5
--- Delete Contact ---
Enter email of contact to delete: old@example.com
Contact to delete: Name: Old Contact, Email: old@example.com, Phone: 111-1111
Are you sure? (yes/no): yes
Contact 'Old Contact' deleted successfully!
Export to JSON:
Enter your choice (1-8): 6
--- Export Contacts ---
Supported formats: JSON (.json), CSV (.csv)
Enter export file path: exports/my_contacts.json
Contacts exported successfully to 'exports/my_contacts.json'!
Export to CSV:
Enter export file path: exports/contacts.csv
Contacts exported successfully to 'exports/contacts.csv'!
Enter your choice (1-8): 7
--- Contact Statistics ---
Total Contacts: 15
Contacts with Address: 10
Contacts with Notes: 5
Contact Manager also supports non-interactive CLI usage:
# Add a contact
contact-manager add "John Doe" john@example.com "555-1234" --address "123 Main St" --notes "Client"
# Search contacts
contact-manager search john
# List all contacts
contact-manager list
# Delete a contact
contact-manager delete john@example.com --force
# Export contacts
contact-manager export contacts.csv
# View statistics
contact-manager stats
# Specify custom storage location
contact-manager --storage ~/my-contacts.json list
# Enable debug logging
contact-manager --log-level DEBUG --log-file app.log
For development tasks:
# Show all available commands
make help
# Install for development
make install-dev
# Run tests
make test
# Run tests with coverage
make test-cov
# Format code
make format
# Run linters
make lint
# Type checking
make type-check
# Clean generated files
make clean
# Generate demo data
make demo
# Build Docker image
make docker-build
# Run all checks (clean, install, lint, test)
make all
Contact-Manager/
├── .github/
│ ├── workflows/
│ │ └── ci.yml # GitHub Actions CI/CD
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md # Bug report template
│ │ └── feature_request.md # Feature request template
│ └── pull_request_template.md # PR template
├── src/
│ └── contact_manager/
│ ├── __init__.py # Package initialization
│ ├── __main__.py # Entry point for -m flag
│ ├── models.py # Contact data model
│ ├── validation.py # Input validation utilities
│ ├── storage.py # Data persistence layer
│ ├── manager.py # Contact management logic
│ ├── ui.py # Interactive user interface
│ ├── cli.py # Command-line interface
│ └── logger.py # Logging configuration
├── tests/
│ ├── __init__.py
│ ├── test_models.py # Model tests
│ ├── test_validation.py # Validation tests
│ └── test_manager.py # Manager tests
├── scripts/
│ ├── generate_demo_data.py # Demo data generator
│ ├── setup_dev.sh # Dev setup (Unix)
│ └── setup_dev.bat # Dev setup (Windows)
├── legacy/
│ └── contact_manager_v1.py # Original implementation
├── data/ # Auto-created for storing contacts
│ └── contacts.json
├── run.py # Convenience script to run app
├── setup.py # Package installation script
├── pyproject.toml # Modern Python project config
├── requirements.txt # Core dependencies
├── requirements-dev.txt # Development dependencies
├── Makefile # Development tasks automation
├── Dockerfile # Docker container definition
├── docker-compose.yml # Docker Compose configuration
├── .dockerignore # Docker ignore rules
├── pytest.ini # Pytest configuration
├── .flake8 # Flake8 linter config
├── .pre-commit-config.yaml # Pre-commit hooks
├── .gitignore # Git ignore rules
├── CONTRIBUTING.md # Contribution guidelines
├── CODE_OF_CONDUCT.md # Code of conduct
├── SECURITY.md # Security policy
├── CHANGELOG.md # Version history
├── LICENSE # MIT License
└── README.md # This file
# Install development dependencies
pip install -e ".[dev]"
# Run all tests
pytest
# Run with coverage
pytest --cov=contact_manager --cov-report=html
# Run specific test file
pytest tests/test_models.py
# Run with verbose output
pytest -v
The project follows Python best practices:
Accepts various phone number formats:
123-456-7890(123) 456-7890123.456.78901234567890+1 123 456 7890Contacts are automatically saved to data/contacts.json in the following format:
[
{
"name": "John Doe",
"email": "john@example.com",
"phone": "123-456-7890",
"address": "123 Main St",
"notes": "Important client",
"created_at": "2024-01-15T10:30:00.000000",
"updated_at": "2024-01-15T10:30:00.000000"
}
]
JSON: Full contact information including timestamps CSV: Simplified format (name, email, phone, address, notes)
models.py)validation.py)storage.py)manager.py)ui.py)Contributions are welcome! Here’s how you can help:
git clone https://github.com/your-username/Contact-Manager.git
git checkout -b feature/your-feature-name
pytest
git commit -m "Add: feature description"
git push origin feature/your-feature-name
Potential future enhancements:
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
| Made with Python | GitHub | Report Bug | Request Feature |