# README
Space Voyager
Types of Exoplanets
- Gas Giant: Composed of only gaseous compounds.
- Terrestrial: Earth-like planets, a bit more rocky and larger than Earth.
Features
-
Add an Exoplanet: Add a new exoplanet by providing the following properties:
- name
- description
- distance from Earth (in light years)
- radius (in Earth-radius units)
- mass (only for Terrestrial planets, in Earth-mass units)
- type (GasGiant or Terrestrial)
-
List Exoplanets: Retrieve a list of all available exoplanets.
-
Get Exoplanet by ID: Retrieve information about a specific exoplanet by its unique ID.
-
Update Exoplanet: Update the details of an existing exoplanet.
-
Delete Exoplanet: Remove an exoplanet from the catalog.
-
Fuel Estimation: Estimate the fuel cost for a trip to a particular exoplanet based on the distance, gravity of the exoplanet, and crew capacity.
Running the Service
Using Docker
- Build the Docker image:
make build
- Run the Docker container:
make run
API Endpoints - Exoplanet Mircoservice
Health Check
- URL:
/exoplanets/api/v1/health
- Method:
GET
Add an Exoplanet
- URL:
/exoplanets/api/v1/exoplanets
- Method:
POST
- Data:
{ "name": "Kepler-22b", "description": "A possible super-Earth exoplanet.", "distance": 6, "radius": 2.4, "mass": 5.0, "type": "Terrestrial" }
- CURL:
$ curl --location 'localhost:3003/exoplanets/api/v1/exoplanets' \
--header 'Content-Type: application/json' \
--data '{
"name": "AaaaKepler-22b",
"description": "A possible super-Earth exoplanet.",
"distance": 1,
"radius": 3.4,
"mass": 2.0,
"type": "GasGiant"
}'
List Exoplanets
- URL:
/exoplanets/api/v1/exoplanets
- Method:
GET
- CURL:
$ curl --location 'localhost:3003/exoplanets/api/v1/exoplanets'
Get Exoplanet by ID
- URL:
/exoplanets/api/v1/exoplanets/getexoplanet?id=1
- Method:
GET
- CURL:
$ curl --location 'localhost:3003/exoplanets/api/v1/exoplanets/getexoplanet?id=3'
Update Exoplanet
- URL:
/exoplanets/api/v1/exoplanets/updateexoplanet
- Method:
PUT
- Data:
{ "id": "1", "name": "Kepler-22b", "description": "A possible super-Earth exoplanet.", "distance": 6, "radius": 5.4, "mass": 5.0, "type": "Terrestrial" }
- CURL:
$ curl --location --request PUT 'localhost:3003/exoplanets/api/v1/exoplanets/updateexoplanet' \
--header 'Content-Type: application/json' \
--data '{
"id": "1",
"name": "Kepler-22b",
"description": "A possible super-Earth exoplanet.",
"distance": 6,
"radius": 5.4,
"mass": 5.0,
"type": "GasGiant"
}'
Delete Exoplanet
- URL:
/exoplanets/api/v1/exoplanets/deleteexoplanet?id=1
- Method:
DELETE
- CURL:
$ curl --location --request DELETE 'localhost:3003/exoplanets/api/v1/exoplanets/deleteexoplanet?id=1'
API Endpoints - Fuelestimation Mircoservice
Fuel Estimation
- URL:
/fuelestimation/api/v1/fuelestimation?crewcount=50&planetid=2
- Method:
GET
- CURL:
$ curl --location 'localhost:6000/fuelestimation/api/v1/fuelestimation?crewcount=50&planetid=1'
Fuel Calculation
Fuel estimation to reach an exoplanet can be calculated as:
f = d / (g^2) * c units
Where:
d
= distance of exoplanet from Earthg
= gravity of exoplanetc
= crew capacity (int)
Gravity Calculation
- Gas Giant:
g = (0.5 / r^2)
- Terrestrial:
g = (m / r^2)
Where:
m
= massr
= radius
Constraints
10 < d < 1000
(light years) : int0.1 < m < 10
(Earth-Mass unit) : double0.1 < r < 10
(Earth-radius unit) : double