Skip to content

rlcDev/millennium-falcon-challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI build Status CD build Status

The Millennium Falcon Challenge

Context

The current project is a solution implementation in response of the Millennium Falcon Challenge. The details of the mission are described here.

What are the odds ?

Never tell me the odds

Actually, there are several ways to get them. Let's discover that together!

Requirements

To take up the challenge, the following stack has been chosen:

  • Backend called the Millennium Falcon based on NestJS
  • Frontend called c3po implemented in Angular
  • Command line interface called r2d2 using Nest Commander

If you would like to explore the project, you would need at least Node LTS 18.12.1 and NPM 8.19.2.

Eventually you might need Docker with Docker Compose.

Web application

A first way to compute the odd is to use a developed web application which has been deployed : falcon.rlaurent.fr.

The UI consists in a basic computer screen where you can upload the empire JSON file by clicking on the icon :

web app desktop

which is responsive :

mobile

Command Line Interface

A second way to get the odds for a mission is to use the provided CLI, released in the project.

You can get the odds by launching a signed 'give-me-the-odds' executable. You must select the executable base on your platform, which is reflected in the folder name of the CLI package delivered. The platforms available are :

  • Windows x64
  • Linux x64
  • MacOS x64
  • MacOS arm64

For instance the syntax on an Archlinux distribution is :

./give-me-the-odds <path to the millennium-falcon json file> <path to the empire json file>

Note : The paths can be relative or absolute.

Example :

cli success example

The CLI should guide you in your travel :

  • No arguments provided :

cli no args

  • Too many arguments :

cli too many args

  • Any time you can consult the help with :

give-me-the-odds -h

cli help

Deploying locally on your computer

You can get the odds by running the web application on your computer. All you need is Docker and Docker Compose.

Once the project is released the CI/CD pipeline pushes Docker images to DockerHub :

So you can use docker-compose to deploy it locally. From the root of the project :

cd deployment && docker-compose up -d

Using Swagger

Eventually the last way to get the odds is to use Swagger.

Along with the deliveries a Swagger doc of the API is deployed here : falcon-swagger.rlaurent.fr/swagger

You can then upload you empire json file and get the odds.

An example :

swagger

It's not the main goal of Swagger, of course! :)

However, you can discover the exposed API: Falcon mission odds' API :

api-discovery

Contribution

If you would like to contribute to the project, you would need first to git clone the project :

git clone [email protected]:rlcDev/millennium-falcon-challenge.git

The backend

  • To start the backend, you should run :

npm start

And to watch the changes :

npm run start:dev

And you can target the api on port 3000.

Note : Swagger will be available at http://localhost:3000/swagger

  • To run the unit tests :

npm run test

  • To run the e2e tests :

npm run test:e2e

  • To check the test coverage

npm run test:cov

Also, there is a script to generate the cli:

npm run cli:build-prod

In order to be able to run it, you need have cp command.

Note : The generated CLI might work on your machine. But if you want to distribute it, you need to sign it. You can do it with ldid or codesign.

At the end all you need is its package.json.

The frontend

  • To start the frontend.

npm start

Note : The application will be available on port 4200 http://localhost:4200

  • To run the unit tests :

npm run test

Same idea, you could refer to the package.json for other commands.

Pushing changes

Whenever your code is ready, you can make sure that:

  • Code guidelines are applied
  • Your changes are tested with new tests
  • The older ones passed

And you can submit a pull request to the develop branch and wait for reviews and approvals.

Thanks for reading :)!