2.0 KiB
Research Findings
Decision: Use httpx for asynchronous HTTP requests
Rationale: The existing application uses FastAPI, which is an asynchronous framework. The requests library is synchronous and will block the event loop, degrading performance. httpx provides a similar API to requests but is fully asynchronous, making it the ideal choice for this project.
Alternatives considered: Using requests in a thread pool. This is a viable option but is more complex to implement and maintain than using a native async library like httpx.
Decision: Use SQLAlchemy with asyncpg for database integration
Rationale: SQLAlchemy is a powerful and widely used ORM for Python that supports asynchronous operations with the asyncpg driver. This allows for non-blocking database calls, which is essential for a FastAPI application. It also provides a robust way to manage database sessions and connection pooling.
Alternatives considered:
- Using a synchronous ORM: This would block the event loop and is not recommended for FastAPI.
- Writing raw SQL queries: This is more error-prone, less secure (risk of SQL injection), and harder to maintain than using an ORM.
- SQLModel: While SQLModel is a good option, SQLAlchemy is more mature and has a larger community. Since the project already uses SQLAlchemy, it's better to stick with it for consistency.
Decision: Use Pydantic BaseSettings for configuration management
Rationale: Pydantic's BaseSettings provides a convenient way to manage application settings and secrets from environment variables. This keeps sensitive information out of the codebase and makes the application more portable across different environments.
Alternatives considered:
- Hardcoding configuration: This is insecure and makes the application difficult to configure.
- Using
.inior.jsonfiles: This is a viable option, but Pydantic'sBaseSettingsprovides validation and type hinting, which makes the configuration more robust.