PhoneSaver is a modern contact management app built with SwiftUI for the frontend and Go (using the Gin framework) for the backend. It provides a seamless way to manage contacts with features like contact tagging, one-tap communication, scheduled reminders, encrypted contacts, and cloud backups via Firebase. The app uses a MySQL database to store contact data securely and integrates Firebase for backup functionality.
- Features
- Project Structure
- Tech Stack
- Prerequisites
- Setup Instructions
- Usage
- API Endpoints
- Screenshots
- Contributing
- License
- Contact Tagging: Organize contacts with custom tags (e.g., "Work", "Family").
- One-Tap Communication: Call or message contacts directly from the app.
- Scheduled Reminders: Set follow-up reminders for contacts using local notifications.
- Encrypted Contacts: Securely store phone numbers using CryptoKit for encryption.
- Cloud Backups: Back up contacts to Firebase for easy syncing and recovery.
- Insights: View last interaction dates and birthdays for each contact.
- Temporary Sharing: Share contacts via temporary links (stored in the share_links table).
- Dark Mode Support: Fully responsive UI with dark mode support.
phoneSaver/
├── ios-app/ # iOS frontend application (SwiftUI)
│ ├── Assets.xcassets/ # App assets
│ ├── Views/ # SwiftUI view components
│ └── Models/ # Data models
├── backend/ # Go backend server
│ ├── main.go # Main server code
│ ├── phoneS/ # Backend services
│ └── config/ # Configuration files
└── android-app/ # Placeholder for Android version
│ ├── go.mod # Go module dependencies
│ ├── go.sum # Dependency checksums
│ └── serviceAccountKey.json # Firebase service account key (not included in repo)
├── README.md # This file
├── LICENSE # License file (MIT License)
└── .env.example # Environment variables template
- Frontend: SwiftUI, CryptoKit, UserNotifications, Firebase SDK
- Backend: Go, Gin framework, MySQL, Firebase Admin SDK
- Database: MySQL
- Cloud: Firebase (Firestore for backups)
Before setting up the project, ensure you have the following installed:
- Xcode 15.0 or later
- iOS 16.0 or later (for simulator/device)
- Firebase SDK (via Swift Package Manager)
- CocoaPods (for additional dependencies)
- Go 1.20 or later
- MySQL 8.0 or later
- Firebase Admin SDK (
go get firebase.google.com/go
) - OpenSSL (for encryption)
- Strong password policy (minimum 12 characters, including uppercase, lowercase, numbers, and special characters)
- Rate limiting configuration
- SSL/TLS certificates
- Environment variables for sensitive data
- Git
- A Firebase project (for cloud backups)
- A MySQL database instance
- A domain name for production deployment
- Create a
.env
file based on.env.example
:
cp .env.example .env
- Configure environment variables:
DB_HOST=localhost
DB_PORT=3306
DB_USER=your_db_user
DB_PASSWORD=your_secure_password
DB_NAME=phonesaver
JWT_SECRET=your_secure_jwt_secret
SERVER_PORT=8080
FIREBASE_CONFIG=./firebase-credentials.json
RATE_LIMIT=100
RATE_LIMIT_PERIOD=100
- Set up security headers:
- Enable CORS only for trusted domains
- Set up proper Content Security Policy
- Enable HSTS
- Configure security headers in Nginx/Apache
- Navigate to the Backend Directory:
cd phonesaver-backend
- Install Dependencies:
go mod tidy
-
Set Up Firebase:
- Create a Firebase project at Firebase Console.
- Go to Project Settings > Service Accounts and generate a new private key.
- Download the
serviceAccountKey.json
file and place it in thephonesaver-backend
directory. - Note: Do not commit this file to GitHub. It's already in .gitignore.
-
Configure Database:
# Create database
mysql -u root -p
CREATE DATABASE phonesaver;
USE phonesaver;
# Create tables
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE contacts (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
encrypted_phone VARCHAR(255) NOT NULL,
tags VARCHAR(255) DEFAULT '',
last_interaction DATETIME DEFAULT NULL,
birthday DATE DEFAULT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id)
);
CREATE TABLE share_links (
id INT AUTO_INCREMENT PRIMARY KEY,
token VARCHAR(36) NOT NULL,
contact_id INT NOT NULL,
user_id INT NOT NULL,
expires_at DATETIME NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (contact_id) REFERENCES contacts(id),
FOREIGN KEY (user_id) REFERENCES users(id)
);
# Create indexes
CREATE INDEX idx_user_id ON contacts(user_id);
CREATE INDEX idx_tags ON contacts(tags);
CREATE INDEX idx_last_interaction ON contacts(user_id, last_interaction);
CREATE INDEX idx_share_links ON share_links(token);
- Start the Backend Server:
# Run with environment variables
export $(cat .env | xargs)
go run main.go
- Navigate to the Frontend Directory:
cd phoneS/phoneS
- Open the Project in Xcode:
open PhoneSaver.xcodeproj
-
Install Firebase SDK:
- In Xcode, go to File > Add Packages.
- Add the Firebase SDK by entering the URL: https://github.com/firebase/firebase-ios-sdk.
- Select the FirebaseFirestore and FirebaseAuth packages.
-
Configure Firebase:
- Download the
GoogleService-Info.plist
file from your Firebase project (Project Settings > General). - Add it to the PhoneSaver target in Xcode.
- Initialize Firebase in your AppDelegate or App struct.
- Download the
-
Build and Run:
- Select an iOS simulator or device in Xcode.
- Press Cmd + R to build and run the app.
-
Environment Variables:
- Never commit sensitive data to version control
- Use environment variables for configuration
- Rotate secrets regularly
-
Input Validation:
- Validate all user inputs
- Use prepared statements for database queries
- Implement rate limiting
- Sanitize user input
-
Error Handling:
- Never expose sensitive information in error messages
- Log errors securely
- Implement proper error boundaries
-
Authentication:
- Use JWT for authentication
- Implement proper session management
- Use secure password hashing
- Implement password reset functionality
-
Data Protection:
- Encrypt sensitive data
- Use secure key management
- Implement proper backup procedures
- Use secure communication channels
- Install MySQL (if not already installed):
- On macOS (using Homebrew):
brew install mysql
- Start the MySQL server:
brew services start mysql
- Log in to MySQL:
mysql -u root -p
Enter your password (e.g., MySecurePass123).
- Create the Database:
CREATE DATABASE phonesaver;
USE phonesaver;
- Create the users Table:
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL
);
- Create the contacts Table:
CREATE TABLE contacts (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
encrypted_phone VARCHAR(255) NOT NULL,
tags VARCHAR(255) DEFAULT '',
last_interaction DATETIME DEFAULT NULL,
birthday DATE DEFAULT NULL,
FOREIGN KEY (user_id) REFERENCES users(id)
);
- Create the share_links Table:
CREATE TABLE share_links (
id INT AUTO_INCREMENT PRIMARY KEY,
token VARCHAR(36) NOT NULL,
contact_id INT NOT NULL,
user_id INT NOT NULL,
expires_at DATETIME NOT NULL,
FOREIGN KEY (contact_id) REFERENCES contacts(id),
FOREIGN KEY (user_id) REFERENCES users(id)
);
- Add Indexes:
CREATE INDEX idx_user_id ON contacts(user_id);
CREATE INDEX idx_tags ON contacts(tags);
CREATE INDEX idx_last_interaction ON contacts(user_id, last_interaction);
- Navigate to the Frontend Directory:
PUT /api/contacts/:id/last-interaction
Authorization: Bearer <token>
Content-Type: application/json
{
"last_interaction": "2024-01-01T00:00:00Z"
}
PUT /api/contacts/:id/birthday
Authorization: Bearer <token>
Content-Type: application/json
{
"birthday": "1990-01-01"
}
POST /api/backup
Authorization: Bearer <token>
Content-Type: application/json
{
"contacts": [
{
"name": "John Doe",
"phone": "+1234567890",
"tags": ["friend", "work"]
}
]
}
- Fork the repository
- 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.
Abhinav Anand - @AbhinavAnand241201
Project Link: https://github.com/AbhinavAnand241201/phoneSaver