- Python 3.10+: Download Python
- Git: Install Git
- Firebase Console: Firebase Console
git clone https://github.com/kvcops/KV-Nexus.git
cd KV-Nexus
It's recommended to use a virtual environment to manage dependencies.
python -m venv venv
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
You will need to create a Firebase project to host your database. This project will be used to store your database and other resources. Make sure to select the region closest to you.
If you don't have a Firebase project:
-
Go to the Firebase Console.
-
Click on "Add project" and follow the prompts to create a new project.
- Choosing the Google Analytics for this project is optional, but it is recommended.
- Click on "Continue" to create your project. Wait for Firebase to finish creating your project.
- In the Firebase Console, select your project.
- Click the gear icon (⚙️) next to "Project Overview" and select Project settings.
- Navigate to the Service accounts tab.
- Click on Generate new private key.
- A JSON file will be downloaded. Keep this file secure and do not commit it to version control.
Extract the necessary values from the downloaded JSON file and set them as environment variables.
Create a .env
file in the root directory of your project:
FIREBASE_PROJECT_ID=your_project_id
FIREBASE_CLIENT_EMAIL=your_client_email
FIREBASE_PRIVATE_KEY=your_private_key
FIREBASE_CLIENT_ID=client_id
FIREBASE_AUTH_URI=auth_uri
FIREBASE_TOKEN_URI=token_uri
FIREBASE_AUTH_PROVIDER_X509_CERT_URL=auth_provider_x509_cert_url
FIREBASE_CLIENT_X509_CERT_URL=client_x509_cert_url
FIREBASE_UNIVERSE_DOMAIN=universe_domain
Replace your_project_id
, your_client_email
, and your_private_key
with the corresponding values from the JSON file.
Note: Ensure that the
serviceAccountKey.json
file and.env
file are added to your.gitignore
to prevent them from being pushed to version control.
- In the Firebase Console, select your project.
- Click on Storage in the left sidebar.
- Scroll down and click on Firebase Storage in the center of the page.
- Choose the region closest to you. In my case, I chose Asia-east2 (hong kong).
- Always select the Start in production mode.
- Click on Next.
- STORAGE_BUCKET_URL: This is found in the Firebase console under Storage.Also make sure that the STORAGE_BUCKET_URL is correctly set like this.
STORAGE_BUCKET_URL=gs://<your-project-id>.appspot.com
authDomain=
projectId=
storageBucket=
messagingSenderId=
appId=
Ensure you have pip installed, then install the required packages:
pip install -r requirements.txt
With everything set up, you can now run the application:
flask run
NOTE: If you encounter an issue related to type "field" like one shown below:-
Simply add a env var to specify the type of the firebase account.
FIREBASE_TYPE=service_account
Once all the above steps are done, you should be able to run the application without any issues. your .env file should look like this.
- Database Setup: If your application uses a database, ensure it's properly configured and migrated.
- Environment Variables: Consider using tools like
python-dotenv
to manage environment variables seamlessly. - Security: Always keep your service account keys and other sensitive information secure. Avoid hardcoding them in your codebase.
Also make sure to obtain these API keys from the respective websites. As they are also used in the application.
mailjet_api_key = os.environ.get("mail_API_KEY") # Replace with your Mailjet API key
mailjet_api_secret = os.environ.get("mail_API_SECRET") # Replace with your Mailjet API secret
mailjet = Client(auth=(mailjet_api_key, mailjet_api_secret), version='v3.1')
google_api_key = os.environ.get("API_KEY")
unsplash_api_key = os.getenv('UNSPLASH_API_KEY')
openweathermap_api_key = os.getenv('OPENWEATHERMAP_API_KEY')