forked from fastapi/full-stack-fastapi-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Implement Phase 2 - Backend Database Infrastructure #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andrade94
wants to merge
34
commits into
Astrea-Technologies:master
Choose a base branch
from
Astrea-Technologies:phase-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Implement Phase 2 - Backend Database Infrastructure #7
andrade94
wants to merge
34
commits into
Astrea-Technologies:master
from
Astrea-Technologies:phase-2
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Service Layer Implementation for Comment and Metrics Repositories
Redis Service Implementation for Political Social Media Analysis Platform
Redis takeoff
# Topic Analysis Implementation for Social Media Content
Vector repository
Implement Simple Task Processing System for MVP
Social Media Data Collection and Processing Refactor
Implement Phase 1 MVP Backend Setup & Docker Cleanup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This pull request implements Phase 2 of the backend development, focusing on establishing the core database infrastructure for both PostgreSQL and MongoDB as outlined in
next-implementations.md
. It sets up the necessary models, schemas (utilizing existing ones for MongoDB), and connection utilities required for subsequent data storage and retrieval operations.Significant effort was also dedicated to debugging and resolving Python import path issues and configuration differences encountered when running the backend application both locally and within the Docker Compose environment.
Changes Made:
backend/app/db/mongo_utils.py
containing asynchronous functions (get_mongo_client
,close_mongo_connection
,get_mongo_database
,get_mongo_collection
) to manage the Motor client connection using settings fromconfig.py
.backend/app/main.py
to:mongo_utils.py
functions into FastAPI'sstartup
andshutdown
events for MongoDB connection lifecycle management./health
check endpoint to use the new MongoDB utility for verifying the connection status.backend/app/db/models/political_entity.py
backend/app/db/models/social_media_account.py
backend/app/db/models/entity_relationship.py
political_models.py
) that was initially created.backend/app/db/schemas/mongodb.py
.post_schema.py
,comment_schema.py
,analysis_schema.py
) that were initially created.__init__.py
files tobackend/
andbackend/app/db/
to ensure proper package recognition by Python.mongo_utils.py
(frombackend.app...
toapp...
) to be compatible with the Docker container's working directory.sys.path
modifications frommain.py
used during local debugging.localhost
vs.mongodb
) and confirmed the Docker setup works correctly with service names.database-architecture.md
file in the project root directory, reflecting the actual codebase structure (individual SQL model files, correct MongoDB schema path, and Pydantic definitions).Testing:
uvicorn
/python -m uvicorn
) which revealed and led to the fixing of Python import path issues.localhost
vs.mongodb
service name).docker compose up --build -d
.backend
container logs viadocker compose logs --follow backend
./health
endpoint reports correctly via logs after startup.Next Steps:
.env.example
) for running locally vs. Docker, especially regarding database hostnames.