- Link: Video Demonstration
This project is part of the MindSpark Hackathon and involves building a news aggregation application using a Django backend, integrated with Qdrant for vector storage and MySQL for data management.
Ensure that you have the following installed:
- Python 3.11
- pip (Python package installer)
- virtualenv (optional but recommended)
- Docker (for Qdrant)
- MySQL (for the database)
Clone the repository and navigate into the project directory:
git clone https://github.com/swarup-2004/MindSpark-Hacathon.git
cd MindSpark-HacathonCreate and activate a virtual environment:
# Create a virtual environment
python -m venv env
# Activate the virtual environment
# For Windows:
env\Scripts\activate
# For Mac/Linux:
source env/bin/activateInstall the required packages:
pip install -r requirements.txtTo configure Qdrant and store collections on the local disk when running it via Docker, you can follow these updated steps:
docker pull qdrant/qdrantTo store the Qdrant collection data on your local disk, map a local directory to a directory inside the Docker container.
docker run -p 6333:6333 \
-v /path/to/local/storage:/qdrant/storage \
qdrant/qdrantIn the command above:
- Replace
/path/to/local/storagewith the actual path where you want to store the Qdrant collections on your local machine. For example,C:\Users\YourName\Documents\QdrantDataon Windows or/home/yourname/qdrant_dataon Linux/macOS. - The
-voption mounts the specified local directory to/qdrant/storageinside the Docker container, which is the default storage path for Qdrant.
In a Python script or interactive shell, run the following code:
from qdrant_client import QdrantClient
client = QdrantClient("http://localhost:6333")
def create_qdrant_collection(collection_name):
client.create_collection(
collection_name=collection_name,
vectors_config={"size": 384, "distance": "Cosine"} # Adjust the vector size as per your model
)
print(f"Collection '{collection_name}' created.")
create_qdrant_collection("articles")
create_qdrant_collection("keywords")- Create a database named
newson your local MySQL server. - Create a
.envfile in your project directory and add the following configurations:
DATABASE_NAME=news
DATABASE_USER=your_database_user
DATABASE_PASSWORD=your_database_password
DATABASE_HOST=localhost
DATABASE_PORT=3306
EMAIL_PORT=your_email_port
EMAIL_USE_TLS=True
EMAIL_HOST_USER=your_email_host_user
EMAIL_HOST_PASSWORD=your_email_host_password
DEFAULT_FROM_EMAIL=your_default_from_email
NEWS_API_KEY=your_news_api_key
Change to the mindspark_backend directory and run migrations:
cd mindspark_backend
python manage.py migrateCreate a superuser for the Django admin interface:
python manage.py createsuperuserIn your settings.py file, update the CORS_ALLOWED_ORIGINS setting to include the URL of your frontend application. This ensures that cross-origin requests from your frontend to the backend are allowed.
CORS_ALLOWED_ORIGINS = [
'http://your-frontend-url.com', # Replace with your actual frontend URL
]This setting ensures that only the specified frontend domain is allowed to interact with your backend via cross-origin requests.
In your database, specifically the django_site table, update the following fields:
domain: Set this to your frontend domain.name: Set this to your application's name.
You can do this either by:
- Accessing the
django_sitetable directly in your database and updating the fields manually. - Using the Django admin panel, which can be accessed after running the server.
Start the Django development server:
python manage.py runserver- Ensure that you have Docker installed and running on your machine to pull and run the Qdrant image.
- Make sure to replace placeholder values in the
.envfile with your actual database and email configuration details.