Skip to content
Merged

Dev #10

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a52b2f9
Refactor and document services, validations, and repositories for cro…
SebastianLopezO Dec 29, 2024
7d76124
Temporary solution for migrating the use of exceptions, controllers a…
SebastianLopezO Dec 29, 2024
fa856fb
creation of structure for tests
SebastianLopezO Dec 30, 2024
30970a8
Framework for unit testing
SebastianLopezO Dec 30, 2024
cb9d57c
Validations for crop service
SebastianLopezO Jan 1, 2025
4bf1f20
fix for using isValid in crop validation
SebastianLopezO Jan 2, 2025
9270511
Update SCrop.java
SebastianLopezO Jan 2, 2025
dc2b47c
Implementation of mail service using Google's SMTP protocol
SebastianLopezO Jan 2, 2025
0255cb7
Implementation of controller for mail dispatcher service
SebastianLopezO Jan 2, 2025
bab6661
Update JwtService.java
SebastianLopezO Jan 2, 2025
b19759f
Setting up sending emails asynchronously
SebastianLopezO Jan 2, 2025
bf622a5
Configuring Redis as a cache point
SebastianLopezO Jan 3, 2025
e7ab6b3
attempted redis configuration solution and asynchronicity in the same…
SebastianLopezO Jan 3, 2025
a51586a
Documentation of dependencies, under categorization
SebastianLopezO Jan 10, 2025
a8dafa1
Implementation of a cache system in the user management service
SebastianLopezO Jan 11, 2025
aec1cfb
Reformat Code
SebastianLopezO Jan 11, 2025
4ba166e
Refactor .env.example with placeholder variables
SebastianLopezO Jan 11, 2025
f7251fb
Refactoring functions for the mail delivery service
SebastianLopezO Jan 11, 2025
8339c64
Test Separation of exceptions for handling different http status codes
SebastianLopezO Jan 11, 2025
dd668fe
Configuring annotations for caching
SebastianLopezO Jan 12, 2025
bae758a
Refactor: improve enums, update controllers, and add Swagger document…
SebastianLopezO Jan 12, 2025
8410eb8
Refactor: reorganize folder structure for clarity and scalability
SebastianLopezO Jan 12, 2025
2452422
command service refactoring
SebastianLopezO Jan 13, 2025
89360ba
Rate Limiting Config
SebastianLopezO Jan 15, 2025
d6e5895
configuration of routes exempt from rate limiting
SebastianLopezO Jan 15, 2025
04781ae
Merge branch 'main' into dev
SebastianLopezO Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 62 additions & 21 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,28 +1,69 @@
# Configuración APP
APP_NAME=app
PORT=port
TITLE=title
VERSION=version
AUTHOR=author
# Application Configuration
# Basic settings for your application
APP_NAME=<APP_NAME> # Name of your application
PORT=<PORT> # Port the application will listen on
TITLE=<TITLE> # Title of the API
DESCRIPTION=<DESCRIPTION> # Description of the API
VERSION=<VERSION> # Version of your API
AUTHOR=<AUTHOR> # Author(s) of the API

# MongoDB Credentials
DATA_CONNECTION_METHOD=method # Methods (mongodb+srv, mongodb)
DATA_SOURCE_USERNAME=username
DATA_SOURCE_PASSWORD=password
DATA_SOURCE_DOMAIN=domain
DATA_SOURCE_DB=database
DATA_PARAMS=params
# Settings for connecting to MongoDB
DATA_CONNECTION_METHOD=<CONNECTION_METHOD> # Connection method (mongodb+srv or mongodb)
DATA_SOURCE_USERNAME=<USERNAME> # MongoDB username
DATA_SOURCE_PASSWORD=<PASSWORD> # MongoDB password
DATA_SOURCE_DOMAIN=<DOMAIN> # MongoDB server domain
DATA_SOURCE_DB=<DATABASE> # Database name
DATA_PARAMS=<CONNECTION_PARAMS> # Additional connection parameters

# Redis Credentials
# Settings for connecting to Redis (used for caching)
CACHE_TYPE=<CACHE_TYPE> # Cache type (redis)
CACHE_HOST=<REDIS_HOST> # Redis host
CACHE_PORT=<REDIS_PORT> # Redis port
CACHE_DB=<REDIS_DB> # Redis database ID (usually 0)
CACHE_USERNAME=<REDIS_USERNAME> # Redis username
CACHE_PASSWORD=<REDIS_PASSWORD> # Redis password
CACHE_TIMEOUT=<CACHE_TIMEOUT> # Timeout for cache operations (in ms)
CACHE_LETTUCE_POOL_MAX_ACTIVE=<MAX_ACTIVE> # Max active connections in Redis pool
CACHE_LETTUCE_POOL_MAX_WAIT=<MAX_WAIT> # Max wait time for Redis connections (in ms)
CACHE_LETTUCE_POOL_MAX_IDLE=<MAX_IDLE> # Max idle connections in Redis pool
CACHE_LETTUCE_POOL_MIN_IDLE=<MIN_IDLE> # Min idle connections in Redis pool

# Cache Configuration
# Settings for cache behavior
CACHE_TIME_TO_LIVE=<CACHE_TTL> # Time to live for cache items (in ms)
CACHE_NULL_VALUES=<BOOLEAN> # Whether to store null values in cache (true/false)

# Email Credentials
# Settings for sending emails via SMTP
MAIL_HOST=<SMTP_HOST> # SMTP server (e.g., Gmail)
MAIL_PORT=<SMTP_PORT> # SMTP port (587 for TLS)
MAIL_USERNAME=<SMTP_USERNAME> # SMTP login username
MAIL_PASSWORD=<SMTP_PASSWORD> # SMTP login password
MAIL_PROPERTIES_SMTP_AUTH=<TRUE/FALSE> # Enable SMTP authentication (true/false)
MAIL_PROPERTIES_SMTP_STARTTLS_ENABLE=<TRUE/FALSE> # Enable STARTTLS for secure connection

# JWT Credentials
SECURITY_JWT_SECRET_KEY=secret-key
SECURITY_JWT_EXPIRATION=jwt-expiration
SECURITY_PUBLIC_ROUTES=/**
# Settings for JWT (JSON Web Token) authentication
SECURITY_JWT_SECRET_KEY=<JWT_SECRET_KEY> # Secret key for signing JWT tokens
SECURITY_JWT_EXPIRATION=<JWT_EXPIRATION> # JWT expiration time (in ms)
SECURITY_PUBLIC_ROUTES=<PUBLIC_ROUTES> # Public routes that do not require authentication (e.g., /auth/login)

# Rate Limiting Config
# Settings for API rate limiting
RATE_LIMITING_MAX_REQUESTS=<MAX_REQUESTS> # Max requests per client IP within the defined time window
RATE_LIMITING_TIME_WINDOW=<TIME_WINDOW> # Time window in milliseconds (1 minute)
RATE_LIMITING_PUBLIC_ROUTES=<PUBLIC_ROUTES> # Public routes excluded from rate limiting

# Https Headers
HEADER_CORS_ALLOWED_ORIGINS=*
# HTTPS Headers (CORS)
# Settings for Cross-Origin Resource Sharing (CORS)
HEADER_CORS_ALLOWED_ORIGINS=<ALLOWED_ORIGINS> # Allowed origins for CORS (e.g., http://localhost:3000)

# Config TOMCAT
SERVER_TOMCAT_TIMEOUT=ms
# Tomcat Configuration
# Settings for your Tomcat server
SERVER_TOMCAT_TIMEOUT=<TOMCAT_TIMEOUT> # Timeout for Tomcat server (in ms)

# Logs (INFO, DEBUG, OFF)
DEBUGGER_MODE=mode
# Log Level Configuration
# Define the logging level (e.g., INFO, DEBUG, OFF)
DEBUGGER_MODE=<DEBUG_MODE> # Log level: INFO, DEBUG, or OFF
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## Deployment

[![Deployment](https://github.com/SmartPotTech/SmartPot-API/actions/workflows/deployment.yml/badge.svg)](https://github.com/SmartPotTech/SmartPot-API/actions/workflows/deployment.yml)
[![General CI Pipeline](https://github.com/SmartPotTech/SmartPot-API/actions/workflows/ci-pipeline.yml/badge.svg)](https://github.com/SmartPotTech/SmartPot-API/actions/workflows/ci-pipeline.yml)

[![Checkout Code](https://github.com/SmartPotTech/SmartPot-API/actions/workflows/checkout.yml/badge.svg)](https://github.com/SmartPotTech/SmartPot-API/actions/workflows/checkout.yml)

### 1. Compilación de la Aplicación

Expand Down
175 changes: 129 additions & 46 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,132 +2,189 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- Model version for Maven POM -->
<modelVersion>4.0.0</modelVersion>

<!-- Parent project information -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.1</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<!-- Basic project information -->
<groupId>smarpot.com</groupId>
<artifactId>api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SmartPot-API</name>
<description>SmartPot-API</description>
<url />

<!-- Licenses for the project -->
<licenses>
<license />
</licenses>

<!-- Developers involved in the project -->
<developers>
<developer />
</developers>

<!-- Source control management (SCM) configuration -->
<scm>
<connection />
<developerConnection />
<tag />
<url />
</scm>

<!-- Global properties -->
<properties>
<!-- Java version used for the project -->
<java.version>17</java.version>
</properties>

<!-- Project dependencies -->
<dependencies>

<!-- ===================== Spring Boot Dependencies ===================== -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<artifactId>spring-boot-starter-actuator</artifactId> <!-- For monitoring and health checks -->
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<artifactId>spring-boot-starter-web</artifactId> <!-- For building RESTful web services -->
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
<artifactId>spring-boot-starter-validation</artifactId> <!-- For validation support using annotations -->
</dependency>

<!-- ===================== Data & Persistence Dependencies ===================== -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<artifactId>spring-boot-starter-data-mongodb</artifactId> <!-- MongoDB integration -->
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.8.3</version>
<artifactId>spring-boot-starter-data-redis</artifactId> <!-- Redis integration -->
<version>3.4.1</version>
</dependency>

<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId> <!-- Redis client library -->
<version>5.2.0</version>
</dependency>

<!-- ===================== Security Dependencies ===================== -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<artifactId>spring-boot-starter-security</artifactId> <!-- Spring Security for authentication and authorization -->
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
<artifactId>spring-security-test</artifactId> <!-- Testing utilities for Spring Security -->
<scope>test</scope> <!-- Available only in test scope -->
</dependency>

<!-- JWT -->
<!-- ===================== JWT (JSON Web Token) Dependencies ===================== -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.12.6</version>
<version>0.12.6</version> <!-- JWT core library -->
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.12.6</version>
<version>0.12.6</version> <!-- JWT implementation -->
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.12.6</version>
<version>0.12.6</version> <!-- JWT support for Jackson (JSON parsing) -->
</dependency>

<!-- ===================== Testing Dependencies ===================== -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <!-- Testing utilities for Spring Boot -->
<scope>test</scope> <!-- Available only in test scope -->
</dependency>

<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId> <!-- REST Docs for generating API documentation -->
<scope>test</scope> <!-- Available only in test scope -->
</dependency>

<!-- ===================== Development & Tools Dependencies ===================== -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId> <!-- Developer tools for faster development (restarts, etc.) -->
<scope>runtime</scope> <!-- Available only during runtime -->
<optional>true</optional> <!-- Optional dependency -->
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <!-- Lombok for reducing boilerplate code (getters/setters, constructors, etc.) -->
<scope>compile</scope> <!-- Available at compile time -->
</dependency>

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.8.3</version> <!-- OpenAPI support for automatic API documentation -->
</dependency>

<dependency>
<groupId>io.github.cdimascio</groupId>
<artifactId>dotenv-java</artifactId>
<version>3.1.0</version>
<version>3.1.0</version> <!-- Load environment variables from a .env file -->
</dependency>

<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.6.3</version>
<version>1.6.3</version> <!-- MapStruct for object mapping -->
</dependency>

<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.6.3</version>
<version>1.6.3</version> <!-- MapStruct annotation processor -->
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
<artifactId>spring-boot-starter-cache</artifactId> <!-- Spring Boot caching support -->
</dependency>

<!-- ===================== Mail Dependencies ===================== -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<artifactId>spring-boot-starter-mail</artifactId> <!-- Spring Boot mail support -->
</dependency>

<!-- ===================== Miscellaneous Dependencies ===================== -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId> <!-- Apache Commons Pool for Redis connection management -->
<version>2.11.1</version>
</dependency>

</dependencies>

<!-- Build configuration -->
<build>
<plugins>
<plugin>
Expand All @@ -136,21 +193,47 @@
</plugin>
</plugins>
</build>

<!-- Profiles for different configurations -->
<profiles>
<!-- Profiles for Docker -->
<profile>
<id>docker</id>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>.env</exclude>
</excludes>
</resource>
</resources>
<plugins>
<!-- Maven Resources Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/docker/resources</outputDirectory>
<resources>
<resource>
<!-- Including all resources in the project -->
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<!-- Exclude the .env file from being included in the resources -->
<resource>
<directory>${basedir}</directory> <!-- The base directory (root of the project) -->
<excludes>
<exclude>.env</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>


</project>
Loading
Loading