From a7b534b1ddb702a5bf18443904768bdfa6315f48 Mon Sep 17 00:00:00 2001 From: ccornu <ccornu@takima.fr> Date: Tue, 11 Feb 2025 12:10:18 +0100 Subject: [PATCH] feat: update README.md --- README.md | 114 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 79 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index afe3e09..810239f 100644 --- a/README.md +++ b/README.md @@ -1,63 +1,107 @@ # Tournament API -## Initalisation +## Initialization ### Pre-requisites -You need to have Docker and AWS CLI installed on your machine +Ensure you have the following tools installed on your machine: -### How to start the database +- [Docker](https://www.docker.com/) +- [AWS CLI](https://aws.amazon.com/cli/) -In `docker/db` folder, run the following command: +### Starting the database + +Navigate to the `docker/db` directory and run the following command to start the local database: ```bash docker compose up -d ``` -### How to start the API +### Starting the API -Place yourself at root and start +1. Make sure that the database is up by executing ```bash -docker compose up -d +docker ps +``` + +Look for the `dynamodb-local` container in the list of running services + +2. From the root directory, start the API using: + +```bash +./gradlew run ``` -// or with cmd +--- ## Available endpoints -## Technical choices +Below is a list of available API endpoints and their usage: + +| Endpoint goal | HTTP verb | URL | Body | Response | +|-------------------------------|-----------|------------------------|-------------------------------------------|--------------------------------------------------------------------------------------------------------------| +| Create new player | POST | /players | { "pseudo" : "John" } | { "pseudo" : "John", "pointsNumber": 0 } | +| Update players points | PUT | /players | { "pseudo" : "John", "pointsNumber": 15 } | { "pseudo" : "John", "pointsNumber": 15 } | +| Get player by its pseudo | GET | /players/{pseudo} | | { "pseudo" : "Francis", "pointsNumber": 0 } | +| Get player info by its pseudo | GET | /players/{pseudo}/info | | { "pseudo" : "Francis", "pointsNumber": 0, rank : 2 } | +| Get players ranking | GET | /players/ranking | | [{ "pseudo" : "John", "pointsNumber": 15, rank : 1 }, { "pseudo" : "Francis", "pointsNumber": 0, rank : 2 }] | +| Delete player | DELETE | /players | | | + +--- + +## Testing + +To verify that the tests are functioning correctly, run the following command: + +```bash +./gradlew clean test --info +``` + +--- + +## Preparing for Production + +To deploy this application in a production environment, there are several key areas to address: + +### 1. Security management : + +**Database** + +- Currently, a local database with dummy logging is used. For production, you can leverage AWS DynamoDB in the cloud by + connecting your API to a live DynamoDB instance. +- Be mindful of the costs associated with using a cloud database. + +**Endpoints** + +- All API endpoints are currently open to public access. For secure access, implement authentication using the + `ktor-server-auth` plugin. + +- Consider using an IAM solution, such as: + - **AWS IAM** + - **Keycloak** + - **Microsoft EntraID** -- I chose ... because ... +- Additionally, you can use an API Gateway (e.g., Kong) to handle requests and manage security for your API. -## I want to ensure tests are running +### 2. Database and table creation -## Left to do +- Currently, the database is started manually, and table creation is handled at application startup. +- For production, use Terraform to manage the setup of DynamoDB tables and establish connections with AWS + infrastructure. -- [x] setup dynamo DB -- [x] faire la connexion avec Dynamo -- 1er endpoint - - [x] créer l'entité joueur - - [x] créer le repo et le connecter à la BD - - [x] tester unitairement le service - - [ ] tester l'intégration complète - - [x] endpoint fonctionnel pour l'ajout d'un joueur avec test - - [ ] tests d'intégration - - [ ] tests unitaires -- [x] tous les endpoints demandés -- [ ] gestion de la sécurité +### 3. CI/CD Pipelines -Dans l'ordre : +Implementing CI/CD pipelines is essential for seamless deployment. Set up the following jobs in your repository: -- Amélioration du fonctionnel - - Routes factorisées - - DTO - - Appels à la BD -- Amélioration des tests -- Amélioration de la sécurité -- Déploiement en prod serein +- `install dependencies`: Cache reusable dependencies for subsequent jobs. +- `build`: Ensure the application compiles successfully. +- `test`: Run all application tests to validate functionality. +- `package`: Prepare the application for deployment. +- `deploy`: Create a manual, clickable job to deploy the application to the desired environment -## Going further +### 4. GreenIT Considerations -- Database migration tool -- ... \ No newline at end of file +- This application is primarily used during tournaments to calculate points and rankings. +- To reduce unnecessary resource consumption, we could set up infrastructure jobs to shut down the API when not in use + and restart it when needed. \ No newline at end of file -- GitLab