Design (LLD) TrueCaller - Machine Coding

Table of contents

No heading

No headings in the article.


TrueCaller is a phone number lookup and spam blocking service that allows users to identify unknown phone numbers and block unwanted calls. In order to design the Low-level design (LLD) for TrueCaller, several key components would need to be considered.

  1. Phone Number Database: A large database of phone numbers and associated information, such as contact names and caller ID information, would be necessary to provide the core functionality of the service. The database would need to be able to handle a large number of queries and updates in real-time, and would likely be implemented using a distributed database system.

  2. Caller ID Lookup: A system for quickly looking up phone numbers in the database and returning the associated contact name and other information would be necessary. This could be implemented using a hash table or a search tree, such as a B-tree, to allow for fast lookups.

  3. Spam Blocking: A system for identifying and blocking unwanted calls would need to be implemented. This could be done by using machine learning algorithms to analyze call patterns and other data to identify spam calls, or by integrating with third-party spam blocking services.

  4. User Interface: A user-friendly interface for searching for phone numbers, adding and updating contact information, and managing spam blocking settings would be necessary. This could be implemented as a web interface or as a mobile app.

  5. Privacy and Security: Strong security measures would be necessary to protect user data and ensure that the service complies with privacy regulations. This could include encryption of sensitive data, secure authentication and authorization, and regular security audits.

  6. Scaling: The service will be handling a large number of requests and updates, so the system should be designed in a way that it can easily scale horizontally and vertically as the user base grows.

This is a general overview of the key components that would be necessary to implement a TrueCaller-like service. The actual implementation will depend on the specific requirements and constraints of the project, and may include additional components or different design choices.

Designing a TrueCaller-like system using object-oriented programming in Java would involve creating several classes to represent different aspects of the system. Here is an example of how the classes might be organized:

  1. PhoneNumber class - This class would represent a phone number. It would have properties such as the country code, area code, and the phone number itself. It would also have methods to format the phone number in different ways (e.g. with or without the country code).

  2. Contact class - This class would represent a contact in the TrueCaller system. It would have properties such as the name of the contact, their phone number, and any additional information such as their email address or address. It would also have methods to add or update the contact's information.

  3. PhoneBook class - This class would represent the phone book, and it would have properties such as a list of contacts. It would also have methods to add, remove, and search for contacts in the phone book.

  4. TrueCaller class - This class would be the main class of the system. It would have properties such as the phone book and a list of blocked numbers. It would also have methods to make a call, block a number, and search for a contact in the phone book.

Here is an example of how the classes might be implemented:

public class PhoneNumber {
    private String countryCode;
    private String areaCode;
    private String number;

    public PhoneNumber(String countryCode, String areaCode, String number) {
        this.countryCode = countryCode;
        this.areaCode = areaCode;
        this.number = number;

    public String getFormattedNumber() {
        return "+" + countryCode + " " + areaCode + " " + number;

    // Additional methods such as equals, hashcode

public class Contact {
    private String name;
    private PhoneNumber phoneNumber;
    private String email;
    private String address;

    public Contact(String name, PhoneNumber phoneNumber) { = name;
        this.phoneNumber = phoneNumber;

    public void setEmail(String email) { = email;

    public void setAddress(String address) {
        this.address = address;

    public String getName() {
        return name;

    public PhoneNumber getPhoneNumber() {
        return phoneNumber;

    // Additional methods such as equals, hashcode

public class PhoneBook {
    private List<Contact> contacts;

    public PhoneBook() {
        contacts = new ArrayList<>();

    public void addContact(Contact contact) {

    public void removeContact(Contact contact) {

    public List<Contact> searchContacts(String name) {
        List<Contact> searchResults = new ArrayList<>();
        for (Contact contact : contacts) {
            if (contact.getName().contains(name)) {
        return searchResults;

public class TrueCaller {
    private PhoneBook phoneBook;
    private List<PhoneNumber> blockedNumbers;

    public TrueCaller(PhoneBook phoneBook) {
        this.phoneBook = phoneBook;
        blockedNumbers = new ArrayList<>();

    public void makeCall(PhoneNumber phoneNumber) {
        if (blockedNumbers.contains(phoneNumber)) {
            System.out.println("The number " + phoneNumber.getFormattedNumber() + " is blocked, call cannot be made.");
        } else {
            List<Contact> searchResults = phoneBook.searchContacts(phoneNumber);
            if (searchResults.size() > 0) {
                Contact contact = searchResults.get(0);
                System.out.println("Calling " + contact.getName() + " at " + phoneNumber.getFormattedNumber());
            } else {
                System.out.println("The number " + phoneNumber.getFormattedNumber() + " is not in your phone book, call cannot be made.");

    public void blockNumber(PhoneNumber phoneNumber) {
        System.out.println("The number " + phoneNumber.getFormattedNumber() + " has been blocked.");

    public void unblockNumber(PhoneNumber phoneNumber) {
        System.out.println("The number " + phoneNumber.getFormattedNumber() + " has been unblocked.");

    public List<Contact> searchPhoneBook(String name) {
        return phoneBook.searchContacts(name);

Did you find this article valuable?

Support Subhahu Jain by becoming a sponsor. Any amount is appreciated!