This project is a FastAPI application for managing and analyzing TV show data. The application supports uploading data, analyzing it, clustering, classification, and more.
tv_data_show/
├── controllers/
│ ├── v1/
│ │ ├── init.py
│ │ ├── analyze.py
│ │ ├── query.py
│ │ ├── upload.py
│ ├── init.py
├── core/
│ ├── init.py
│ ├── config.py
│ ├── security.py
├── db/
│ ├── init.py
│ ├── base.py
│ ├── models.py
│ ├── schemas.py
│ ├── session.py
├── services/
│ ├── init.py
│ ├── analyze.py
│ ├── upload.py
│ ├── query.py
├── globals.py
├── main.py
├── generate_api_key.py
├── interview_data.db
├── test.db
├── requirements.txt
├── Dockerfile
├── .env
└── tests/
├── init.py
├── conftest.py
├── test_main.py
├── test_analyze.py
├── test_query.py
├── test_upload.py
- Docker
- Python 3.11
- pip
Create a .env
file in the root of your project with the following content:
API_KEY=your_api_key_here
-
Clone the repository:
git clone https://github.com/yourusername/tv_data_show.git cd tv_data_show
-
Install dependencies:
pip install -r requirements.txt
-
Generate an API key:
You can generate an API key manually and place it in the
.env
file or use the provided script:python generate_api_key.py
This will create an
api_key.txt
file. Move the API key fromapi_key.txt
to your.env
file.
-
Build the Docker image:
docker build -t tv_data_show:latest .
-
Run the Docker container:
docker run -p 8000:8000 --env-file .env tv_data_show:latest
-
Run the application:
uvicorn main:app --reload
Endpoint: /api/v1/uploadfile/
-
Method:
POST
-
Description: Upload a CSV file containing TV show data.
-
Example:
curl -X POST "http://127.0.0.1:8000/api/v1/uploadfile/" -F "file=@path_to_your_file.csv" -H "Authorization: your_api_key"
Endpoint: /api/v1/analyze/
-
Method:
POST
-
Description: Analyze the uploaded data.
-
Example:
curl -X POST "http://127.0.0.1:8000/api/v1/analyze/" -H "Authorization: your_api_key"
Endpoint: /api/v1/results/
-
Method:
GET
-
Description: Fetch the analysis results.
-
Example:
curl -X GET "http://127.0.0.1:8000/api/v1/results/" -H "Authorization: your_api_key"
Endpoint: /api/v1/similarity/
-
Method:
GET
-
Description: Compute the similarity of a given video ID with other videos.
-
Example:
curl -X GET "http://127.0.0.1:8000/api/v1/similarity/?video_id=YourVideoID" -H "Authorization: your_api_key"
Endpoint: /api/v1/cluster/
-
Method:
GET
-
Description: Cluster the videos into a specified number of clusters.
-
Example:
curl -X GET "http://127.0.0.1:8000/api/v1/cluster/?n_clusters=5" -H "Authorization: your_api_key"
Endpoint: /api/v1/classify/
-
Method:
GET
-
Description: Classify the videos based on their features.
-
Example:
curl -X GET "http://127.0.0.1:8000/api/v1/classify/" -H "Authorization: your_api_key"
-
Install test dependencies:
pip install pytest httpx python-dotenv
-
Run the tests:
pytest
tests/conftest.py
: Sets up environment variables for tests.tests/test_main.py
: Tests the main endpoints.tests/test_analyze.py
: Tests the analyze functionality.tests/test_query.py
: Tests the query functionality.tests/test_upload.py
: Tests the upload functionality.