Skip to content

Initial Python Backend Scaffolding: database setup, models, error handling and two endpoints#4

Merged
tmcneil-mdb merged 7 commits intomongodb:mainfrom
tmcneil-mdb:python-scaffolding-setup
Oct 24, 2025
Merged

Initial Python Backend Scaffolding: database setup, models, error handling and two endpoints#4
tmcneil-mdb merged 7 commits intomongodb:mainfrom
tmcneil-mdb:python-scaffolding-setup

Conversation

@tmcneil-mdb
Copy link
Copy Markdown
Collaborator

This PR introduces the foundational backend structure for the Fast application. It sets up core configurations, database connectivity, error handling, and establishes the initial API endpoints.

Key Changes

  • Added project scaffolding and folder structure for the backend
  • Implemented centralized error handling and custom exceptions
  • Configured database connection
  • Created /api/movies/
  • Created /api/movies/batch/
  • Added environment configuration and dependency setup

Testing

  • Verified both endpoints locally via FastAPI docs (/docs)
  • Confirmed database connection and data persistence
  • Checked error responses for validation and connection issues

Note: The readme was created to onboard another engineer, will not be included in the final version.

… onboarding docs

- Set up FastAPI backend for Movies API
- Implement create_success_response and create_error_response utils
- Add MongoDB error mapper and global exception handler
- Add .gitignore for Python, FastAPI, MongoDB data
- Write detailed onboarding Readme with setup, FastAPI leaning and project mapping
- Verified parity with TS response formatting and error handling
Copy link
Copy Markdown
Collaborator

@cbullinger cbullinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple minor things. and I'm not familiar with Pydantic/Fast API, so apologies for any naive questions/comments.

Comment thread server/python/src/models/models.py Outdated
Comment thread server/python/src/models/models.py Outdated
Comment thread server/python/src/models/models.py Outdated
Comment thread server/python/src/utils/errorHandler.py Outdated
Comment thread server/python/src/utils/errorHandler.py Outdated
Comment thread server/python/src/database/mongo_client.py Outdated
Comment thread server/python/src/routers/movies.py Outdated
Comment thread server/python/src/routers/movies.py Outdated
Comment thread server/python/src/routers/movies.py Outdated
if genre:
filter["genres"] = {"$regex": genre, "$options": "i"}
if year:
# I personally got some dirty data in the year field, a 1995è. Should we guard against this?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds reasonable to me. and i'll pass that on re: the dirty data; seems like something we should clean up in the actual sample database

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bad data in the year field is now on Docs' radar, btw. not sure when it'll be cleaned up, though.

The current mflix db has years with special chars within them. This fix strips all non-digit chars from the year field or sets the year field to none of the string is empty. 

Typos, spacing, and renaming addressed as well.  Removed error msg handling explanation.
Copy link
Copy Markdown
Collaborator

@cbullinger cbullinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking comments and some questions re: requirements.txt.

Comment thread server/python/src/routers/movies.py Outdated
Comment on lines +91 to +95
# Guarding against the dirty data in the year field.
if "year" in movie and not isinstance(movie["year"], int):
cleaned_year = re.sub(r"\D", "", str(movie["year"]))
try:
movie["year"] = int(cleaned_year) if cleaned_year else None
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] maybe revise the wording to be more diplomatic 😅 (depending on when the sample dataset is updated, we might be able to remove this entirely before release)

Suggested change
# Guarding against the dirty data in the year field.
if "year" in movie and not isinstance(movie["year"], int):
cleaned_year = re.sub(r"\D", "", str(movie["year"]))
try:
movie["year"] = int(cleaned_year) if cleaned_year else None
# Ensure that the year field contains int value.
if "year" in movie and not isinstance(movie["year"], int):
cleaned_year = re.sub(r"\D", "", str(movie["year"]))
try:
movie["year"] = int(cleaned_year) if cleaned_year else None

Comment thread server/python/requirements.txt
Comment thread server/python/requirements.txt Outdated
Comment thread server/python/requirements.txt Outdated
Comment thread server/python/requirements.txt Outdated
Comment thread server/python/requirements.txt Outdated
Comment thread server/python/requirements.txt Outdated
Comment thread server/python/src/routers/movies.py
@tmcneil-mdb tmcneil-mdb merged commit 57a8f52 into mongodb:main Oct 24, 2025
1 check passed
@tmcneil-mdb tmcneil-mdb deleted the python-scaffolding-setup branch October 24, 2025 17:15
cbullinger added a commit that referenced this pull request Jan 31, 2026
- #1 Movie Cards: Make entire card clickable, enforce consistent heights, tone down checkbox
- #2 Top Toolbar: Remove batch buttons, add contextual bottom selection bar
- #3 Filters Bar: Replace mint/green with neutral gray borders and backgrounds
- #4 Navbar: Remove full-width green border and animated underline effect
- #5 Aggregations: Use light gray for row hover, tone down comment pills and show more button
- Additional: Remove bright green border from aggregations section headers

All changes improve visual hierarchy and reduce competing visual elements per reviewer feedback on PR #75.
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.

2 participants