{"id":22515421,"url":"https://github.com/brunoliratm/Ludus-GameStore-API","last_synced_at":"2025-08-03T17:32:07.312Z","repository":{"id":230792713,"uuid":"779085037","full_name":"brunoliratm/Ludus-GameStore","owner":"brunoliratm","description":"Ludus is not just a game store, it's a gateway to endless adventures and thrilling experiences. Whether you're a casual gamer or a hardcore enthusiast, Ludus has something for everyone.","archived":false,"fork":false,"pushed_at":"2024-10-11T18:50:02.000Z","size":18812,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-30T17:55:21.821Z","etag":null,"topics":["jdbc","servlet","spring","thymeleaf"],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brunoliratm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-29T02:19:29.000Z","updated_at":"2024-10-30T15:48:24.000Z","dependencies_parsed_at":"2024-04-15T01:40:27.088Z","dependency_job_id":"25094d26-7536-4ba4-b307-e9e729caf68a","html_url":"https://github.com/brunoliratm/Ludus-GameStore","commit_stats":null,"previous_names":["brunoliratm/ludus-gamestore"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunoliratm%2FLudus-GameStore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunoliratm%2FLudus-GameStore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunoliratm%2FLudus-GameStore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunoliratm%2FLudus-GameStore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brunoliratm","download_url":"https://codeload.github.com/brunoliratm/Ludus-GameStore/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228556843,"owners_count":17936433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jdbc","servlet","spring","thymeleaf"],"created_at":"2024-12-07T03:32:11.596Z","updated_at":"2025-08-03T17:32:07.296Z","avatar_url":"https://github.com/brunoliratm.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\r\n  \u003cimg src=\"images/ludus.svg\" width=\"400\" height=\"200\" alt=\"Ludus Logo\"\u003e\r\n  \u003ch1 align=\"center\"\u003eLudus Game Store API\u003c/h1\u003e\r\n  \r\n  [![Spring Boot](https://img.shields.io/badge/Spring%20Boot-3.4.3-brightgreen.svg)](https://spring.io/projects/spring-boot)\r\n  [![Java](https://img.shields.io/badge/Java-21-orange.svg)](https://www.oracle.com/java/)\r\n  [![JUnit5](https://img.shields.io/badge/JUnit-5.9.3-25A162.svg)](https://junit.org/junit5/)\r\n  [![Mockito](https://img.shields.io/badge/Mockito-5.2.0-66B366.svg)](https://site.mockito.org/)\r\n  [![Docker](https://img.shields.io/badge/Docker-enabled-2496ED.svg)](https://www.docker.com/)\r\n  [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\r\n  [![Swagger UI](https://img.shields.io/badge/Swagger-UI-85EA2D.svg)](http://localhost:8080/swagger-ui.html)\r\n  \r\n  \u003ch3\u003eA comprehensive RESTful API for managing a modern gaming store platform with secure user authentication, robust game catalog, and seamless purchase processing.\u003c/h3\u003e\r\n\u003c/div\u003e\r\n\r\n## 📋 Table of Contents\r\n\r\n- [📌 Overview](#-overview)\r\n- [✨ Key Features](#-key-features)\r\n- [🛠️ Tech Stack](#️-tech-stack)\r\n- [🚀 Getting Started](#-getting-started)\r\n- [📊 API Endpoints](#-api-endpoints)\r\n- [🔐 Security Implementation](#-security-implementation)\r\n- [📝 Data Models](#-data-models)\r\n- [🧪 Testing Strategy](#-testing-strategy)\r\n- [🐳 Docker Support](#-docker-support)\r\n- [👥 Credits](#-credits)\r\n- [🤝 Contributing](#-contributing)\r\n- [📜 License](#-license)\r\n\r\n## 📌 Overview\r\n\r\nLudus Game Store API is a robust Spring Boot application that provides a complete backend solution for online game stores. The API enables developers to manage game catalogs, handle user authentication and authorization, process purchases with various payment methods, and implement filtering capabilities for an enhanced user experience.\r\n\r\n## ✨ Key Features\r\n\r\n- **Game Management**\r\n  - Create, read, update, and delete games\r\n  - Filter games by genre, platform, release year, and name\r\n  - Comprehensive validation of game attributes\r\n  \r\n- **User Authentication \u0026 Authorization**\r\n  - JWT-based authentication\r\n  - Role-based access control\r\n  - Secure password handling\r\n  \r\n- **Purchase Processing**\r\n  - Multiple payment methods (Credit Card, Debit Card, PIX, PayPal, Boleto)\r\n  - Purchase history tracking\r\n  - User-specific purchase reports\r\n  \r\n- **Robust Error Handling**\r\n  - Customized exception messages\r\n  - Internationalization support\r\n  - Validation error reporting\r\n  \r\n- **Pagination \u0026 Sorting**\r\n  - Efficient data retrieval with pagination\r\n  - Dynamic response format with metadata\r\n\r\n## 🛠️ Tech Stack\r\n\r\n- **Backend Framework**: Spring Boot\r\n- **Security**: Spring Security with JWT\r\n- **Database Access**: Spring Data JPA\r\n- **API Documentation**: Swagger/OpenAPI\r\n- **Validation**: Jakarta Bean Validation\r\n- **Data Modeling**: Lombok\r\n- **Testing**: JUnit 5, Mockito\r\n- **Containerization**: Docker\r\n- **Dependency Management**: Maven\r\n\r\n## 🚀 Getting Started\r\n\r\n### Prerequisites\r\n\r\n- Java 21 or higher\r\n- Maven 3.6+ \r\n- Your preferred IDE (IntelliJ IDEA, Eclipse, VS Code)\r\n- PostgreSQL Server or compatible database\r\n- Docker (optional, for containerized deployment)\r\n\r\n### Installation\r\n\r\n1. Clone the repository:\r\n```bash\r\ngit clone https://github.com/brunoliratm/Ludus-GameStore-Api.git\r\ncd Ludus-GameStore-Api\r\n```\r\n\r\n2. Configure your database settings in `application.properties`\r\n```properties\r\nspring.datasource.url=jdbc:postgresql://localhost:5432/ludus_db\r\nspring.datasource.username=your_username\r\nspring.datasource.password=your_password\r\nspring.datasource.driver-class-name=org.postgresql.Driver\r\n```\r\n\r\n3. Build the project:\r\n```bash\r\nmvn clean install\r\n```\r\n\r\n4. Run the application:\r\n```bash\r\nmvn spring-boot:run\r\n```\r\n\r\n5. Access the API at `http://localhost:8080/`\r\n6. Explore API documentation at `http://localhost:8080/swagger-ui.html`\r\n\r\n### Docker Deployment\r\n\r\n1. Build the Docker image:\r\n```bash\r\ndocker build -t ludus-gamestore-api .\r\n```\r\n\r\n2. Run the container with basic configuration:\r\n```bash\r\ndocker run -p 8080:8080 -e SPRING_PROFILES_ACTIVE=prod ludus-gamestore-api\r\n```\r\n\r\n3. Access the API at `http://localhost:8080/` and Swagger documentation at `http://localhost:8080/swagger-ui.html`\r\n\r\n## 📊 API Endpoints\r\n\r\n### Games API\r\n\r\n| Method | Endpoint | Description | Authentication Required |\r\n|--------|----------|-------------|------------------------|\r\n| GET | `/api/v1/games` | List all games with optional filtering by genre and name | No |\r\n| GET | `/api/v1/games/{id}` | Get game details by ID | No |\r\n| POST | `/api/v1/games` | Create a new game | Yes (ADMIN) |\r\n| PUT | `/api/v1/games/{id}` | Update an existing game | Yes (ADMIN) |\r\n| DELETE | `/api/v1/games/{id}` | Delete a game | Yes (ADMIN) |\r\n\r\n### Users API\r\n\r\n| Method | Endpoint | Description | Authentication Required |\r\n|--------|----------|-------------|------------------------|\r\n| GET | `/api/v1/users` | List all users with optional name filtering | Yes (ADMIN) |\r\n| GET | `/api/v1/users/{id}` | Get user profile by ID | Yes (ADMIN) |\r\n| POST | `/api/v1/users` | Create a new user | Yes (ADMIN) |\r\n| PUT | `/api/v1/users/{id}` | Update user information | Yes (ADMIN) |\r\n| DELETE | `/api/v1/users/{id}` | Delete user account (soft delete) | Yes (ADMIN) |\r\n\r\n### Authentication API\r\n\r\n| Method | Endpoint | Description | Authentication Required |\r\n|--------|----------|-------------|------------------------|\r\n| POST | `/api/v1/auth/login` | Authenticate user and get JWT token | No |\r\n| POST | `/api/v1/auth/register` | Register a new user and generate JWT token | No |\r\n\r\n### Purchases API\r\n\r\n| Method | Endpoint | Description | Authentication Required |\r\n|--------|----------|-------------|------------------------|\r\n| GET | `/api/v1/purchases` | List all purchases with optional filtering | Yes (ADMIN) |\r\n| GET | `/api/v1/purchases/{id}` | Get purchase details by ID | Yes (ADMIN) |\r\n| POST | `/api/v1/purchases` | Create a new purchase | Yes (ADMIN) |\r\n| GET | `/api/v1/purchases/user/{userId}` | Get purchases by user ID | Yes (ADMIN) |\r\n\r\n## 🔐 Security Implementation\r\n\r\nThe API uses JWT (JSON Web Token) for authentication. The `TokenService` generates and validates tokens, while Spring Security handles authorization based on user roles. To access protected endpoints, include a valid JWT token in the Authorization header:\r\n\r\n```\r\nAuthorization: Bearer \u003cyour_jwt_token\u003e\r\n```\r\n\r\n## 📝 Data Models\r\n\r\n```mermaid\r\nclassDiagram\r\n    class GameModel {\r\n        +Long id\r\n        +String name\r\n        +GameGenre genre\r\n        +int releaseYear\r\n        +GamePlatform platform\r\n        +BigDecimal price\r\n    }\r\n    \r\n    class UserModel {\r\n        +Long id\r\n        +boolean active\r\n        +String email\r\n        +String name\r\n        +String password\r\n        +UserRole role\r\n        +Collection~GrantedAuthority~ getAuthorities()\r\n        +String getPassword()\r\n        +String getUsername()\r\n        +boolean isAccountNonExpired()\r\n        +boolean isAccountNonLocked()\r\n        +boolean isCredentialsNonExpired()\r\n        +boolean isEnabled()\r\n    }\r\n    \r\n    class PurchaseModel {\r\n        +Long id\r\n        +LocalDate purchaseDate\r\n        +BigDecimal price\r\n        +PaymentMethod paymentMethod\r\n        +GameModel game\r\n        +UserModel user\r\n    }\r\n    \r\n    class GameGenre {\r\n        \u003c\u003cenumeration\u003e\u003e\r\n        ACTION\r\n        ADVENTURE\r\n        FIGHTING\r\n        HORROR\r\n        MMORPG\r\n        RACING\r\n        RPG\r\n        SHOOTER\r\n        SIMULATION\r\n        SPORTS\r\n        STRATEGY\r\n        SURVIVAL\r\n        OTHER\r\n    }\r\n    \r\n    class GamePlatform {\r\n        \u003c\u003cenumeration\u003e\u003e\r\n        PC\r\n        PLAYSTATION\r\n        XBOX\r\n        NINTENDO\r\n        MOBILE\r\n        OTHER\r\n    }\r\n    \r\n    class PaymentMethod {\r\n        \u003c\u003cenumeration\u003e\u003e\r\n        CREDIT_CARD\r\n        DEBIT_CARD\r\n        PIX\r\n        PAYPAL\r\n        BOLETO\r\n        OTHER\r\n    }\r\n    \r\n    class UserRole {\r\n        \u003c\u003cenumeration\u003e\u003e\r\n        USER\r\n        ADMIN\r\n    }\r\n    \r\n    PurchaseModel \"many\" --\u003e \"1\" GameModel : has\r\n    PurchaseModel \"many\" --\u003e \"1\" UserModel : made by\r\n    GameModel -- GameGenre : has\r\n    GameModel -- GamePlatform : runs on\r\n    PurchaseModel -- PaymentMethod : uses\r\n    UserModel -- UserRole : has\r\n```\r\n\r\n## 🧪 Testing Strategy\r\n\r\nThe project uses a comprehensive testing approach to ensure code quality and reliability:\r\n\r\n- **Unit Testing**: JUnit 5 for testing individual components in isolation\r\n- **Mocking**: Mockito for creating mock objects to simulate dependencies\r\n- **Test Coverage**: Extensive test coverage across all services and controllers\r\n- **Integration Tests**: Testing the interaction between different components\r\n\r\nKey test classes:\r\n- `GameServiceTest`: Tests for game operations including validation and filtering\r\n- `UserServiceTest`: Tests for user management operations\r\n- `PurchaseServiceTest`: Tests for purchase process and order management\r\n- `AuthServiceTest`: Tests for authentication and token generation/validation\r\n\r\nTo run the tests:\r\n```bash\r\nmvn test\r\n```\r\n\r\n## 🐳 Docker Support\r\n\r\nThe application includes Docker support for easy deployment in any environment. The Dockerfile sets up the appropriate Java runtime environment and configures the application for production use.\r\n\r\n### Dockerfile Features\r\n- Multi-stage build for optimized image size\r\n- Maven build in the first stage with Eclipse Temurin 21\r\n- Slim JRE-based runtime image in the second stage\r\n- Proper layer caching for faster builds\r\n- Exposes port 8080 for the application\r\n- Health check to verify application is running properly\r\n\r\n### Environment Variables\r\nThe application supports configuration through environment variables, which can be passed when running the Docker container. Spring Boot will automatically map these environment variables to application properties.\r\n\r\nCommon environment variables you can configure:\r\n\r\n- `SPRING_DATASOURCE_URL`: Database URL\r\n- `SPRING_DATASOURCE_USERNAME`: Database username\r\n- `SPRING_DATASOURCE_PASSWORD`: Database password\r\n- `JWT_SECRET`: Secret key used for JWT token signing\r\n- `API_BASEURL`: Base URL for the API (defaults to http://localhost:8080/api/v1)\r\n- `ADMIN_DEFAULT_EMAIL`: Email for the default admin user (default: adminlgs@email.com)\r\n- `ADMIN_DEFAULT_PASSWORD`: Password for the default admin user (default: puzzle001@)\r\n- `SPRING_PROFILES_ACTIVE`: Set to your desired Spring profile (default, dev, prod)\r\n- `SERVER_PORT`: The port on which the application runs (default: 8080)\r\n\r\nWhen running in a Docker container, use `host.docker.internal` to connect to a database running on your host machine, for example:\r\n\r\n```bash\r\n --add-host=host.docker.internal:host-gateway \\\r\n  -e SPRING_DATASOURCE_URL=jdbc:postgresql://host.docker.internal:5432/ludus \\\r\n```\r\n\r\nExample of running with custom environment variables:\r\n\r\n```bash\r\ndocker run -p 8080:8080 \\\r\n  -e SPRING_DATASOURCE_URL=jdbc:postgresql://127.0.0.1:5432/ludus \\\r\n  -e SPRING_DATASOURCE_USERNAME=postgres \\\r\n  -e SPRING_DATASOURCE_PASSWORD=password \\\r\n  -e JWT_SECRET=your_secure_jwt_secret \\\r\n  -e ADMIN_DEFAULT_EMAIL=admin@ludus.com \\\r\n  -e ADMIN_DEFAULT_PASSWORD=secure_admin_password \\\r\n  -e SPRING_PROFILES_ACTIVE=prod \\\r\n  -e API_BASEURL=http://localhost:8080/api/v1 \\\r\n  ludus-gamestore-api\r\n```\r\n\r\n## 👥 Credits\r\n\r\n| \u003ca href=\"https://github.com/brunoliratm\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/114788642?v=4\" float=\"left\" width=\"40px\" height=40px\u003e\u003cp\u003eBrunoMagno\u003c/p\u003e\u003c/a\u003e | \u003ca href=\"https://github.com/Paulo-Araujo-Jr\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/127964717?v=4\" float=\"left\" width=\"40px\" height=\"40px\"\u003e\u003cp\u003ePauloAraujo\u003c/p\u003e\u003c/a\u003e |\r\n| --- | --- |\r\n\r\n## 🤝 Contributing\r\n\r\nWe welcome contributions from the community! To contribute:\r\n\r\n1. Fork the repository\r\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\r\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\r\n4. Push to the branch (`git push origin feature/amazing-feature`)\r\n5. Open a Pull Request\r\n\r\nPlease make sure your code follows the project's coding standards and includes appropriate tests.\r\n\r\n## 📜 License\r\n\r\nThis project is licensed under the MIT License.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunoliratm%2FLudus-GameStore-API","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrunoliratm%2FLudus-GameStore-API","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunoliratm%2FLudus-GameStore-API/lists"}