Skip to content

MongoPostConnect is a full-stack social media project that leverages MongoDB for storing and managing user posts, comments, multimedia content, and likes. The application integrates Flask for backend logic, user authentication, and GridFS for multimedia storage.

License

Notifications You must be signed in to change notification settings

Bushra-Butt-17/MongoPostConnect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

97 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

front

MongoPostConnect πŸš€

Description πŸ“

MongoPostConnect is a full-stack web application built with Flask and MongoDB, where users can post multimedia content, like and comment on posts, and manage their personal profiles. The application uses Flask for backend handling, MongoDB as the database, and GridFS to store multimedia files such as images.

Features 🌟

  • User registration and login with secure password hashing πŸ”.
  • Post creation with the ability to add multimedia content (images) πŸ–ΌοΈ.
  • Post editing and deletion (only by the creator) ✏️❌.
  • Commenting and liking functionality on posts πŸ’¬πŸ‘.
  • Profile page where users can view their posts πŸ‘€.
  • Full authentication system using Flask-Login πŸ”’.

Tech Stack πŸ› οΈ

  • Backend: Flask
  • Database: MongoDB (with GridFS for multimedia)
  • Authentication: Flask-Login, Flask-Bcrypt
  • Frontend: HTML, CSS, Bootstrap
  • Other: PyMongo, GridFS

What is MongoDB? 🌱

MongoDB is a NoSQL document-oriented database that stores data in flexible, JSON-like documents, which makes it easy to store, query, and manipulate complex data. Unlike traditional relational databases, MongoDB does not require predefined schemas and tables, providing more flexibility for developers to store and retrieve data. MongoDB is scalable and designed to handle large volumes of data, making it ideal for applications that need to process high amounts of unstructured data. In this project, MongoDB is used to store user data, posts, and multimedia content, while GridFS is used for storing large files such as images.


Video Demonstration πŸŽ₯

SocialConnect-Implementation-Part1.mp4
SocialConnect-Implementation-Part2.mp4

Main Page 🏠

  • Endpoint: /
  • Description: The main page where users can view posts made by all registered users. Displays posts along with multimedia (images). Users can like, comment, and navigate to their profile from this page.
  • Functionalities:
    • View all posts πŸ“œ.
    • Add a new post (if logged in) βž•.
    • View posts with multimedia files πŸ“Έ.
    • Like and comment on posts β€οΈπŸ’¬.

Login πŸ”‘

  • Endpoint: /login
  • Description: The login page where users can authenticate themselves to access their account.
  • Methods: GET, POST
  • Functionalities:
    • GET: Displays the login form πŸ“‘.
    • POST: Takes the username and password, checks credentials, and logs the user in using Flask-Login πŸ”’.
@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        # Authenticate and log in

Register πŸ†•

  • Endpoint: /register
  • Description: The registration page where users can create a new account by providing a username and password.
  • Methods: GET, POST
  • Functionalities:
    • GET: Displays the registration form πŸ“‘.
    • POST: Registers the user, stores their username and hashed password, and redirects them to the login page πŸ›¬.
@app.route('/register', methods=['GET', 'POST'])
def register():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        # Hash password and save user data

Profile πŸ‘€

  • Endpoint: /profile
  • Description: The user profile page, where users can view all the posts they have made and manage their content.
  • Methods: GET
  • Functionalities:
    • Displays the logged-in user’s posts πŸ“Έ.
    • Option to edit or delete own posts ✏️❌.
@app.route('/profile')
@login_required
def profile():
    user_posts = mongo.db.posts.find({"user_id": current_user.username})
    return render_template('profile.html', user=current_user, posts=user_posts)

All Posts πŸ“œ

  • Endpoint: /home
  • Description: Displays all posts from every user on the platform.
  • Methods: GET
  • Functionalities:
    • Shows all posts, including multimedia content and comments πŸ–ΌοΈπŸ’¬.
    • Allows users to like or comment on posts β€οΈπŸ’¬.
    • Navigates to individual post details (edit, delete if owner) πŸ› οΈ.
@app.route('/home')
def index():
    posts = mongo.db.posts.find()
    return render_template('index.html', posts=posts)

Add Post βž•

  • Endpoint: /add_post
  • Description: Allows users to create and publish a new post, optionally including multimedia content.
  • Methods: GET, POST
  • Functionalities:
    • Users can add text and upload images (via GridFS) πŸ“Έ.
    • The post is saved to MongoDB, and multimedia is stored using GridFS πŸ“‚.
@app.route('/add_post', methods=['GET', 'POST'])
@login_required
def add_post():
    if request.method == 'POST':
        post_text = request.form['text']
        # Handle multimedia file uploads
        post = {
            "user_id": current_user.username,
            "text": post_text,
            "multimedia": multimedia_files,
            "likes": 0,
            "comments": []
        }
        mongo.db.posts.insert_one(post)

Edit Post ✏️

  • Endpoint: /edit_post/<post_id>
  • Description: Allows users to edit their own posts.
  • Methods: GET, POST
  • Functionalities:
    • Users can edit the text and replace multimedia of their own posts ✏️.
    • Only the original poster can edit the post πŸ“.
@app.route('/edit_post/<post_id>', methods=['GET', 'POST'])
@login_required
def edit_post(post_id):
    post = mongo.db.posts.find_one({"_id": ObjectId(post_id)})
    # Handle edit functionality

Delete Post ❌

  • Endpoint: /delete_post/<post_id>
  • Description: Allows users to delete their own posts.
  • Methods: POST
  • Functionalities:
    • Only the post creator can delete the post and associated multimedia from GridFS πŸ—‘οΈ.
@app.route('/delete_post/<post_id>', methods=['POST'])
@login_required
def delete_post(post_id):
    post = mongo.db.posts.find_one({"_id": ObjectId(post_id)})
    # Handle deletion logic

Like Post ❀️

  • Endpoint: /like_post/<post_id>
  • Description: Allows users to like a post. A user can only like a post once.
  • Methods: POST
  • Functionalities:
    • Updates the "likes" list in the post document ❀️.
    • Prevents a user from liking the same post multiple times πŸ”’.
@app.route('/like_post/<post_id>', methods=['POST'])
@login_required
def like_post(post_id):
    # Logic to add like

Comment on Post πŸ’¬

  • Endpoint: /add_comment/<post_id>
  • Description: Allows users to comment on posts.
  • Methods: POST
  • Functionalities:
    • Users can add comments to posts, which are stored within the post document πŸ’¬.
@app.route('/add_comment/<post_id>', methods=['POST'])
@login_required
def add_comment(post_id):
    comment_text = request.form['comment']
    # Add comment to post

License πŸ“

MIT License. See LICENSE for more details.


Contributing 🀝

Feel free to fork this repository, make changes, and submit pull requests. All contributions are welcome!


Contact πŸ“§

For any questions or inquiries, feel free to contact me via my GitHub: Bushra-Butt-17.


Screenshots πŸ“Έ

Main Page 🏠

Screenshot 2 Screenshot 20

Login Page πŸ”‘

Screenshot 202

Screenshot 2

Profile Page πŸ‘€

bush-profile-initial bush-profile

bush-profile-1

hasma-profile-1

hasma-profile-2 hasma-profile-3

All Posts πŸ“œ

Screenshot 2024- Screenshot 20240 Screenshot 2024-

About

MongoPostConnect is a full-stack social media project that leverages MongoDB for storing and managing user posts, comments, multimedia content, and likes. The application integrates Flask for backend logic, user authentication, and GridFS for multimedia storage.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published