# Getting started with Ecolyo Agent This section will allow you to launch a proper local environment for Ecolyo-Agent !!! info "" If you are a new developer tasked to work on this project, check the [setup your environment](../../setup_your_environment.md). ##  Repositories This project is split between a backend and frontend, each project has its own repository. [Ecolyo-Agent Client repository](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-client) [Ecolyo-Agent Server repository](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-server) ## Local usage !!! note Before launching the application, ensure you've properly filled the `.env` file according to the template. If needed please refer to a team member. The template contains - IMAGE_FOLDER: this variable specify the folder where ecogestures images are located. By default, you can place this folder at the same level as your project for a local usage. (not inside the project). For alpha, rec/prod environment, make sure the path indicated in docker-compose volumes correspond with the location of the image file on the server. - MOCK_OAUTH2: Set this variable to true while in local, so the OAuth2 dance will be mocked by backend and you will be able to login to your application. In order to launch the project in local with the backend working launch the following command ```bash yarn local-up ``` This command will launch the app from the _docker-compose.local.yml_ file, which will launch 4 images and start the react app with _yarn start_ - The backend Go app, from the image located on its Gitlab repository - A mySQL database, from the DockerHub image - A phpMyAdmin to browse the database, from the DockerHub image - The Nginx server with a local configuration located in nginx/site.conf ???note "Nginx info" The nginx server redirects https requests from front-end to the backend on port 1443. It has two configuration files : - `nginx/site.conf`, used for local development - `nginx/site.prod.conf`, used for production The nginx server needs local ssl certificates in order to run an interact with backend, these certificates are present in the project. To stop it properly use ```bash yarn local-down ``` ??? note "for windows users" :warning: **If you are launching the project from a Windows OS** : Make sure to comment the 'extra_hosts' lines in the docker-compose.local file. Otherwise, you you won't be able to access your machine's localhost from the docker container. To check if the application starts successfully, launch the command ```bash docker logs backoffice-client_backend_1 ``` You should obtain the following messages: > --- Server is starting --- > Token signing key set > Mock OAuth2 server Listening on: <http://localhost:8090> Once the application is started, you can access it at <https://localhost> !!! tip This app runs in https, such as the backend, to access it go on <https://localhost/> Also make sure you have HTTPS env variable set to true. **Do not** use the app with the port 3000, you won't be able to login. ## Ecolyo Agent - Server ### Features - Authentification using OAuth2 - Connected admins can use an API to edit and save different sections of the newsletters that will be sent to Ecolyo users - Exposes a public route to get the sections of a specific or the last newsletter ### Setup This backend should be deployed with the frontend using [local command](#local-usage) However this backend can be run in standalone : - Set a .env file at the root and add all variables declared in the template.env - (Optionnal) Create new certificates by running cd dev_certificates && ./generate-certificates.sh - Run `docker-compose up -d` Once deployed, you can access to a Swagger documentation of the API on <https://${HOSTNAME}/swagger/index.html> ### Launch locally Launch all necessary services : Run `docker-compose up -d` In local you can access phpmyadmin interface to manage the database : <http://localhost:8008> Launch the server by pressing F5 on vscode, you will see the logs on the debug console. All API routes are available on <https://localhost:1443> ### Build image for local `docker build . -t backoffice-server`