diff --git a/README.md b/README.md index 115f097..daadc03 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,70 @@ # Deep Impact - + + +## Overview + +Deep Impact is a web application designed to provide users with insights into the potential dangers of asteroid impacts. Utilizing the NASA NeoWs API, we've developed a simulation tool that visualizes incoming asteroids and explores various methods of asteroid deflection. + +### Our Team + +- Daniel Smith-dePaz +- Jordan Yamada +- Pierre Bell +- Michael Roy +- Mickey Shoenberger +- Jordan Edgington + +To learn more about Deep Impact, check out our [Deep Impact GitHub](https://github.com/Team-Deep-Impact/Deep-Impact). + +## Features + +1. **Asteroid Visualization**: Visualize incoming asteroids using real-time data from the NASA NeoWs API. +2. **Scenario & Deflection Strategies**: Explore various methods of asteroid deflection, such as Nuclear Detonation, Kinetic Impact, and Gravity Tractor. +3. **Simulation Tool**: Simulate asteroid trajectories and deflection outcomes. +4. **Dashboard**: View the dashboard, and other pages with relevant information and insights. + +## Getting Started + +### Django Backend Setup + +1. **Set Up Python Environment**: + - Vanilla Python: + ```sh + python -m venv deep-impact-env + ``` + - Virtual Environment Wrapper: + ```sh + mkvirtualenv deep-impact-env + ``` + - Activate the environment: + ```sh + source deep-impact-env/bin/activate + ``` + +2. **Install Required Packages**: + - Navigate to the backend directory and install dependencies: + ```sh + cd Deep-Impact/backend/deep_impact_proj + pip install -r requirements.txt + ``` + +### Vite Frontend Setup + +1. **Install Node Modules**: + - Navigate to the frontend directory and install dependencies: + ```sh + npm install + ``` + +2. **Run Development Server**: + - Start the development server: + ```sh + npm run dev + ``` + +## License + +Deep Impact is open-source software released under the [MIT License](LICENSE). Feel free to use, modify, and distribute the codebase in accordance with the terms of the license. + +Thank you for choosing Deep Impact. We hope you enjoy exploring our project and learning more about asteroid impacts! diff --git a/backend/deep_impact_proj/.env.sample b/backend/deep_impact_proj/.env.sample new file mode 100644 index 0000000..cc3ccc3 --- /dev/null +++ b/backend/deep_impact_proj/.env.sample @@ -0,0 +1,6 @@ +SECRET_KEY=<"Your Django Secret Key"> +SENTRY_API_KEY=<"Your NASA Sentry API Key"> +OPENAI_API_KEY=<"Your OpenAI API Key"> +HOST_CLIENT=<"Your FrontEnd URL"> +ALLOWED_HOSTS=<"Your Server URL"> +DEBUG=<"True for Deployment | False for Development"> \ No newline at end of file diff --git a/backend/deep_impact_proj/.gitignore b/backend/deep_impact_proj/.gitignore new file mode 100644 index 0000000..c66ba3a --- /dev/null +++ b/backend/deep_impact_proj/.gitignore @@ -0,0 +1,2 @@ +.env +.venv \ No newline at end of file diff --git a/backend/deep_impact_proj/api_app/__init__.py b/backend/deep_impact_proj/api_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/deep_impact_proj/api_app/__pycache__/__init__.cpython-311.pyc b/backend/deep_impact_proj/api_app/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..96988ff Binary files /dev/null and b/backend/deep_impact_proj/api_app/__pycache__/__init__.cpython-311.pyc differ diff --git a/backend/deep_impact_proj/api_app/__pycache__/admin.cpython-311.pyc b/backend/deep_impact_proj/api_app/__pycache__/admin.cpython-311.pyc new file mode 100644 index 0000000..aea8442 Binary files /dev/null and b/backend/deep_impact_proj/api_app/__pycache__/admin.cpython-311.pyc differ diff --git a/backend/deep_impact_proj/api_app/__pycache__/apps.cpython-311.pyc b/backend/deep_impact_proj/api_app/__pycache__/apps.cpython-311.pyc new file mode 100644 index 0000000..331dfe9 Binary files /dev/null and b/backend/deep_impact_proj/api_app/__pycache__/apps.cpython-311.pyc differ diff --git a/backend/deep_impact_proj/api_app/__pycache__/models.cpython-311.pyc b/backend/deep_impact_proj/api_app/__pycache__/models.cpython-311.pyc new file mode 100644 index 0000000..6b3e232 Binary files /dev/null and b/backend/deep_impact_proj/api_app/__pycache__/models.cpython-311.pyc differ diff --git a/backend/deep_impact_proj/api_app/__pycache__/urls.cpython-311.pyc b/backend/deep_impact_proj/api_app/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000..0ae640f Binary files /dev/null and b/backend/deep_impact_proj/api_app/__pycache__/urls.cpython-311.pyc differ diff --git a/backend/deep_impact_proj/api_app/__pycache__/utils.cpython-311.pyc b/backend/deep_impact_proj/api_app/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000..11ac1df Binary files /dev/null and b/backend/deep_impact_proj/api_app/__pycache__/utils.cpython-311.pyc differ diff --git a/backend/deep_impact_proj/api_app/__pycache__/views.cpython-311.pyc b/backend/deep_impact_proj/api_app/__pycache__/views.cpython-311.pyc new file mode 100644 index 0000000..23785c7 Binary files /dev/null and b/backend/deep_impact_proj/api_app/__pycache__/views.cpython-311.pyc differ diff --git a/backend/deep_impact_proj/api_app/admin.py b/backend/deep_impact_proj/api_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/backend/deep_impact_proj/api_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/backend/deep_impact_proj/api_app/apps.py b/backend/deep_impact_proj/api_app/apps.py new file mode 100644 index 0000000..4432ad0 --- /dev/null +++ b/backend/deep_impact_proj/api_app/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ApiAppConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'api_app' diff --git a/backend/deep_impact_proj/api_app/migrations/__init__.py b/backend/deep_impact_proj/api_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/deep_impact_proj/api_app/migrations/__pycache__/__init__.cpython-311.pyc b/backend/deep_impact_proj/api_app/migrations/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..19149c1 Binary files /dev/null and b/backend/deep_impact_proj/api_app/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/backend/deep_impact_proj/api_app/models.py b/backend/deep_impact_proj/api_app/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/backend/deep_impact_proj/api_app/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/backend/deep_impact_proj/api_app/tests.py b/backend/deep_impact_proj/api_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/backend/deep_impact_proj/api_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/backend/deep_impact_proj/api_app/urls.py b/backend/deep_impact_proj/api_app/urls.py new file mode 100644 index 0000000..b057ccd --- /dev/null +++ b/backend/deep_impact_proj/api_app/urls.py @@ -0,0 +1,9 @@ +from django.urls import path +from .views import Sentry, OpenAI + + + +urlpatterns = [ + path('sentry/', Sentry.as_view(), name='sentry'), + path('openai/', OpenAI.as_view(), name='openai'), +] diff --git a/backend/deep_impact_proj/api_app/utils.py b/backend/deep_impact_proj/api_app/utils.py new file mode 100644 index 0000000..c81d3e4 --- /dev/null +++ b/backend/deep_impact_proj/api_app/utils.py @@ -0,0 +1,23 @@ +from django.core.exceptions import ValidationError +import os +import requests +from rest_framework.response import Response +from rest_framework.status import ( + HTTP_200_OK, + HTTP_204_NO_CONTENT, + HTTP_201_CREATED, + HTTP_400_BAD_REQUEST +) + + +sentry_api_key = os.environ.get("SENTRY_API_KEY") + +def get_sentry(): + try: + response = requests.get(f'https://api.nasa.gov/neo/rest/v1/neo/browse?api_key={sentry_api_key}') + response.raise_for_status() + data = response.json() + return Response(data, status=HTTP_200_OK) + except ValidationError as e: + print(e) + return Response(e, status=HTTP_400_BAD_REQUEST) \ No newline at end of file diff --git a/backend/deep_impact_proj/api_app/views.py b/backend/deep_impact_proj/api_app/views.py new file mode 100644 index 0000000..de6a3f2 --- /dev/null +++ b/backend/deep_impact_proj/api_app/views.py @@ -0,0 +1,26 @@ +from django.shortcuts import render +from django.core.exceptions import ValidationError +import os +import requests +from rest_framework.views import APIView +from rest_framework.response import Response +from rest_framework.status import ( + HTTP_200_OK, + HTTP_204_NO_CONTENT, + HTTP_201_CREATED, + HTTP_400_BAD_REQUEST +) +from .utils import get_sentry + +sentry_api_key = os.environ.get("SENTRY_API_KEY") + + + +# Create your views here. +class Sentry(APIView): + def get(self, request): + return get_sentry() + + +class OpenAI(APIView): + pass diff --git a/backend/deep_impact_proj/db.sqlite3 b/backend/deep_impact_proj/db.sqlite3 new file mode 100644 index 0000000..fa02a47 Binary files /dev/null and b/backend/deep_impact_proj/db.sqlite3 differ diff --git a/backend/deep_impact_proj/deep_impact_proj/__init__.py b/backend/deep_impact_proj/deep_impact_proj/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/deep_impact_proj/deep_impact_proj/__pycache__/__init__.cpython-311.pyc b/backend/deep_impact_proj/deep_impact_proj/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..00cb333 Binary files /dev/null and b/backend/deep_impact_proj/deep_impact_proj/__pycache__/__init__.cpython-311.pyc differ diff --git a/backend/deep_impact_proj/deep_impact_proj/__pycache__/settings.cpython-311.pyc b/backend/deep_impact_proj/deep_impact_proj/__pycache__/settings.cpython-311.pyc new file mode 100644 index 0000000..74aab0a Binary files /dev/null and b/backend/deep_impact_proj/deep_impact_proj/__pycache__/settings.cpython-311.pyc differ diff --git a/backend/deep_impact_proj/deep_impact_proj/__pycache__/urls.cpython-311.pyc b/backend/deep_impact_proj/deep_impact_proj/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000..3a1cce6 Binary files /dev/null and b/backend/deep_impact_proj/deep_impact_proj/__pycache__/urls.cpython-311.pyc differ diff --git a/backend/deep_impact_proj/deep_impact_proj/__pycache__/wsgi.cpython-311.pyc b/backend/deep_impact_proj/deep_impact_proj/__pycache__/wsgi.cpython-311.pyc new file mode 100644 index 0000000..7caa192 Binary files /dev/null and b/backend/deep_impact_proj/deep_impact_proj/__pycache__/wsgi.cpython-311.pyc differ diff --git a/backend/deep_impact_proj/deep_impact_proj/asgi.py b/backend/deep_impact_proj/deep_impact_proj/asgi.py new file mode 100644 index 0000000..e521e2e --- /dev/null +++ b/backend/deep_impact_proj/deep_impact_proj/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for deep_impact_proj project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'deep_impact_proj.settings') + +application = get_asgi_application() diff --git a/backend/deep_impact_proj/deep_impact_proj/settings.py b/backend/deep_impact_proj/deep_impact_proj/settings.py new file mode 100644 index 0000000..389d485 --- /dev/null +++ b/backend/deep_impact_proj/deep_impact_proj/settings.py @@ -0,0 +1,138 @@ +""" +Django settings for deep_impact_proj project. + +Generated by 'django-admin startproject' using Django 5.0.4. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.0/ref/settings/ +""" +import os +from pathlib import Path +from dotenv import load_dotenv + +# Load environment variables from .env file +load_dotenv() + + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = os.environ.get("SECRET_KEY") + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = os.environ.get("DEBUG") + +ALLOWED_HOSTS = [os.environ.get("ALLOWED_HOSTS"), "localhost"] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'corsheaders', + 'api_app', + 'rest_framework', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'corsheaders.middleware.CorsMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'deep_impact_proj.urls' + + + +CORS_ALLOWED_ORIGINS = [os.environ.get("HOST_CLIENT")] + + + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'deep_impact_proj.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.0/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/backend/deep_impact_proj/deep_impact_proj/urls.py b/backend/deep_impact_proj/deep_impact_proj/urls.py new file mode 100644 index 0000000..4b41197 --- /dev/null +++ b/backend/deep_impact_proj/deep_impact_proj/urls.py @@ -0,0 +1,23 @@ +""" +URL configuration for deep_impact_proj project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('api/', include('api_app.urls')), +] diff --git a/backend/deep_impact_proj/deep_impact_proj/wsgi.py b/backend/deep_impact_proj/deep_impact_proj/wsgi.py new file mode 100644 index 0000000..0c08fe8 --- /dev/null +++ b/backend/deep_impact_proj/deep_impact_proj/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for deep_impact_proj project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'deep_impact_proj.settings') + +application = get_wsgi_application() diff --git a/backend/deep_impact_proj/manage.py b/backend/deep_impact_proj/manage.py new file mode 100755 index 0000000..3331bb8 --- /dev/null +++ b/backend/deep_impact_proj/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'deep_impact_proj.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/backend/deep_impact_proj/requirements.txt b/backend/deep_impact_proj/requirements.txt new file mode 100644 index 0000000..4957a6f --- /dev/null +++ b/backend/deep_impact_proj/requirements.txt @@ -0,0 +1,17 @@ +asgiref==3.8.1 +certifi==2024.2.2 +charset-normalizer==3.3.2 +click==8.1.7 +Django==5.0.6 +django-cors-headers==4.2.0 +djangorestframework==3.15.1 +gunicorn==22.0.0 +h11==0.14.0 +idna==3.7 +packaging==24.0 +python-dotenv==1.0.1 +requests==2.31.0 +sqlparse==0.5.0 +urllib3==2.2.1 +uvicorn==0.29.0 +whitenoise==6.6.0 diff --git a/frontend/index.html b/frontend/index.html index 0c589ec..aa5d224 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -2,9 +2,9 @@
- + -Main
Scenario
About
Effects
Defenses
About
+What is Deep Impact?
+Deep impact is a web-app designed to give users insight into potential danger of asteroid impact. Using the NASA NeoWs API we have created a simulation tool to visualize incoming asteroids and various methods of asteroid deflection.
+Our Team
+The Sky Is Falling!
+To see learn more about Deep Impact, checkout our GitHub.
Defending Earth against potentially hazardous meteors or asteroids involves several strategies and technologies, primarily focused on detection, deflection, and disruption. Here are the primary defense options:
+By combining these strategies, the global community aims to protect Earth from the potentially devastating effects of asteroid impacts.
+The impact of a meteor hitting Earth can vary widely depending on the size, composition, speed, and location of the impact. Here are the key impacts based on the size of the meteor:
+In summary, while the impact of small meteors is relatively minor and localized, large meteors can have devastating global consequences. Preparedness and mitigation strategies are essential for minimizing the potential impacts of such events.
+