- 📌 Project Description
- 🏗️ Project Architecture
- 🚀 Key Features
- 🏗️ Installation & Configuration
- 🔗 API Endpoints
- 📡 Deployment
- 🚀 Roadmap & Future Improvements
- 📜 Export Project Dependencies
- 👨💻 Author & Contributions
- 📜 License
- 👥 Authors
Loto API is an application that allows users to manage their lottery tickets and automatically calculate their winnings by comparing their numbers with official results. The project includes a secure API with JWT authentication, a ticket management system, and a hybrid SQL/NoSQL database.
The application follows a Full-Stack architecture:
- Frontend: Simple web interface based on HTML, CSS, and JavaScript.
- Backend: REST API developed with Spring Boot 3.4.2.
- Database:
- SQLite: Stores users and tickets.
- MongoDB: Stores historical results.
- Automation: A script retrieves and updates draw results from source files.
- ✔️ User management (Registration, Login, JWT Authentication).
- ✔️ Ticket submission and management (CRUD operations on tickets).
- ✔️ Automatic calculation of winnings.
- ✔️ Historical results stored in MongoDB.
- ✔️ Visualization of results through charts.
- ✔️ Automatic updates of results via a script.
- ✔️ API endpoint security with Spring Security & JWT.
git clone https://github.com/SDINAHET/Loto_API.git
cd Loto_API
Configure application.properties
:
spring.datasource.url=jdbc:sqlite:loto.db
spring.datasource.driver-class-name=org.sqlite.JDBC
spring.datasource.username=
spring.datasource.password=
spring.datasource.hikari.maximum-pool-size=5
Start MongoDB and configure application.properties
:
spring.data.mongodb.uri=mongodb://localhost:27017/loto_results
mvn install
mvn spring-boot:run
The API is available at http://localhost:8082/swagger-ui/index.html
The web interface can be served using Live Server on VSCode. Open index.html
and start Live Server to access http://127.0.0.1:5500/src/main/resources/static/index.html
.
npm install -g http-server
http-server src/main/resources/static -p 5500
http-server src/main/resources/static -p 5500 -a 0.0.0.0
Available front on: http://127.0.0.1:5500
🔗 Swagger UI : see API doc
Method | Endpoint | Description |
---|---|---|
POST | /api/users/register |
User registration |
POST | /api/auth/login3 |
Login and JWT generation |
GET | /api/auth/me |
Retrieve user info |
GET | /api/auth/me/firstname |
Retrieve user's first name |
POST | /api/auth/logout |
Logout (JWT deletion) |
GET | /api/users |
Retrieve list of users (Admin only) |
GET | /api/users/{id} |
Retrieve a user's details |
DELETE | /api/users/{id} |
Delete a user (Admin only) |
PUT | /api/users/{id} |
Update user information |
Method | Endpoint | Description |
---|---|---|
POST | /api/tickets |
Add a ticket |
GET | /api/tickets |
List user tickets |
GET | /api/tickets/{id} |
Ticket details |
DELETE | /api/tickets/{id} |
Delete a ticket |
PUT | /api/tickets/{id} |
Modify a ticket |
Method | Endpoint | Description |
---|---|---|
GET | /api/tirages |
List all draws |
GET | /api/tirages/dates |
Retrieve available draw dates |
GET | /api/tirages?startDate={}&endDate={} |
Draws between two dates |
Method | Endpoint | Description |
---|---|---|
GET | /api/gains/calculate |
Calculate ticket winnings |
GET | /api/gains |
Retrieve recorded winnings |
GET | /api/gains/{ticketId} |
Details of a ticket's winnings |
Method | Endpoint | Description |
---|---|---|
GET | /api/historique/last20 |
Retrieve the last 20 results |
GET | /api/historique/last20/Detail/tirage/{date} |
Details of a draw by date |
GET | /api/historique/last20/Detail/tirages?startDate={}&endDate={} |
History between two dates |
The project can be deployed on Alwaysdata, AWS, or a VPS using Docker.
Create Dockerfile.backend
for the backend at the root of the project:
# Use a lightweight Java 21 image
FROM openjdk:21-jdk-slim
# Set the working directory
WORKDIR /app
# Copy backend files
COPY . /app
# Execution permissions
RUN chmod +x mvnw
# Build the application
RUN ./mvnw install
# Run the application
CMD ["./mvnw", "spring-boot:run"]
# Expose the API port
EXPOSE 8082
Create Dockerfile.frontend for the frontend at the root of the project:
# Use a lightweight Node.js image
FROM node:18-alpine
# Install http-server globally
RUN npm install -g http-server
# Set the working directory
WORKDIR /app
# Copy frontend files
COPY src/main/resources/static /app
# Expose port 5500
EXPOSE 5500
# Start the HTTP server
CMD ["http-server", "-p", "5500"]
Create a docker-compose.yml
file to orchestrate the application:
version: "3.8"
services:
backend:
build:
context: .
dockerfile: Dockerfile.backend
ports:
- "8082:8082"
depends_on:
- mongodb
environment:
SPRING_DATA_MONGODB_URI: mongodb://mongodb:27017/loto_database # No authentication required
frontend:
build:
context: .
dockerfile: Dockerfile.frontend
ports:
- "5500:5500"
depends_on:
- backend
mongodb:
image: mongo:latest
container_name: mongodb
restart: always
ports:
- "27017:27017"
environment:
MONGO_INITDB_DATABASE: loto_database # Sets the default database
volumes:
- mongodb_data:/data/db
# - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro # Ensure this file exists
volumes:
mongodb_data:
Start the containers:
docker-compose up -d --build
http-server src/main/resources/static -p 5500
Then open your browser at http://127.0.0.1:5500/ to access the frontend and for the backend (Swagger): http://localhost:8082/swagger-ui/index.html.
📌 Explanation: up -d → Starts the containers in the background (detached mode). --build → Forces Docker to rebuild the images.
To stop the Docker services, run:
docker-compose down -v
If you want to remove all images and associated volumes:
docker-compose down --rmi all --volumes
Guide for the instalation of Docker package on Github for the project Loto_API: GITHUB_PACKAGE.md
- ✔️ Addition of advanced analysis on results
- ✔️ Support for new games (Euromillions, Keno, etc.)
- ✔️ Notifications for winning results
To export all dependencies from a Maven project to a text file, use the following command:
mvn dependency:list > dependencies.txt
📜 Licence
Project under MIT License - Free to use and modify.
🎉 Thank you for using Loto API! Good luck 🍀
Developed by @SDINAHET Contributions are welcome! Open an issue or submit a PR 🚀
👥 Authors
![]() Stéphane Dinahet 🚀 Creator & Lead Developer |
- 📌 Description du Projet
- 🏗️ Architecture du Projet
- 🚀 Fonctionnalités Principales
- 🏗️ Installation & Configuration
- 🔗 Endpoints de l'API
- 📡 Déploiement
- 🚀 Roadmap & Améliorations Futures
- 📜 Export des Dépendances du Projet
- 👨💻 Auteur & Contributions
- 📜 Licence
- 👥 Auteurs
Loto API est une application permettant aux utilisateurs de gérer leurs tickets de loterie et de calculer automatiquement leurs gains en comparant leurs numéros avec les résultats officiels. Le projet inclut une API sécurisée avec authentification JWT, un système de gestion des tickets et une base de données hybride SQL/NoSQL.
L'application suit une architecture Full-Stack :
- Frontend : Interface web simple basée sur HTML, CSS et JavaScript.
- Backend : API REST développée avec Spring Boot 3.4.2.
- Base de données :
- SQLite : Stockage des utilisateurs et des tickets.
- MongoDB : Stockage des résultats historiques.
- Automatisation : Un script récupère et met à jour les résultats des tirages à partir des fichiers sources.
- ✔️ Gestion des utilisateurs (Inscription, Connexion, Authentification JWT).
- ✔️ Soumission et gestion des tickets (CRUD des tickets).
- ✔️ Calcul automatique des gains.
- ✔️ Historique des résultats enregistrés en MongoDB.
- ✔️ Visualisation des résultats sous forme de graphiques.
- ✔️ Mise à jour automatique des résultats via un script.
- ✔️ Sécurisation des endpoints API avec Spring Security & JWT.
git clone https://github.com/SDINAHET/Loto_API.git
cd Loto_API
Configurer application.properties
:
spring.datasource.url=jdbc:sqlite:loto.db
spring.datasource.driver-class-name=org.sqlite.JDBC
spring.datasource.username=
spring.datasource.password=
spring.datasource.hikari.maximum-pool-size=5
Démarrer MongoDB et configurer application.properties
:
spring.data.mongodb.uri=mongodb://localhost:27017/loto_results
python3 run.py
mvn install spring-boot:run
L'API est disponible sur http://localhost:8082/swagger-ui/index.html
L'interface web peut être servie via Live Server sur VSCode. Ouvrir index.html
et démarrer Live Server pour accéder à http://127.0.0.1:5500/src/main/resources/static/index.html
.
npm install -g http-server
http-server src/main/resources/static -p 5500
http-server src/main/resources/static -p 5500 -a 0.0.0.0
Available front on: http://127.0.0.1:5500
http-server → Lance un serveur HTTP statique. src/main/resources/static → Définit le dossier contenant les fichiers à servir. -p 5500 → Spécifie que le serveur doit écouter sur le port 5500 comme live server
🔗 Swagger UI : Voir la doc API
Méthode | Endpoint | Description |
---|---|---|
POST | /api/users/register |
Inscription utilisateur |
POST | /api/auth/login3 |
Connexion et génération du JWT |
GET | /api/auth/me |
Récupération des infos utilisateur |
GET | /api/auth/me/firstname |
Récupérer le prénom de l'utilisateur |
POST | /api/auth/logout |
Déconnexion (suppression du JWT) |
GET | /api/users |
Récupération de la liste des utilisateurs (Admin uniquement) |
GET | /api/users/{id} |
Récupération des informations d’un utilisateur |
DELETE | /api/users/{id} |
Suppression d’un utilisateur (Admin uniquement) |
PUT | /api/users/{id} |
Mise à jour des informations utilisateur |
Méthode | Endpoint | Description |
---|---|---|
POST | /api/tickets |
Ajouter un ticket |
GET | /api/tickets |
Lister les tickets de l'utilisateur |
GET | /api/tickets/{id} |
Détails d’un ticket |
DELETE | /api/tickets/{id} |
Supprimer un ticket |
PUT | /api/tickets/{id} |
Modifier un ticket |
Méthode | Endpoint | Description |
---|---|---|
GET | /api/tirages |
Lister tous les tirages |
GET | /api/tirages/dates |
Récupérer les dates des tirages disponibles |
GET | /api/tirages?startDate={}&endDate={} |
Tirages entre deux dates |
Méthode | Endpoint | Description |
---|---|---|
GET | /api/gains/calculate |
Calculer les gains des tickets |
GET | /api/gains |
Récupérer les gains enregistrés |
GET | /api/gains/{ticketId} |
Détails des gains d'un ticket |
Méthode | Endpoint | Description |
---|---|---|
GET | /api/historique/last20 |
Récupérer les 6 derniers résultats de l'historique des résultats officiel |
GET | /api/historique/last20/Detail/tirage/{date} |
Détails d’un tirage par date |
GET | /api/historique/last20/Detail/tirages?startDate={}&endDate={} |
Historique entre deux dates |
Le projet peut être déployé sur Alwaysdata, AWS ou un VPS avec Docker.
Créer un Dockerfile.backend
pour le backend à la racine du projet :
# Utiliser une image Java 21 légère
FROM openjdk:21-jdk-slim
# Définir le répertoire de travail
WORKDIR /app
# Copier les fichiers du backend
COPY . /app
# Permission d'execution
RUN chmod +x mvnw
# Construire l'application
RUN ./mvnw install
# Exécuter l'application
CMD ["./mvnw", "spring-boot:run"]
# Exposer le port de l'API
EXPOSE 8082
Créer un Dockerfile.frontend
pour le frontend à la racine du projet :
# Utiliser une image Node.js légère
FROM node:18-alpine
# Installer http-server globalement
RUN npm install -g http-server
# Définir le répertoire de travail
WORKDIR /app
# Copier les fichiers du frontend
COPY src/main/resources/static /app
# Exposer le port 5500
EXPOSE 5500
# Lancer le serveur HTTP
CMD ["http-server", "-p", "5500"]
Créer un fichier docker-compose.yml
pour orchestrer l'application :
version: "3.8"
services:
backend:
build:
context: .
dockerfile: Dockerfile.backend
ports:
- "8082:8082"
depends_on:
- mongodb
environment:
SPRING_DATA_MONGODB_URI: mongodb://mongodb:27017/loto_database # Suppression de l'authentification
frontend:
build:
context: .
dockerfile: Dockerfile.frontend
ports:
- "5500:5500"
depends_on:
- backend
mongodb:
image: mongo:latest
container_name: mongodb
restart: always
ports:
- "27017:27017"
environment:
MONGO_INITDB_DATABASE: loto_database # Définit la base de données par défaut
volumes:
- mongodb_data:/data/db
# - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro # Vérifie que ce fichier existe bien
volumes:
mongodb_data:
Lancer les conteneurs :
docker-compose up -d --build
http-server src/main/resources/static -p 5500
puis ouvrir votre navigateur à l'adresse http://127.0.0.1:5500/
pour accéder au frontend
et pour le backend (swagger):http://localhost:8082/swagger-ui/index.html
.
📌 Explication : up -d → Démarre les conteneurs en arrière-plan (mode détaché). --build → Force la reconstruction des images Docker.
Quand tu veux arrêter les services docker, exécute :
docker-compose down -v
Si tu veux supprimer toutes les images et volumes associés :
docker-compose down --rmi all --volumes
Guide pour l'installation des package Docker sur Github pour le projet Loto_API: GITHUB_PACKAGE.md
- ✔️ Ajout d’analyses avancées sur les résultats
- ✔️ Support de nouveaux jeux (Euromillions, Keno, etc.)
- ✔️ Notifications push ou email pour les résultats officiel
To export all dependencies from a Maven project to a text file, use the following command:
mvn dependency:list > dependencies.txt
📜 Licence
Projet sous licence MIT - Libre d'utilisation et de modification.
🎉 Merci d'utiliser Loto API ! Bonne chance 🍀
Développé par @SDINAHET Contributions bienvenues ! Ouvrez une issue ou proposez une PR 🚀
👥 Auteurs
![]() Stéphane Dinahet 🚀 Creator & Lead Developer |
flowchart TD
A[User] -->|Interacts| B[Frontend]
B -->|Sends API Request| C[Backend]
C -->|Validates Token| D[Authentication]
D -->|Token Verified| C
C -->|Queries Database| E[Database Layer]
E -->|Stores Users & Tickets| F[SQLite]
E -->|Stores History| G[MongoDB]
F -->|Returns Data| C
G -->|Returns Data| C
C -->|Sends Response| B
B -->|Displays Results| A