This directory contains the FastAPI application and its associated routes for the Researcher project. The API is designed to handle various operations related to user authentication, file management, messaging, and research functionalities.
- app.py: This is the main entry point for the FastAPI application. It sets up the application, including middleware, routes, and the application lifespan. The application uses CORS middleware to allow requests from specified origins and includes routers for different functionalities.
The API is organized into several route modules, each handling specific aspects of the application:
- auth.py: Manages user authentication using AWS Cognito. It includes endpoints for user signup, login, email verification, and logout. The module also provides helper functions for JWT token creation and verification.
- file.py: Handles file operations, including retrieving, adding, updating, and deleting file metadata in the database. It ensures that file operations are performed securely and efficiently.
- message.py: Provides endpoints to retrieve messages by thread ID. It ensures that messages are only accessible to users who own the corresponding threads.
- research.py: Manages research-related operations, including processing chat requests and managing chat history. It integrates with the Researcher graph to process user prompts and generate responses.
- s3.py: Handles file uploads to S3 and indexes them in the PGEmbedding vector store. It ensures that files are securely uploaded and indexed for efficient retrieval and processing.
- thread.py: Manages chat threads, including creating, updating, retrieving, and deleting threads. It ensures that thread operations are restricted to the owning user.
- utils/auth.py: Contains helper functions for authentication, including JWT token management, user verification, and secret hash calculation for AWS Cognito.
- Ensure you have Python and FastAPI installed.
- Set up your environment variables, including AWS credentials and Cognito configuration.
- Run the FastAPI application:
uvicorn api.app:app --reload
- Access the API documentation at
http://localhost:8000/docs
to explore available endpoints and their functionalities.
- Ensure that the environment variables are correctly set up to enable seamless integration with AWS services.
- The API is designed to be modular, allowing for easy extension and maintenance.
This setup is tailored for the Researcher project and may require adjustments for other environments or projects.