Skip to content

social media sample application#175

Merged
cod-all merged 6 commits intomasterfrom
social-network-sample-application
May 4, 2026
Merged

social media sample application#175
cod-all merged 6 commits intomasterfrom
social-network-sample-application

Conversation

@tmcallaghan
Copy link
Copy Markdown
Contributor

Social media application for sample usecases.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment thread usecases/social_media/app.py Fixed
Comment thread usecases/social_media/routes/posts.py Fixed
tmcallaghan and others added 2 commits April 30, 2026 13:02
…debug mode'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
… remote source'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Comment thread usecases/social_media/routes/posts.py Dismissed
… remote source'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@cod-all cod-all self-assigned this May 1, 2026
@cod-all
Copy link
Copy Markdown
Contributor

cod-all commented May 1, 2026

Architecture is clean and the DocumentDB integration is solid. A few small things:

  1. login_required is duplicated in routes/users.py, routes/posts.py, and routes/search.py. Suggest extracting it into a shared utilities file.

  2. routes/posts.py has the following -

for post in posts:
        author = db.users.find_one({'_id': post['author_id']})
        post['author'] = author

So if an author has 100 posts, it's going to do 100 findOne() operations. Should this be changed to a batch lookup?

  1. users.py does a regex search - 'username': {'$regex': query, '$options': 'i'}

Which means if I type in .* , I can essentially get all users. Should there be a validation or escape added to avoid this?

1. refactored login_required to remove code duplication
2. eliminated author lookup for each post, now single find() operation
3. eliminated wildcard/regex searching for users, now exact match only
@cod-all
Copy link
Copy Markdown
Contributor

cod-all commented May 1, 2026

Changes look great. 2 other items to fix before merging, as these could cause issues with deployment.

  1. The readme says "The application runs in debug mode by default when using python app.py ". But app.py has this:

debug = os.getenv('FLASK_DEBUG', 'false').strip().lower() in ('1', 'true', 'yes', 'on') 

Debug is off by default.

  1. In the readme, "4. Run the Application" - you give two ways to run - using flask or python.  RUnning it via python will read the FLASK_PORT variable (3000). But running via flask doesn't - it will default to port 5000. So if launched via flask run, the localhost URL in the readme won't work.

@cod-all cod-all merged commit 08b2f3d into master May 4, 2026
4 checks passed
@tmcallaghan tmcallaghan deleted the social-network-sample-application branch May 4, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants