MentorConnect: Student-Mentor Messaging App

Customize this app
23
import logging
from gunicorn.app.base import BaseApplication
from app_init import create_initialized_flask_app

# Flask app creation should be done by create_initialized_flask_app to avoid circular dependency problems.
app = create_initialized_flask_app()

# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

class StandaloneApplication(BaseApplication):
    def __init__(self, app, options=None):
        self.application = app
        self.options = options or {}
        super().__init__()

    def load_config(self):
        # Apply configuration to Gunicorn
        for key, value in self.options.items():
            if key in self.cfg.settings and value is not None:
                self.cfg.set(key.lower(), value)

    def load(self):
Get full code

MentorConnect: Student-Mentor Messaging App

Created: | Last Updated:

Introduction to the MentorConnect Template

The MentorConnect template is designed to help you build a messaging app where students can connect with mentors and discuss problems in real-time. This template includes features for user registration, login, and a chat interface for communication between students and mentors.

Getting Started with the Template

To get started with the MentorConnect template, follow these steps:

  1. Click "Start with this Template": This will load the template into the Lazy Builder interface.

Test the Application

  1. Press the Test Button: This will begin the deployment of the app and launch the Lazy CLI. The CLI will guide you through any required user input.

Entering User Input

The application requires user input for registration and login. Follow these steps to provide the necessary input:

  1. Register a New User:

    • Navigate to the /register route.
    • Fill in the registration form with a username, password, and optionally, a specialization if registering as a mentor.
    • Submit the form to create a new user account.
  2. Login:

    • Navigate to the /login route.
    • Fill in the login form with your username and password.
    • Submit the form to log in to your account.

Using the App

Once you have registered and logged in, you can use the app as follows:

  1. Home Page:

    • The home page lists all available mentors.
    • Students can view mentor details and initiate a chat by clicking on the "Chat with [Mentor]" button.
  2. Dashboard:

    • Depending on whether you are logged in as a student or a mentor, you will see different dashboards.
    • Student Dashboard: Lists all available mentors.
    • Mentor Dashboard: Shows recent messages from students.
  3. Chat Interface:

    • Navigate to the /chat/<user_id> route to chat with a specific user.
    • The chat interface allows you to send and receive messages in real-time.

Integrating the App

If you need to integrate the app with external tools or services, follow these steps:

  1. API Endpoints:

    • The app provides several API endpoints for user registration, login, and messaging.
    • You can use these endpoints to integrate the app with other services or frontend applications.
  2. Sample Request and Response:

    • Sample Request: ```http POST /register Content-Type: application/json

    { "username": "student1", "password": "password123", "is_mentor": false } - **Sample Response**:json { "message": "Registration successful. Please log in." } ```

  3. Adding Web Components:

    • If you need to add web components to an external tool, ensure you include the necessary HTML and JavaScript code.
    • For example, to add a chat button, you can use the following code: html <a href="/chat/{{ mentor.user.id }}" class="mt-2 inline-block bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"> Chat with {{ mentor.user.username }} </a>

By following these steps, you can successfully set up and use the MentorConnect template to build a student-mentor messaging app. If you encounter any issues or need further assistance, refer to the Lazy documentation or reach out to the Lazy support team.

Technologies

Flask Flask