The Django Server microservice of Climate wavers is responsible for handling core functionalities, user management, and data processing tasks. Built on the Django rest framework, this server provides a robust and secure backend for the application.
- Project Overview
- Features
- Setting up a MariaDB Database
- Installation and Setup
- Environment Variables
- Deployment
- License
The Climate Change and Disaster Response Platform aims to monitor climate changes, predict natural disasters, and facilitate efficient disaster response. Leveraging Django, the server component ensures seamless user experience, data management, and integration with various data sources.
- User Authentication: Secure user registration, login, and profile management.
- Data Management: Store and manage user data, community information, and other data for application.
- Real-time Data Processing: Process incoming data streams for analysis and visualization.
- Collaborative Communities: Enable users to form communities, share observations, and collaborate.
- API Endpoints: Provides RESTful APIs for frontend interaction and external integrations.
- Clone the Repository:
https://github.com/ClimateWavers/backend.git cd backend
- Create virtual environment:
python3 -m venv myenv -- "Name of the virtual environment"
- Activate virtual environment:
source myenv/bin/activate
-
Install Dependencies:
pip install -r requirements.txt
-
Database Setup:
- Configure the database settings in
settings.py
. - Run migrations:
python manage.py migrate
- Configure the database settings in
-
Static and Media Files:
- Collect static files:
python manage.py collectstatic
- Configure media file settings in
settings.py
.
- Collect static files:
-
Run the Django Development Server:
python manage.py runserver
The Django server will be available at
http://localhost:8001
.
To start MariaDB, refer to the database microservice repository https://github.com/ClimateWavers/database
or the branch - database, at development repository https://github.com/Olagold-hackxx/ClimateWavers
-
Open your Django project's
settings.py
. -
Locate the
DATABASES
section. -
Configure the database settings. Here's an example configuration for MariaDB:
# ... (Your existing settings) DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'your_database_name', 'USER': 'your_database_user', 'PASSWORD': 'your_database_password', 'HOST': 'localhost or deployment service name', # Set the host where your MariaDB is running 'PORT': '3306', # Default MariaDB port } }
- SECRET_KEY: Django secret key for security
- DEBUG: Set to
True
for development,False
for production. - ALLOWED_HOSTS: List of allowed hostnames for the Django server.
- MARIADB_PASSWORD: Database Password
- MARIADB_USER: Database user
- VERIFICATION_MAIL: Personalized verification mail
- DOMAIN: Application domain or frontend url
- APP_EMAIL: Application email
- MARIADB_DB_NAME: Database name
- MARIADB_PORT: Database port, 3306 default value for mariadb
- MARIADB_SERVER: Database host, localhost on development environment, database service name on openshift cluster
- BACKEND:
We provide three different methods for deploying this microservice to openshift clusters.
Use the import git repository feature on openshift console.
- Navigate to Add page in the Developer console on openshift
- Select Dockerfile strategy
- Deployment type should be Deployment Config
- Secure routes
- Supply the environment variables after deployment
Using the scripts provided in automate_development
folder, simplifies deployment. To use the scripts, docker and oc must be installed.
You can replace the image repository in the scripts build.sh
in automate_deployment
or use the repository we provided.
automate_deployment/./build.sh
If the image repository was changed when building, update the development.yaml
file in k8s
folder with your image repository
automate_deployment/./deploy.sh
Deploy with tekton with the pipeline deployment script in automated_deployment
directory
automate_deployment/./pipeline.sh
This project is licensed under the MIT License.