voici mon code python je veux que tu m'aide a le transformer en frontend en utilisant le framework adapter pour toi :
from pymongo import MongoClient

# Connection to MongoDB
connection_string = "mongodb+srv://123:123@firstserv.i5myl.mongodb.net/?retryWrites=true&w=majority&appName=FIRSTSERv"
client = MongoClient(connection_string)

# Main database and collections
db = client["FIRSTSERv"]
users_collection = db["users"]
conversations_collection = db["conversations"]  # New collection for conversations

def create_account():
    name = input("Enter your name to sign up: ")
    existing_user = users_collection.find_one({"name": name})
    if not existing_user:
        user_doc = {
            "name": name,
            "user_id": str(len(list(users_collection.find())) + 1)  # Generate a unique ID
        }
        users_collection.insert_one(user_doc)
        print("Account created successfully!")
    else:
        print("An account with this name already exists.")

def check_login():
    login = input("Enter your username to log in: ")
    login_user = users_collection.find_one({"name": login})
    if not login_user:
        print("This user does not exist. Please create an account first.")
        return None
    else:
        print(f"Welcome back, {login}!")
    return login

def get_user_list():
    return [user["name"] for user in users_collection.find()]

def start_conversation(login):
    
    users = get_user_list()
    users.remove(login)
    if not users:
        print("No other users available to chat with.")
        return
    print("Available users:")
    for user in users:
        print(user)

    recipient = input("Enter the name of the user you want to chat with: ")
    if recipient not in users:
        print("User does not exist or is not available.")
        return

    # Check if a conversation already exists
    conversation = conversations_collection.find_one({
        "participants": {"$all": [login, recipient]}
    })

    if not conversation:
        # Create a new conversation
        conversation_doc = {
            "participants": [login, recipient],
            "messages": []
        }
        conversation_id = conversations_collection.insert_one(conversation_doc).inserted_id
        print("New conversation started!")
    else:
        conversation_id = conversation["_id"]
        print("Conversation already exists. Opening conversation...")

    
    chat_loop(login, recipient, conversation_id)

def chat_loop(login, recipient, conversation_id):
    while True:
        print("\nOptions:")
        show_conversation(conversation_id)
        
        print("For existing conversation pls leave blank")
        
        message_text = input("Enter your message: ")
        if message_text =="":
            print("Exiting conversation.")
            break
        else :

            message_doc = {
                    "sender": login,
                    "message": message_text
            }
            conversations_collection.update_one(
                    {"_id": conversation_id},
                    {"$push": {"messages": message_doc}}
            )
            print("Message sent!")
            
        
        

def show_conversation(conversation_id):
    conversation = conversations_collection.find_one({"_id": conversation_id})
    print("\nConversation messages:")
    for msg in conversation["messages"]:
        print(f"{msg['sender']}: {msg['message']}")
    print()
def delete_conversation(login):
    conversations = conversations_collection.find({"participants": login})
    convo_list = list(conversations)
    if not convo_list:
        print("You have no conversations.")
        return
    print("Your conversations:")
    for i, convo in enumerate(convo_list, start=1):
        print(f"{i}. {', '.join(convo['participants'])}")

    choice = input("Enter the number of the conversation to delete: ")
    if not choice.isdigit() or int(choice) < 1 or int(choice) > len(convo_list):
        print("Invalid choice. Please try again.")
        return

    conversation_id = convo_list[int(choice) - 1]["_id"]
    print(f"Are you sure you want to delete conversation {conversation_id}? (Y/N): ")
    confirm = input().lower()
    if confirm == "y":
        conversations_collection.delete_one({"_id": conversation_id})
        print(f"Conversation {conversation_id} deleted.")
    else:
        print("Deletion cancelled.")

def view_conversations(login):
    # Fetch all conversations involving the user
    conversations = conversations_collection.find({
        "participants": login
    })
    convo_list = list(conversations)
    if not convo_list:
        print("You have no conversations.")
        return

    print("Your conversations:")
    for idx, convo in enumerate(convo_list):
        # Get the other participant's name
        other_participants = [p for p in convo["participants"] if p != login]
        participants_str = ", ".join(other_participants)
        print(f"{idx + 1}. Chat with {participants_str}")

    choice = input("Enter the number of the conversation to open it, or 'b' to go back if you want to delette one type delette ")
    if choice.lower() == 'b':
        return
    if choice.lower() == "delette":
        delete_conversation(login)
    try:
        choice = int(choice) - 1
        if 0 <= choice < len(convo_list):
            conversation_id = convo_list[choice]["_id"]
            recipient = [p for p in convo_list[choice]["participants"] if p != login][0]
            chat_loop(login, recipient, conversation_id)
        else:
            print("Invalid choice.")
    except ValueError:
        print("Invalid input.")

def logout():
    print("You have logged out.")
    return None

def login_menu():
    print("\nMenu:")
    print("1. Log in")
    print("2. Create an account")
    print("3. Quit")
    choice = input("Enter your choice: ")
    return choice

def main_menu(login):
    print("\nMenu:")
    print("1. Start a conversation")
    print("2. View your conversations")
    print("3. Log out")
    print("4. Quit")
    choice = input("Enter your choice: ")
    return choice

def main():
    login = None
    while True:
        if login:
            choice = main_menu(login)
        else:
            choice = login_menu()

        if choice == "1":
            if login:
                start_conversation(login)
            else:
                login = check_login()
        elif choice == "2":
            if login:
                view_conversations(login)
            else:
                create_account()
        elif choice == "3":
            if login:
                login = logout()
            else:
                print("Please log in first.")
        elif choice == "4":
            print("Goodbye!")
            break
        else:
            print("Invalid choice. Please try again.")

if __name__ == "__main__":
    main()