Skip to content

Update README and modify port configuration in the env files for both profiles. #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@ Identity API is a microservice which is used for the creation and management of
## Environment and setup
For setting up the development environment, please refer to the [Developer Guide](https://piramal-swasthya.gitbook.io/amrit/developer-guide/development-environment-setup) .

# Running Instructions

This service consists of two profiles that work together: the main application profile and the 1097_identity profile. Each profile operates on a different port for independent functionality.

## Building and Running

### 1. Main Application (Port: 8094)
```bash
# Build and Run
mvn clean install -DENV_VAR=local
mvn spring-boot:run -DENV_VAR=local
```

### 2. 1097_identity Profile (Port: 8095)
```bash
# Build and Run (in a new terminal)
mvn clean install -P1097_identity -DENV_VAR=local
mvn spring-boot:run -P1097_identity -DENV_VAR=local
```

**Note:** Start the main application before running the 1097_identity profile. Each profile requires the `-DENV_VAR=local` parameter for local development.

## API Guide
Detailed information on API endpoints can be found in the [API Guide](https://piramal-swasthya.gitbook.io/amrit/architecture/api-guide).

Expand Down
8 changes: 4 additions & 4 deletions src/main/environment/1097_example.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

server.port=8095
# DataSource settings: set here your own configurations for the database

spring.datasource.url=<Enter AMRIT DB_1097_IDENTITY URL here>
spring.datasource.username=<Enter your AMRIT DB_1097_IDENTITY username>
spring.datasource.password=<Enter your AMRIT DB_1097_IDENTITY password>
spring.datasource.url=jdbc:mysql://localhost:3306/db_identity
spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
Comment on lines +4 to +6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

⚠️ Potential issue

Replace hardcoded credentials with placeholders in example file.

Since this is an example properties file, it should use placeholders instead of hardcoded credentials. This helps prevent accidental commits of real credentials and provides better guidance for users.

Apply this diff:

-spring.datasource.url=jdbc:mysql://localhost:3306/db_identity
-spring.datasource.username=root
-spring.datasource.password=1234
+spring.datasource.url=jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:db_identity}?useSSL=true
+spring.datasource.username=${DB_USERNAME}
+spring.datasource.password=${DB_PASSWORD}

Additional recommendations:

  1. Enable SSL for secure database connections
  2. Consider using the latest MySQL connector (com.mysql.cj.jdbc.Driver)
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
spring.datasource.url=jdbc:mysql://localhost:3306/db_identity
spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.url=jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:db_identity}?useSSL=true
spring.datasource.username=${DB_USERNAME}
spring.datasource.password=${DB_PASSWORD}

2 changes: 1 addition & 1 deletion src/main/environment/common_example.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
server.port=8094
# DataSource settings: set here your own configurations for the database
spring.datasource.url=jdbc:mysql://localhost:3306/db_identity
spring.datasource.url=jdbc:mysql://localhost:3306/db_iemr
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ Codebase verification

Database name inconsistency detected - likely an error

The change to db_iemr in common_example.properties appears incorrect as:

  • All other configuration files reference variations of db_identity
  • The IdentityService.java explicitly uses db_identity schema in SQL queries
  • No database migration scripts are present

Please revert the database name change in common_example.properties to maintain consistency with the rest of the codebase.

πŸ”— Analysis chain

Verify database migration requirements.

The database URL has been changed from db_identity to db_iemr. Please ensure:

  1. Database schema compatibility
  2. Data migration requirements
  3. Consistent database naming across all profiles
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check database configuration consistency across files
# and look for any migration scripts or documentation

# Check for database names in configuration files
echo "Checking database configurations..."
rg -l "db_identity|db_iemr" --type properties

# Look for migration scripts
echo -e "\nChecking for migration scripts..."
fd -e sql -e java -e xml --full-path "migration|flyway|liquibase"

Length of output: 314


Script:

#!/bin/bash
# Search for database configurations and related files more thoroughly

echo "Checking all property and YAML files for database configurations..."
find . -type f \( -name "*.properties" -o -name "*.yml" \) -exec grep -l "datasource\|jdbc:\|db_identity\|db_iemr" {} \;

echo -e "\nChecking for SQL and database-related files..."
find . -type f \( -name "*.sql" -o -name "*database*" -o -name "*schema*" \) 2>/dev/null

echo -e "\nChecking for database configuration in Java files..."
find . -type f -name "*.java" -exec grep -l "DataSource\|JdbcTemplate\|EntityManagerFactory" {} \;

Length of output: 1249


Script:

#!/bin/bash
echo "Examining database URLs in all property files..."
for file in ./src/main/environment/*.properties ./src/main/resources/application.properties; do
    echo -e "\n=== $file ==="
    grep -i "datasource.url\|jdbc:" "$file" || true
done

echo -e "\nChecking IdentityService.java for database references..."
grep -A 5 -B 5 "DataSource\|JdbcTemplate\|EntityManagerFactory" ./src/main/java/com/iemr/common/identity/service/IdentityService.java

Length of output: 5681

spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
5 changes: 0 additions & 5 deletions src/main/environment/common_local.properties

This file was deleted.

Loading