A phone number spam detection and contact management system built with Django. Think Truecaller, but your own version! Protect users from spam calls while managing contacts efficiently.
- 📱 Phone number spam detection
- 👥 Contact management
- 🔒 User authentication with JWT
- 🔍 Search functionality
- ⚡ Performance optimized
- 💾 Caching support
Before we dive in, make sure you have:
- Python 3.8 or higher
- pip (Python package manager)
- Git (optional, but recommended)
- A text editor (VS Code, PyCharm, or whatever you prefer)
- A terminal/command prompt
- Coffee ☕ (optional, but highly recommended 😉)
I'll walk you through setting this up on different operating systems. Don't worry, it's easier than it looks!
Open Command Prompt or PowerShell (I'd suggest PowerShell)
-
Clone the repo (if you're using Git)
git clone https://github.com/badalk121/Spam-Sentry cd Spam-Sentry -
Create a virtual environment (keeping things clean!)
python -m venv venv -
Activate it (choose one based on your terminal)
For Command Prompt:
venv\Scripts\activateFor PowerShell:
.\venv\Scripts\Activate.ps1 -
Install requirements
pip install -r requirements.txt -
Set up the database
python manage.py migrate -
Create your superuser (follow the prompts)
python manage.py createsuperuser -
Run the development server
python manage.py runserver
Open Terminal
-
Clone the repo
git clone https://github.com/badalk121/Spam-Sentry.git cd SpamSentry -
Create a virtual environment
python3 -m venv venv -
Activate it
source venv/bin/activate -
Install requirements
pip install -r requirements.txt -
Set up the database
python manage.py migrate -
Create your superuser
python manage.py createsuperuser -
Run the server
python manage.py runserver
Let's test it out! I recommend using either Postman or cURL.
-
Register a new user
curl -X POST [http://localhost:8000/api/users/](http://localhost:8000/api/users/) -H "Content-Type: application/json" -d '{"username":"testuser","phone_number":"+11234567890","password":"testpass123"}' -
Get your token
curl -X POST [http://localhost:8000/api/token/](http://localhost:8000/api/token/) -H "Content-Type: application/json" -d '{"phone_number":"+11234567890","password":"testpass123"}' -
Add a contact (don't forget to replace YOUR_TOKEN)
curl -X POST [http://localhost:8000/api/contacts/](http://localhost:8000/api/contacts/) -H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" -d '{"name":"John Doe","phone_number":"+10987654321"}' -
Report spam
curl -X POST [http://localhost:8000/api/spam/](http://localhost:8000/api/spam/) -H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" -d '{"phone_number":"+10987654321"}'
- Import the provided Postman collection (
SpamSentry.postman_collection.json) - Set up your environment variables:
base_url:http://localhost:8000token: (you'll get this after login)
- Try out the endpoints!
Here are all the endpoints you can play with:
Auth Endpoints: POST /api/users/ - Register new user POST /api/token/ - Get JWT token POST /api/token/refresh/ - Refresh JWT token
Contact Endpoints: GET /api/contacts/ - List contacts POST /api/contacts/ - Create contact GET /api/contacts/1/ - Get contact details PUT /api/contacts/1/ - Update contact DELETE /api/contacts/1/ - Delete contact
Spam Endpoints: POST /api/spam/ - Report spam GET /api/spam/check/ - Check number GET /api/spam/stats/ - Get spam statistics
Windows:
netstat -ano | findstr :8000
taskkill /PID /F
macOS/Linux:
lsof -i :8000
kill -9
Nuclear option (FatBoy):
rm db.sqlite3
python manage.py migrate
Windows PowerShell:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
macOS/Linux:
chmod +x venv/bin/activate
Run all tests
python manage.py test
Run specific tests
python manage.py test apps.users
python manage.py test apps.contacts
python manage.py test apps.spam
Run with coverage
coverage run --source='.' manage.py test
coverage report
Want to deploy to production? Here's what you need to change:
- Update
settings.py:- Set
DEBUG = False - Update
ALLOWED_HOSTS - Configure your production database
- Set up proper cache backend
- Set
- Use a proper web server:
- Nginx + Gunicorn is recommended
- Don't forget SSL certificates!
Found a bug? Want to add a feature? Awesome! Just:
- Fork the repo
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Got questions? Here's how to get help:
- Check the issues tab
- Create a new issue
- Reach out to me at badal.kumar.sde@gmail.com
Developed with efforts and lots of ☕.