An open API service indexing awesome lists of open source software.

https://github.com/simon-gardier/inventory-flutter-dotnet-app

MyVentory is an app/website built in Flutter with a backend written in Dotnet, hosted on Openshift and developped with modern CI/CD standards
https://github.com/simon-gardier/inventory-flutter-dotnet-app

cicd devops dotnet flutter gitlab-runner openapi postgres restapi swagger

Last synced: 3 months ago
JSON representation

MyVentory is an app/website built in Flutter with a backend written in Dotnet, hosted on Openshift and developped with modern CI/CD standards

Awesome Lists containing this project

README

          

```
__ ___ _ __ __ ___
/ |/ /_ _| | / /__ ____ / /_____ _______ __ / | ____ ____
/ /|_/ / / / / | / / _ \/ __ \/ __/ __ \/ ___/ / / / / /| | / __ \/ __ \
/ / / / /_/ /| |/ / __/ / / / /_/ /_/ / / / /_/ / / ___ |/ /_/ / /_/ /
/_/ /_/\__, / |___/\___/_/ /_/\__/\____/_/ \__, / /_/ |_/ .___/ .___/
/____/ /____/ /_/ /_/
```

https://github.com/user-attachments/assets/4e869afa-78b8-4e5e-aa90-8acb3f2211c6

## 🧪Documentation

### Tech stack (app)
- [Flutter](https://jira.montefiore.ulg.ac.be/xwiki/wiki/team0524/view/Technologies/Technology%20Choices%20for%20MyInventory%20System/).

### Tech stack (backend)
- [Dotnet](https://jira.montefiore.ulg.ac.be/xwiki/wiki/team0524/view/Technologies/Technology%20Choices%20for%20MyInventory%20System/).
- [Postgresql](https://jira.montefiore.ulg.ac.be/xwiki/wiki/team0524/view/Technologies/Technology%20Choices%20for%20MyInventory%20System/).

### Project structure (app)
- `Dockerfile.apk` and `Dockerfile.web` are used to create the nginx servers container that serves the download of the application and the website on openshift.
- `MyVentoryApp` contains the Flutter project.
- `MyVentoryApp/lib/` contains the main code of the application.
- `Openshift` contains the YAML fils for the deployment of the app on openshift.
- `gitlab-ci.yml` builds the apk, create an nginx (http server) image with the apk and push it to the container registry.

### Project structure (backend)
- `myventoryapi.sln`: [Solution file](https://learn.microsoft.com/en-us/visualstudio/ide/solutions-and-projects-in-visual-studio?view=vs-2022#solutions) referencing the 2 [dotnet projects](https://learn.microsoft.com/en-us/visualstudio/ide/solutions-and-projects-in-visual-studio?view=vs-2022#projects).
- `MyVentoryApi/`: dotnet project for the backend itself.
- `MyVentoryApi.Tests/`: dotnet project for the unit testing of the backend.
- `Openshift`: The YAML files used to deploy the infrastructure on Openshift

### Development environment (app)
- Install the preferred IDE: [Visual Studio Code](https://code.visualstudio.com/)
- Open the project in VSCode, notifications will appear to install the required extensions. **Accept everything**
- Install Flutter: [installation guide](https://flutter.dev/docs/get-started/install)
- [Android Studio](https://developer.android.com/studio) is required to run the application on an emulator.
- [Set up an Android emulator](https://developer.android.com/studio/run/emulator)
- Build application locally: `flutter build apk --release`
- Note: The apk will be placed in `build/app/outputs/flutter-apk/app-release.apk`.
- Run the application locally:
- Clone the [my-ventory-backend](https://gitlab.uliege.be/SPEAM/2024-2025/team5/myventorybackend) repository and follow the instructions to run the backend locally.
- Start the application: `flutter run --dart-define=API_BASE_URL=http://backend_url`. **Note**: A device (VM/Smartphone) must be connected to VSCode to run the application.
- Add the flag ``-d chrome` to run the application in Chrome.
- By default the applications connects **to the backend running on openshift**. To connect to a local backend, you need to set the `API_BASE_URL` environment variable to the local backend URL.
- `http://10.0.2.2/api` connects to the backend on your machine when running the application in an emulator.
- `http://localhost/api` connects to the backend on your machine when running the website on Chrome.
- `http://local_ip` connects to the backend on your machine when running the application on your smartphone. See `ipconfig` to know your local ip address. More details [here](https://jira.montefiore.ulg.ac.be/xwiki/wiki/team0524/view/Technologies/Local%20development%20and%20testing/).
- To connect a device (VM or smartphone):
- Start the device in Android studio / Connect the smartphone to the computer.
- Select the device in the bottom right corner of VSCode.
- Start the application. It should appear on the device.
- Run the integration tests:
- Just as for `Run the application locally`, you must start the backend locally and set the `API_BASE_URL` environment variable to the local backend URL.
- The integration tests are made to be run on an androind emulator. Thus, you must have one running.
- Start the tests with : `flutter test integration_test/run_integration_tests.dart --dart-define=API_BASE_URL=http://10.0.2.2/api`

### Development environment (backend)
- Install the [.NET 9.0](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) sdk
- Install the recommended IDE: [Visual Studio Code](https://code.visualstudio.com/)
- Open the project in [Visual Studio Code](https://code.visualstudio.com/), notifications will appear to install the required extensions. **Accept everything**
- Setup your environment:
- Create a `database.env` file at the root of the project. See `database.env_template` for a template with explanations on where to find the necessary keys.
- In `MyVentoryApi`, create a `.env` file in the folder `MyVentoryApi/`. See `MyVentoryApi/.env_template` for a template with explanations on where to find the necessary keys.
- You need to trust the SSL certificate to use the backend locally, from `MyVentoryApi/` type: `dotnet dev-certs https --trust`
- Run the backend **locally**:
- Start Docker desktop
- **Start the DB**: `docker-compose --env-file database.env up -d` (remove the `-d` if you want the logs)
- **Note:** You need a database.env file to use `run`. See the "Environment" section above.
- Inspect the database by opening a terminal in the container (from the Docker GUI) and type: `psql -U Team5 -d MyVentory`
- Inspect the database in pgAdmin [here](http://localhost:5050), email: `admin@myventory.com`, password: same as [POSTGRES_PASSWORD in "Variables" section](https://gitlab.uliege.be/SPEAM/2024-2025/team5/myventorybackend/-/settings/ci_cd).
- After connection, right click `Servers` > `Register` > `Server`.
- In General tab, Name: my-ventory-database
- In Connection tab, Host name: my-ventory-database, Username: Team5, Password: same as [POSTGRES_PASSWORD in "Variables" section](https://gitlab.uliege.be/SPEAM/2024-2025/team5/myventorybackend/-/settings/ci_cd)
- If you want to erase the DB, delete the volume from Docker Desktop.
- Note: On pgAdmin hosted on openshift, the name and host name are **myventory-db-service**.
- **Start the backend** (from the `MyVentoryApi` folder): `dotnet run`
- Access the API doc page in local [here](https://localhost/).
- How to update the Database scheme:
When you add a table / modify an exisiting table, you have to create a `Migration` to apply these changes to the DB.
- Install EF CLI tools: `dotnet tool install --global dotnet-ef`
- From the `MyVentoryApi` folder, run `dotnet ef migrations add ` to generate the migration files. They will be used automatically by the pod on Openshift.
- Run the tests in local (in the `MyVentoryApi.Tests` folder):
You must first install [Docker](https://www.docker.com/) and follow the step from above ("**Start the DB**"), as the tests require the database engine to be running.
- You can list the tests with: `dotnet test -t`
- Run the tests with: `dotnet test --logger "html;LogFileName=test-results.html"`
- Read the results of the tests: open the file `MyVentoryApi.Tests/TestResults/test-results.html` in your browser.
- Note: the results are also available in the terminal from which you ran the tests (its just less readable).
- Note: Running the tests delete and recreate your local database.
- Note 2: You must copy your .env file from the `MyVentoryApi` folder to the `MyVentoryApi.Tests` folder.

### CI/CD (app)
- See the [Deployement](https://jira.montefiore.ulg.ac.be/xwiki/wiki/team0524/view/Infra/) wiki page to understand how the pipeline works.

### CI/CD (backend)
- Rules: the pipeline is triggered on every push to the **main** branch, except if the changes pushed are only in *.md files.
- Output:
- Backend container image

## 🔗Usefull references
- [Wiki](https://jira.montefiore.ulg.ac.be/xwiki/wiki/team0524/view/Main/)
- [Technologies used](https://jira.montefiore.ulg.ac.be/xwiki/wiki/team0524/view/Technologies/)
- [Infra doc](https://jira.montefiore.ulg.ac.be/xwiki/wiki/team0524/view/Infra/)
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
- [online documentation](https://docs.flutter.dev/), which offers tutorials, samples, guidance on mobile development, and a full API reference.

## ✍️Main contributors
- Developpement: [Alexandre](alexandre.luzzi@student.uliege.be), [Julien MP](julien.mparirwa@student.uliege.be), [Marzouk](marzouk.ouro-gomma@student.uliege.be)
- CRUD API: [Simon](s.gardier@student.uliege.be), [Dario](dario.rinallo@student.uliege.be)
- External APIs: [Julien DR](julien.direnzo@student.uliege.be), [Marzouk](marzouk.ouro-gomma@student.uliege.be)
- DevOps: [Simon](s.gardier@student.uliege.be)