Skip to content
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
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Database settings
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_DB=Splitora
MYSQL_DB=Splitora

SPRING_LIQUIBASE_CONTEXTS=dev
5 changes: 4 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ jobs:

- name: Build Docker Image
run: |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/splitora-app:1.0 .
docker build \
--build-arg SPRING_LIQUIBASE_CONTEXTS=prod \
--build-arg SPRING_LIQUIBASE_CHANGELOG=classpath:db/changelog/db.changelog-master-prod.yaml
-t ${{ secrets.DOCKER_HUB_USERNAME }}/splitora-app:1.0 .

- name: Push Docker Image to Docker Hub
run: |
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ WORKDIR /app
# Copy the jar file into the container at /app
COPY target/*.jar app.jar

ARG SPRING_LIQUIBASE_CONTEXTS
ENV SPRING_LIQUIBASE_CONTEXTS=${SPRING_LIQUIBASE_CONTEXTS}

# Expose the port the app runs in
EXPOSE 8081

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/${MYSQL_DB} # access the mysql container at the port 3306
SPRING_DATASOURCE_USERNAME: ${MYSQL_USER}
SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD}
SPRING_LIQUIBASE_CONTEXTS: dev
networks:
- splitora-db-network

Expand Down
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.5.0</version>
</dependency>

<!-- liquibase dependency-->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.31.0</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ApiExceptionHandler {
@ExceptionHandler(BadRequestException.class)
public ResponseEntity<ErrorResponseModel> handleBadRequestException(RuntimeException ex) {
log.info("Runtime exception occurred: ", ex);
ErrorResponseModel errorResponse = ResponseUtil.error("Bad Request", HttpStatus.BAD_REQUEST, new ErrorDetails(
ErrorResponseModel errorResponse = ResponseUtil.error(ex.getMessage(), HttpStatus.BAD_REQUEST, new ErrorDetails(
ErrorCode.INVALID_REQUEST.getCode(),
ErrorCode.INVALID_REQUEST.getMessage()
));
Expand All @@ -39,7 +39,7 @@ public ResponseEntity<ErrorResponseModel> handleRefreshTokenInvalidException(Ref
@ExceptionHandler(DataNotFoundException.class)
public ResponseEntity<ErrorResponseModel> handleDataNotFoundException(DataNotFoundException ex) {
log.info("DataNotFoundException occurred: ", ex);
ErrorResponseModel errorResponse = ResponseUtil.error("Data Not Found", HttpStatus.NOT_FOUND, new ErrorDetails(
ErrorResponseModel errorResponse = ResponseUtil.error(ex.getMessage(), HttpStatus.NOT_FOUND, new ErrorDetails(
ErrorCode.ENTITY_NOT_FOUND.getCode(),
ErrorCode.ENTITY_NOT_FOUND.getMessage()
));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.satwik.splitora.persistence.dto.expense;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.satwik.splitora.persistence.dto.user.OwerDTO;
import jakarta.validation.constraints.NotNull;
import lombok.*;
Expand All @@ -24,6 +25,7 @@ public class ExpenseDTO {
@NotNull
private String description;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
private LocalDateTime date;

private List<OwerDTO> owers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class User extends BaseEntity {
private String password;

@Enumerated(EnumType.STRING)
@Column(name = "registrationMethod")
@Column(name = "registration_method")
private RegistrationMethod registrationMethod;

@Enumerated(EnumType.STRING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
public interface UserRepository extends JpaRepository<User, UUID> {

Optional<User> findByEmail(String email);

boolean existsByEmail(String email);
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public List<UserDTO> findMembers(UUID groupId) {
List<UserDTO> userDTOS = new ArrayList<>();
for (GroupMembers groupMembers : groupMembersList) {
UserDTO userDTO = new UserDTO();
userDTO.setUserId(groupMembers.getMember().getId());
userDTO.setEmail(groupMembers.getMember().getEmail());
userDTO.setUsername(groupMembers.getMember().getUsername());
userDTO.setPhone(new PhoneDTO(groupMembers.getMember().getCountryCode(), groupMembers.getMember().getPhoneNumber()));
Expand Down
36 changes: 0 additions & 36 deletions src/main/resources/application.properties

This file was deleted.

67 changes: 67 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Connection of spring application with database
spring:
datasource:
url: jdbc:mysql://localhost:3306/Splitora
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver

jpa:
hibernate:
ddl-auto: none
naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy

liquibase:
enabled: true
change-log: classpath:db/changelog/db.changelog-master-dev.yaml
contexts: ${SPRING_LIQUIBASE_CONTEXTS:dev}
# show-sql: true # Uncomment to enable SQL logging

security:
oauth2:
client:
registration:
google:
client-id: abc123
client-secret: good123
scope:
- openid
- email
- profile
redirect-uri: http://localhost:3000/callback
provider:
google:
authorization-uri: https://accounts.google.com/o/oauth2/auth
token-uri: https://oauth2.googleapis.com/token
user-info-uri: https://www.googleapis.com/oauth2/v3/userinfo
user-name-attribute: name

server:
port: 8081

# JWT security
jwt:
access:
secretKey: SuP9ErKeY
expirationTimeInMinutes: 150
refresh:
secretKey: wUP89ErKie
expirationTimeInMinutes: 2000

# File path for the report
my:
reportFilePath: /home/ongraph/Downloads/

app:
initial-users:
super-admin:
username: ${SUPERADMIN_USERNAME}
password: ${SUPERADMIN_PASSWORD}
email: ${SUPERADMIN_EMAIL}
regular-users:
- username: ${USER1_USERNAME}
password: ${USER1_PASSWORD}
email: ${USER1_EMAIL}
- username: ${USER2_USERNAME}
password: ${USER2_PASSWORD}
email: ${USER2_EMAIL}
25 changes: 25 additions & 0 deletions src/main/resources/db/changelog/data/seed-groups.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
databaseChangeLog:
- changeSet:
id: 2025-05-31-load-groups
author: splitora
context: dev
changes:
- sql:
splitStatements: false
stripComments: true
sql: |
INSERT IGNORE INTO group_table (
id, created_by, created_on, modified_by, modified_on, default_group, group_name, user_id
) VALUES
(
UNHEX('a1b2c3d4e5f60123456789abcdef0001'), NULL, '2025-05-26 13:24:27.589321', NULL, '2025-05-26 13:24:27.589321',
1, 'Non Grouped Expenses', UNHEX('3719917506b14643afc7b8815fdc81cf')
),
(
UNHEX('a1b2c3d4e5f60123456789abcdef0002'), NULL, '2025-05-26 13:24:27.596714', NULL, '2025-05-26 13:24:27.596714',
1, 'Non Grouped Expenses', UNHEX('5790c07ad90e4df6a062e6465f658127')
),
(
UNHEX('a1b2c3d4e5f60123456789abcdef0003'), NULL, '2025-05-26 13:24:27.601860', NULL, '2025-05-26 13:24:27.601864',
1, 'Non Grouped Expenses', UNHEX('784ad2e326344ba58c5028c8ee56bcd8')
);
30 changes: 30 additions & 0 deletions src/main/resources/db/changelog/data/seed-users.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
databaseChangeLog:
- changeSet:
id: 2025-05-31-load-users
author: splitora
context: dev
changes:
- sql:
splitStatements: false
stripComments: true
sql: |
INSERT IGNORE INTO user (
id, created_by, created_on, modified_by, modified_on,
username, email, phone_country_code, phone_number,
password, registration_method, user_role
) VALUES
(
UNHEX('3719917506b14643afc7b8815fdc81cf'), NULL, '2025-05-26 13:24:27', NULL, '2025-05-26 13:24:27',
'nakul_test_90', '[email protected]', '+91', '0',
'$2a$10$txo1PsQ7M.2uLv/HO.S0TuRHWJPvV8X2oO4gEh/QBNfTX8KIHEuma', 'NORMAL', 'USER'
),
(
UNHEX('5790c07ad90e4df6a062e6465f658127'), NULL, '2025-05-26 13:24:27', NULL, '2025-05-26 13:24:27',
'superadmin', '[email protected]', '+91', '99',
'$2a$10$ndZUrGTuqXw1buq9/MF34eM1XnrnFzwx9227xCGockloaFq.zPb8K', 'NORMAL', 'ADMIN'
),
(
UNHEX('784ad2e326344ba58c5028c8ee56bcd8'), NULL, '2025-05-26 13:24:27', NULL, '2025-05-26 13:24:27',
'gaurav_test_22', '[email protected]', '+91', '1',
'$2a$10$ILSK/k88Rd6SUbiMBHg/IOhuWGk3N5WqRDLz3gDL0.ne.6nANMeaG', 'NORMAL', 'USER'
) ;
22 changes: 22 additions & 0 deletions src/main/resources/db/changelog/db.changelog-master-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
databaseChangeLog:
- include:
file: db/changelog/schema/user-create.yaml
context: dev
- include:
file: db/changelog/schema/group-create.yaml
context: dev
- include:
file: db/changelog/schema/groupmembers-create.yaml
context: dev
- include:
file: db/changelog/schema/expense-create.yaml
context: dev
- include:
file: db/changelog/schema/expenseshare-create.yaml
context: dev
- include:
file: db/changelog/data/seed-users.yaml
context: dev
- include:
file: db/changelog/data/seed-groups.yaml
context: dev
22 changes: 22 additions & 0 deletions src/main/resources/db/changelog/db.changelog-master-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
databaseChangeLog:
- include:
file: db/changelog/schema/user-create.yaml
context: prod
- include:
file: db/changelog/schema/group-create.yaml
context: prod
- include:
file: db/changelog/schema/groupmembers-create.yaml
context: prod
- include:
file: db/changelog/schema/expense-create.yaml
context: prod
- include:
file: db/changelog/schema/expenseshare-create.yaml
context: prod
- include:
file: file:/etc/secrets/seed-users.yaml
context: prod
- include:
file: file:/etc/secrets/seed-groups.yaml
context: prod
45 changes: 45 additions & 0 deletions src/main/resources/db/changelog/schema/expense-create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
databaseChangeLog:
- changeSet:
id: create-expense-table
author: splitora
changes:
- createTable:
tableName: expense
columns:
- column:
name: id
type: BINARY(16)
constraints:
primaryKey: true
- column:
name: created_by
type: BINARY(16)
- column:
name: created_on
type: TIMESTAMP
defaultValueComputed: CURRENT_TIMESTAMP
- column:
name: modified_by
type: BINARY(16)
- column:
name: modified_on
type: TIMESTAMP
defaultValueComputed: CURRENT_TIMESTAMP
- column:
name: group_id
type: BINARY(16)
constraints:
foreignKeyName: fk_expense_group
references: group_table(id)
- column:
name: payer_id
type: BINARY(16)
constraints:
foreignKeyName: fk_expense_payer
references: user(id)
- column:
name: amount
type: DOUBLE
- column:
name: description
type: VARCHAR(255)
Loading