Skip to content

ThomasCode92/nasa-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

32 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

NASA Project

Fullstack application for controlling space missions and enabling seamless exploration beyond our planet. ๐ŸŒŒ๐Ÿ›ฐ๏ธ
Build with Node.js and React, a powerful combination for building dynamic and scalable web applications for seamless client-server interactions.

About this Repository
This project is part of the Complete NodeJS Developer course from Zero To Mastery. It functions as a practical example showcasing the steps involved in creating a comprehensive fullstack project, with a particular emphasis on developing the backend server and seamlessly integrating APIs with the client.

TL;DR

  # Include your MongoDB connection string (MONGO_URL) a server/.env.local file.

  npm run install # install client and server dependencies
  npm run watch # start the client and server applications

  # Visit localhost:3000 to interact with the application

Project structure

The project consists of 3 npm packages

  • nasa-fe: This package represents the client-side React application. While not actively developed within the project, its source code has been provided, and only API integration has been implemented.
  • nasa-project-api: This package serves as the server-side Node.js/Express application and is the primary focus of this project.
  • nasa-project: This is the root project that manages both the client and server components.

Architecture Diagram

To initiate the application in development mode, execute the following command in the project's root directory: npm run watch
This command will launch the server on port 8000 and the client on port 3000. Make sure all the (client and server) dependencies are installed with npm run install.

Client

The React application has been bootstrapped using Create React App and constructed with the arwes framework. This application functions as a dashboard where users can create launches, explore upcoming missions, and review historical mission data.
To exclusively access the frontend, execute the command npm run client in the project's root directory.

Server

The server is implemented as a Node.js and Express application, utilizing Kepler data as its primary source for identifying habitable planets. The process is detailed in the planet-explorer repository.
In addition to utilizing Kepler data, a MongoDB database is used to keep track of all missions created and aborted by the user. This information is accessible to the user through a user-friendly API, providing comprehensive data about their mission launches.
To establish a connection with the database, insert your connection string, identified as MONGO_URL, into a .env.local file within the server project. For running tests, a separate test database is required. Therefore, add a MONGO_TEST_URL within the same file.

  MONGO_URL=mongodb+srv://..... # production database
  MONGO_TEST_URL=mongodb+srv://..... # test database

It's important to mention that the test database will be generated prior to and removed following every test execution.

Development

When the application is launched with npm run watch, nodemon is employed to automatically reload the server whenever there are changes detected in the source code. This ensures a seamless development experience by facilitating real-time updates without manual intervention.

The following commands can be particularly beneficial during development:

  npm run install-server <PACKAGE_NAME> # install a package for the server
  npm run deploy # view the application as it would deploy on a real server

Executing the deploy command will initiate the server on port 8000. You can view the client application by visiting localhost:8000 in your browser. Additionally, the install-server command allows for the installation of a package specifically for the server, aiding in the management of server-side dependencies.

Improving Performance
For better performance and the ability to manage increased request loads, the server can leverage PM2. PM2, a powerful tool designed for creating clusters, enables the deployment of multiple server instances. This clustering approach efficiently distributes the workload, optimizing resource utilization and thereby enhancing overall responsiveness.

  npm run deploy:cluster # view the (clustered) application as it would deploy on a real server
  npm run pm2 --prefix server <PM2 COMMAND> # Run a specific pm2 command on the server

Dockerizing & Production

To containerize (and run) your project, follow these steps:

  docker login
  docker build -t <YOUR_USERNAME>/nasa-project .
  docker push <YOUR_USERNAME>/nasa-project

  # Start the application using docker
  docker run -it -p 8000:8000 --env-file ./server/.env <YOUR_USERNAME>/nasa-project

Ensure to replace <YOUR_USERNAME> with your Docker Hub username.
Production Setup

To containerize (and run) your project, follow these steps:

  docker login
  docker build -t <YOUR_USERNAME>/nasa-project .
  docker run -it -p 8000:8000 --env-file ./server/.env <YOUR_USERNAME>/nasa-project

Ensure to replace <YOUR_USERNAME> with your Docker Hub username.
The .env file used to start the container should mirror the variables in your .env.local file, with an additional variable: NODE_ENV=production.

Deployment

Once your image is on Docker Hub, you can deploy it on your cloud provider (such as EC2 on AWS). However, detailed steps for this process are beyond the scope of this demo project. For more information, please refer to the official documentation provided by your cloud provider.

About

Fullstack application for controlling space missions and enabling seamless exploration beyond our planet. ๐Ÿš€๐ŸŒŒ

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published