This repository contains the final project for ISA, which involves building an API server using FastAPI. The project is designed with modularity and efficiency in mind, leveraging popular libraries and frameworks.
It is recommended to use a virtual environment to manage dependencies.
- To create a virtual environment:
python -m venv venv
- To activate the virtual environment (when in the
backenddirectory):venv\Scripts\activate
- To deactivate the virtual environment:
deactivate
- To install dependencies from
requirements.txt(ensure the virtual environment is activated):pip install -r requirements.txt
- Navigate to the
backenddirectory:cd backend - Start the server using Uvicorn:
uvicorn main:app --reload
The server will run on http://127.0.0.1:8000 by default. Use --host and --port options to customize if needed.
Below are the key libraries used in this project along with their purposes:
| Library | Purpose |
|---|---|
transformers |
Access to HuggingFace's pre-trained models and tools. |
torch |
Required for transformers to function. |
fastapi |
Web framework for building APIs. |
uvicorn |
ASGI server for running the FastAPI application. |
python-dotenv |
For managing environment variables. |
mysql-connector-python |
MySQL database connection. |
requests |
To make HTTP requests (e.g., email APIs). |
passlib |
Manages multiple password hashing algorithms. |
bcrypt |
For secure password hashing. |
python-jose |
JSON Web Token (JWT) support for authentication. |
cryptography |
Provides cryptographic recipes and primitives. |
geopy |
Geocoding and geographical calculations. |
pydantic |
Data validation and parsing using Python type hints. |
FastAPI includes Swagger support out of the box, making it easy to view and test API endpoints.
- Start the server:
uvicorn main:app --reload
- Open your browser and go to: http://127.0.0.1:8000/docs
This will display the auto-generated Swagger UI, where you can interact with the API.
- Environment Variables: Use
.envfiles to store sensitive information such as database credentials or API keys. Make sure to include.envin your.gitignorefile. - Password Management:
passlibandbcryptare available for hashing and verifying passwords. These libraries may be included as needed. - JWT Authentication:
python-joseis used to handle token-based authentication, providing secure and scalable user authentication.