# REST API - MemoryMap [![Build Status](https://codefirst.iut.uca.fr/api/badges/SAE3A_MemoryMap/api/status.svg)](https://codefirst.iut.uca.fr/SAE3A_MemoryMap/api) [![Quality Gate Status](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=SAE3A_MemoryMap-api&token=65450ce2ffdd247afe93544fa91b41a082ad5217&metric=alert_status)](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api) [![Bugs](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=SAE3A_MemoryMap-api&token=65450ce2ffdd247afe93544fa91b41a082ad5217&metric=bugs)](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api) [![Code Smells](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=SAE3A_MemoryMap-api&token=65450ce2ffdd247afe93544fa91b41a082ad5217&metric=code_smells)](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api) [![Coverage](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=SAE3A_MemoryMap-api&token=65450ce2ffdd247afe93544fa91b41a082ad5217&metric=coverage)](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api) [![Duplicated Lines (%)](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=SAE3A_MemoryMap-api&token=65450ce2ffdd247afe93544fa91b41a082ad5217&metric=duplicated_lines_density)](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api) [![Lines of Code](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=SAE3A_MemoryMap-api&token=65450ce2ffdd247afe93544fa91b41a082ad5217&metric=ncloc)](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api) [![Maintainability Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=SAE3A_MemoryMap-api&token=65450ce2ffdd247afe93544fa91b41a082ad5217&metric=sqale_rating)](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api) [![Reliability Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=SAE3A_MemoryMap-api&token=65450ce2ffdd247afe93544fa91b41a082ad5217&metric=reliability_rating)](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api) [![Security Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=SAE3A_MemoryMap-api&token=65450ce2ffdd247afe93544fa91b41a082ad5217&metric=security_rating)](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api) [![Technical Debt](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=SAE3A_MemoryMap-api&token=65450ce2ffdd247afe93544fa91b41a082ad5217&metric=sqale_index)](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api) [![Vulnerabilities](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=SAE3A_MemoryMap-api&token=65450ce2ffdd247afe93544fa91b41a082ad5217&metric=vulnerabilities)](https://codefirst.iut.uca.fr/sonar/dashboard?id=SAE3A_MemoryMap-api) > Made with FastAPI (Python) ## Documentation You can find the official documentation for the project at https://api.memorymap.fr/docs (or https://api.memorymap.fr/redoc) ## How to run it > If you want to try the API on the production environment, please look at the documentation ### Prerequisites - Docker ### Running the Application 1. **Clone the repository**: ```bash git clone https://codefirst.iut.uca.fr/git/SAE3A_MemoryMap/api.git cd api ``` 2. **Create a `.env` file**: Create a `.env` file in the root directory of your project and add the following environment variables: ```env MONGODB_URL=mongodb://localhost:27017/ MONGODB_USERNAME=mongoadmin MONGODB_PASSWORD=secret MONGODB_DATABASE=memorymap JWT_SECRET_KEY=your_jwt_secret_key JWT_ALGORITHM=HS256 JWT_ACCESS_TOKEN_EXPIRE_MINUTES=30 ``` 3. **Build the docker image for the API**: ```bash docker build -t memorymap_api -f docker/Dockerfile . ``` 4. **Run the MongoDB container**: ```bash docker run -d -p 27017:27017 --name mongodb -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret mongo:8.0.3-noble ``` 5. **Run the API container**: ```bash docker run -d -p 8000:8000 --name memorymap_api --env-file .env memorymap_api ``` 6. **Access the API**: The API will be available at `http://localhost:8000` and the documentation at `http://localhost:8000/docs` (or `http://localhost:8000/redoc`) ### Running Tests 1. **Install test dependencies**: ```bash pip install -r tests/requirements.txt ``` 2. **Run the MongoDB container**: ⚠ Do **not** change USERNAME / PASSWORD values ```bash docker run -d -p 27017:27017 --name mongodb -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret mongo:8.0.3-noble ``` 2. **Run the tests**: ```bash pytest ```