Admin dashboard for managing data for AI-chatbot
This project is an Admin Portal for managing data for an AI chatbot. It allows administrators to log in, upload, and delete files. The application is built using Flask, a popular Python web framework, and it provides a simple web interface to interact with the chatbot's data.
Before running the application, ensure the following prerequisites are met:
- Python 3.x is installed on the system.
- Required Python packages are installed. You can install them using
pip install -r requirements.txt
. - The environment variables
FLASK_SECRET_KEY
and any other required variables should be set.
The project consists of the following files:
main.py
: The man program script. Starting point.app.py
: The main Flask application file containing the server logic.admin_users.json
: A JSON file containing a list of admin users' credentials.client_secret.json
: A JSON file containing Google Drive API keys and credentials. (Get it from here [https://console.cloud.google.com/]).stored_files.json
: A JSON file used for attaining Data transparency, this file is kept in synced with the pinecone vector database. (maintained by themanage_vectordb.py
)utils.py
: Utilites / helper functions forapp.py
manage_vectordb.py
: Module for managing the data on Pinecone vector database. Also a standalone script for testing the database.
- Clone the repository from GitHub.
git clone https://github.com/madhav-mknc/admin-portal
cd https://github.com/madhav-mknc/admin-portal
- Install the required dependencies using:
pip install -r requirements.txt
- Set the environment variable
FLASK_SECRET_KEY
to a strong random key for session management and security. Note: In a production environment, ensure this key is kept secret and not hard-coded. - Ensure the
admin_users.json
file contains valid admin user credentials. - Set all the required env variables mentioned in ".env" file.
- To start the Flask server, run the
start_server()
function in theapp.py
file. The server will run onhttp://0.0.0.0:80/
and listen to incoming requests.
python app.py
or
python main.py
- For testing QnA: Open another command line in the same directory and follow the following commands:
python manage_vectordb.py
* ".stats" is a command short for index.describe_index_stats()
* ".reset_index" is for resetting the index by deleting and creating a new one.
The Flask application exposes the following routes:
/
: The homepage of the Admin Portal./login
: The login page for administrators to authenticate themselves./dashboard
: The main dashboard page where administrators can see the uploaded files and manage them./uploads/<filename>
: A route to serve uploaded files directly from the server./upload
: A route to upload files to the server./upload_google_drive
: A route for uploading files from Google Drive./handle_url
: A route for fetching data using a URL./delete/<filename>
: A route to delete uploaded files from the server./logout
: A route to log out and clear the authenticated session./chatbot
: Redirect to chatbot.
- The project uses Flask's built-in session management to store the authenticated status, which is not suitable for production environments. In a real-world application, consider using a more robust session management solution.
- The
allowed_file()
function allows only specific file types (txt, pdf, doc, docx, csv) to be uploaded. Modify theALLOWED_EXTENSIONS
set to include additional file types if required. - In a production environment, it's crucial to ensure secure file uploads to prevent any potential security risks.
This project is licensed under the MIT License. Feel free to use and modify it according to your needs.