diff --git a/backend/.gitattributes b/backend/.gitattributes new file mode 100644 index 00000000..8af972cd --- /dev/null +++ b/backend/.gitattributes @@ -0,0 +1,3 @@ +/gradlew text eol=lf +*.bat text eol=crlf +*.jar binary diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 00000000..c2065bc2 --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,37 @@ +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ diff --git a/backend/.gitkeep b/backend/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/backend/build.gradle b/backend/build.gradle new file mode 100644 index 00000000..79807023 --- /dev/null +++ b/backend/build.gradle @@ -0,0 +1,50 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '4.0.4' + id 'io.spring.dependency-management' version '1.1.7' +} + +group = 'com.stackup' +version = '0.0.1-SNAPSHOT' + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +repositories { + mavenCentral() +} + +dependencies { + // web, jpa, DB(postgresql) + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + runtimeOnly 'org.postgresql:postgresql' + // lombok + compileOnly 'org.projectlombok:lombok' + annotationProcessor 'org.projectlombok:lombok' + + // Querydsl + implementation 'com.querydsl:querydsl-jpa:5.1.0:jakarta' + // Querydsl QClass APT + annotationProcessor 'com.querydsl:querydsl-apt:5.1.0:jakarta' + // Querydsl annotation API + annotationProcessor "jakarta.annotation:jakarta.annotation-api" + annotationProcessor "jakarta.persistence:jakarta.persistence-api" + + // test + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/backend/gradle/wrapper/gradle-wrapper.jar b/backend/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..d997cfc6 Binary files /dev/null and b/backend/gradle/wrapper/gradle-wrapper.jar differ diff --git a/backend/gradle/wrapper/gradle-wrapper.properties b/backend/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..dbc3ce4a --- /dev/null +++ b/backend/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/backend/gradlew b/backend/gradlew new file mode 100644 index 00000000..0262dcbd --- /dev/null +++ b/backend/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/backend/gradlew.bat b/backend/gradlew.bat new file mode 100644 index 00000000..c4bdd3ab --- /dev/null +++ b/backend/gradlew.bat @@ -0,0 +1,93 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/backend/settings.gradle b/backend/settings.gradle new file mode 100644 index 00000000..663f5090 --- /dev/null +++ b/backend/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'stackup' diff --git a/backend/src/main/java/com/stackup/stackup/StackupApplication.java b/backend/src/main/java/com/stackup/stackup/StackupApplication.java new file mode 100644 index 00000000..086eb908 --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/StackupApplication.java @@ -0,0 +1,13 @@ +package com.stackup.stackup; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class StackupApplication { + + public static void main(String[] args) { + SpringApplication.run(StackupApplication.class, args); + } + +} diff --git a/backend/src/main/java/com/stackup/stackup/auth/domain/RefreshToken.java b/backend/src/main/java/com/stackup/stackup/auth/domain/RefreshToken.java new file mode 100644 index 00000000..6314c084 --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/auth/domain/RefreshToken.java @@ -0,0 +1,53 @@ +package com.stackup.stackup.auth.domain; + +import com.stackup.stackup.common.entity.BaseTimeEntity; +import com.stackup.stackup.user.domain.User; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Getter +@Entity +@Table( + name = "refresh_tokens", + indexes = { + @Index(name = "idx_refresh_tokens_user", columnList = "user_id"), + @Index(name = "idx_refresh_tokens_hash", columnList = "token_hash"), + @Index(name = "idx_refresh_tokens_expires", columnList = "expires_at") + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class RefreshToken extends BaseTimeEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = false) + private User user; + + @Column(name = "token_hash", nullable = false, unique = true, length = 500) + private String tokenHash; + + @Column(name = "device_info", length = 500) + private String deviceInfo; + + @Column(name = "expires_at", nullable = false) + private LocalDateTime expiresAt; + + @Column(name = "is_revoked", nullable = false) + private boolean revoked = false; +} diff --git a/backend/src/main/java/com/stackup/stackup/common/entity/BaseSoftDeleteEntity.java b/backend/src/main/java/com/stackup/stackup/common/entity/BaseSoftDeleteEntity.java new file mode 100644 index 00000000..92d6fc17 --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/common/entity/BaseSoftDeleteEntity.java @@ -0,0 +1,13 @@ +package com.stackup.stackup.common.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.MappedSuperclass; +import lombok.Getter; + +@Getter +@MappedSuperclass +public abstract class BaseSoftDeleteEntity extends BaseTimeAndUpdateEntity { + + @Column(name = "is_deleted", nullable = false) + protected boolean deleted = false; +} diff --git a/backend/src/main/java/com/stackup/stackup/common/entity/BaseTimeAndUpdateEntity.java b/backend/src/main/java/com/stackup/stackup/common/entity/BaseTimeAndUpdateEntity.java new file mode 100644 index 00000000..fbd0a6f1 --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/common/entity/BaseTimeAndUpdateEntity.java @@ -0,0 +1,17 @@ +package com.stackup.stackup.common.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.MappedSuperclass; +import lombok.Getter; +import org.hibernate.annotations.UpdateTimestamp; + +import java.time.LocalDateTime; + +@Getter +@MappedSuperclass +public abstract class BaseTimeAndUpdateEntity extends BaseTimeEntity { + + @UpdateTimestamp + @Column(name = "updated_at", nullable = false) + protected LocalDateTime updatedAt; +} diff --git a/backend/src/main/java/com/stackup/stackup/common/entity/BaseTimeEntity.java b/backend/src/main/java/com/stackup/stackup/common/entity/BaseTimeEntity.java new file mode 100644 index 00000000..4c8af302 --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/common/entity/BaseTimeEntity.java @@ -0,0 +1,17 @@ +package com.stackup.stackup.common.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.MappedSuperclass; +import lombok.Getter; +import org.hibernate.annotations.CreationTimestamp; + +import java.time.LocalDateTime; + +@Getter +@MappedSuperclass +public abstract class BaseTimeEntity { + + @CreationTimestamp + @Column(name = "created_at", nullable = false, updatable = false) + protected LocalDateTime createdAt; +} diff --git a/backend/src/main/java/com/stackup/stackup/document/domain/AnalyzedDocument.java b/backend/src/main/java/com/stackup/stackup/document/domain/AnalyzedDocument.java new file mode 100644 index 00000000..e57bf4ef --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/document/domain/AnalyzedDocument.java @@ -0,0 +1,47 @@ +package com.stackup.stackup.document.domain; + +import com.stackup.stackup.common.entity.BaseSoftDeleteEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table( + name = "analyzed_documents", + indexes = { + @Index(name = "idx_analyzed_docs_source", columnList = "source_type, source_id") + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class AnalyzedDocument extends BaseSoftDeleteEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "source_type", nullable = false, length = 20) + private String sourceType; + + @Column(name = "source_id", nullable = false) + private Long sourceId; + + @Column(name = "document_path", nullable = false, length = 1000) + private String documentPath; + + @Column(length = 2000) + private String summary; + + @Column(name = "tech_stack", columnDefinition = "jsonb") + private String techStack; + + @Column(nullable = false, length = 20) + private String status = "ACTIVE"; +} diff --git a/backend/src/main/java/com/stackup/stackup/github/domain/GithubRepository.java b/backend/src/main/java/com/stackup/stackup/github/domain/GithubRepository.java new file mode 100644 index 00000000..fdb0b180 --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/github/domain/GithubRepository.java @@ -0,0 +1,60 @@ +package com.stackup.stackup.github.domain; + +import com.stackup.stackup.common.entity.BaseSoftDeleteEntity; +import com.stackup.stackup.user.domain.User; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Getter +@Entity +@Table( + name = "repositories", + indexes = { + @Index(name = "idx_repositories_user_id", columnList = "user_id") + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class GithubRepository extends BaseSoftDeleteEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = false) + private User user; + + @Column(name = "github_repo_id", nullable = false) + private Long githubRepoId; + + @Column(name = "repo_name", nullable = false, length = 255) + private String repoName; + + @Column(name = "repo_full_name", nullable = false, length = 500) + private String repoFullName; + + @Column(name = "repo_url", nullable = false, length = 500) + private String repoUrl; + + @Column(name = "default_branch", length = 100) + private String defaultBranch = "main"; + + @Column(nullable = false, length = 20) + private String status = "PENDING"; + + @Column(name = "last_synced_at") + private LocalDateTime lastSyncedAt; +} diff --git a/backend/src/main/java/com/stackup/stackup/log/activity/domain/ActivityLog.java b/backend/src/main/java/com/stackup/stackup/log/activity/domain/ActivityLog.java new file mode 100644 index 00000000..dbb3449c --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/log/activity/domain/ActivityLog.java @@ -0,0 +1,57 @@ +package com.stackup.stackup.log.activity.domain; + +import com.stackup.stackup.common.entity.BaseTimeEntity; +import com.stackup.stackup.user.domain.User; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table( + name = "activity_logs", + indexes = { + @Index(name = "idx_activity_logs_user", columnList = "user_id, created_at"), + @Index(name = "idx_activity_logs_action", columnList = "action, created_at"), + @Index(name = "idx_activity_logs_created", columnList = "created_at") + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class ActivityLog extends BaseTimeEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @Column(nullable = false, length = 50) + private String action; + + @Column(name = "resource_type", length = 30) + private String resourceType; + + @Column(name = "resource_id") + private Long resourceId; + + @Column(columnDefinition = "jsonb") + private String detail; + + @Column(name = "ip_address", length = 45) + private String ipAddress; + + @Column(name = "user_agent", length = 500) + private String userAgent; +} diff --git a/backend/src/main/java/com/stackup/stackup/log/ai/domain/AiRequestLog.java b/backend/src/main/java/com/stackup/stackup/log/ai/domain/AiRequestLog.java new file mode 100644 index 00000000..59422d2b --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/log/ai/domain/AiRequestLog.java @@ -0,0 +1,66 @@ +package com.stackup.stackup.log.ai.domain; + +import com.stackup.stackup.common.entity.BaseTimeEntity; +import com.stackup.stackup.session.domain.InterviewSession; +import com.stackup.stackup.user.domain.User; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table( + name = "ai_request_logs", + indexes = { + @Index(name = "idx_ai_logs_user", columnList = "user_id, created_at"), + @Index(name = "idx_ai_logs_session", columnList = "session_id"), + @Index(name = "idx_ai_logs_type", columnList = "request_type, created_at"), + @Index(name = "idx_ai_logs_created", columnList = "created_at") + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class AiRequestLog extends BaseTimeEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "session_id") + private InterviewSession session; + + @Column(name = "request_type", nullable = false, length = 50) + private String requestType; + + @Column(name = "model_name", length = 100) + private String modelName; + + @Column(name = "input_tokens") + private Integer inputTokens; + + @Column(name = "output_tokens") + private Integer outputTokens; + + @Column(name = "latency_ms") + private Integer latencyMs; + + @Column(nullable = false, length = 20) + private String status; + + @Column(name = "error_message", columnDefinition = "text") + private String errorMessage; +} diff --git a/backend/src/main/java/com/stackup/stackup/resume/domain/Resume.java b/backend/src/main/java/com/stackup/stackup/resume/domain/Resume.java new file mode 100644 index 00000000..2467c9c2 --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/resume/domain/Resume.java @@ -0,0 +1,52 @@ +package com.stackup.stackup.resume.domain; + +import com.stackup.stackup.common.entity.BaseSoftDeleteEntity; +import com.stackup.stackup.user.domain.User; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table( + name = "resumes", + indexes = { + @Index(name = "idx_resumes_user_id", columnList = "user_id") + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Resume extends BaseSoftDeleteEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = false) + private User user; + + @Column(name = "original_filename", nullable = false, length = 500) + private String originalFilename; + + @Column(name = "file_path", nullable = false, length = 1000) + private String filePath; + + @Column(name = "file_type", nullable = false, length = 20) + private String fileType; + + @Column(name = "file_size") + private Long fileSize; + + @Column(nullable = false, length = 20) + private String status = "PENDING"; +} diff --git a/backend/src/main/java/com/stackup/stackup/session/domain/InterviewMessage.java b/backend/src/main/java/com/stackup/stackup/session/domain/InterviewMessage.java new file mode 100644 index 00000000..04ef86e5 --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/session/domain/InterviewMessage.java @@ -0,0 +1,56 @@ +package com.stackup.stackup.session.domain; + +import com.stackup.stackup.common.entity.BaseTimeEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table( + name = "interview_messages", + indexes = { + @Index(name = "idx_messages_session", columnList = "session_id, sequence_number"), + @Index(name = "idx_messages_parent", columnList = "parent_message_id") + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class InterviewMessage extends BaseTimeEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "session_id", nullable = false) + private InterviewSession session; + + @Column(name = "sequence_number", nullable = false) + private Integer sequenceNumber; + + @Column(nullable = false, length = 20) + private String role; + + @Column(columnDefinition = "text") + private String content; + + @Column(name = "audio_file_path", length = 1000) + private String audioFilePath; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "parent_message_id") + private InterviewMessage parentMessage; + + @Column(nullable = false, length = 20) + private String status = "CREATED"; +} diff --git a/backend/src/main/java/com/stackup/stackup/session/domain/InterviewSession.java b/backend/src/main/java/com/stackup/stackup/session/domain/InterviewSession.java new file mode 100644 index 00000000..2e19b27f --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/session/domain/InterviewSession.java @@ -0,0 +1,73 @@ +package com.stackup.stackup.session.domain; + +import com.stackup.stackup.common.entity.BaseSoftDeleteEntity; +import com.stackup.stackup.user.domain.User; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Getter +@Entity +@Table( + name = "interview_sessions", + indexes = { + @Index(name = "idx_sessions_user_id", columnList = "user_id"), + @Index(name = "idx_sessions_user_status", columnList = "user_id, status") + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class InterviewSession extends BaseSoftDeleteEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = false) + private User user; + + @Column(length = 200) + private String title; + + @Column(columnDefinition = "text") + private String memo; + + @Column(nullable = false, length = 20) + private String mode; + + @Column(name = "interview_type", nullable = false, length = 30) + private String interviewType; + + @Column(name = "job_category", nullable = false, length = 30) + private String jobCategory; + + @Column(name = "max_questions", nullable = false) + private Integer maxQuestions = 10; + + @Column(name = "max_duration_minutes", nullable = false) + private Integer maxDurationMinutes = 60; + + @Column(nullable = false, length = 20) + private String status = "READY"; + + @Column(name = "total_question_count") + private Integer totalQuestionCount = 0; + + @Column(name = "started_at") + private LocalDateTime startedAt; + + @Column(name = "ended_at") + private LocalDateTime endedAt; +} diff --git a/backend/src/main/java/com/stackup/stackup/session/domain/MessageVoiceAnalysis.java b/backend/src/main/java/com/stackup/stackup/session/domain/MessageVoiceAnalysis.java new file mode 100644 index 00000000..3c12527a --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/session/domain/MessageVoiceAnalysis.java @@ -0,0 +1,48 @@ +package com.stackup.stackup.session.domain; + +import com.stackup.stackup.common.entity.BaseTimeEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table( + name = "message_voice_analyses", + indexes = { + @Index(name = "idx_voice_analyses_message", columnList = "message_id") + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class MessageVoiceAnalysis extends BaseTimeEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "message_id", nullable = false, unique = true) + private InterviewMessage message; + + @Column(name = "speaking_rate_wpm") + private Double speakingRateWpm; + + @Column(name = "silence_duration_sec") + private Double silenceDurationSec; + + @Column(name = "filler_word_counts", columnDefinition = "jsonb") + private String fillerWordCounts; + + @Column(name = "pronunciation_accuracy") + private Double pronunciationAccuracy; +} diff --git a/backend/src/main/java/com/stackup/stackup/session/domain/SessionContext.java b/backend/src/main/java/com/stackup/stackup/session/domain/SessionContext.java new file mode 100644 index 00000000..ad1e53f8 --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/session/domain/SessionContext.java @@ -0,0 +1,44 @@ +package com.stackup.stackup.session.domain; + +import com.stackup.stackup.common.entity.BaseTimeEntity; +import com.stackup.stackup.document.domain.AnalyzedDocument; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.persistence.UniqueConstraint; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table( + name = "session_contexts", + uniqueConstraints = { + @UniqueConstraint(name = "idx_session_contexts_unique", columnNames = {"session_id", "document_id"}) + }, + indexes = { + @Index(name = "idx_session_contexts_session", columnList = "session_id") + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class SessionContext extends BaseTimeEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "session_id", nullable = false) + private InterviewSession session; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "document_id", nullable = false) + private AnalyzedDocument document; +} diff --git a/backend/src/main/java/com/stackup/stackup/session/domain/SessionFeedback.java b/backend/src/main/java/com/stackup/stackup/session/domain/SessionFeedback.java new file mode 100644 index 00000000..3f56c8dc --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/session/domain/SessionFeedback.java @@ -0,0 +1,54 @@ +package com.stackup.stackup.session.domain; + +import com.stackup.stackup.common.entity.BaseSoftDeleteEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table(name = "session_feedbacks") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class SessionFeedback extends BaseSoftDeleteEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "session_id", nullable = false, unique = true) + private InterviewSession session; + + @Column(name = "overall_score") + private Double overallScore; + + @Column(name = "technical_accuracy") + private Double technicalAccuracy; + + @Column(name = "logic_score") + private Double logicScore; + + @Column(name = "communication_score") + private Double communicationScore; + + @Column(name = "strengths_summary", columnDefinition = "text") + private String strengthsSummary; + + @Column(name = "weaknesses_summary", columnDefinition = "text") + private String weaknessesSummary; + + @Column(name = "improvement_keywords", columnDefinition = "jsonb") + private String improvementKeywords; + + @Column(name = "report_file_path", length = 1000) + private String reportFilePath; +} diff --git a/backend/src/main/java/com/stackup/stackup/user/domain/User.java b/backend/src/main/java/com/stackup/stackup/user/domain/User.java new file mode 100644 index 00000000..f4c922e2 --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/user/domain/User.java @@ -0,0 +1,44 @@ +package com.stackup.stackup.user.domain; + +import com.stackup.stackup.common.entity.BaseSoftDeleteEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table( + name = "users", + indexes = { + @Index(name = "idx_users_github_id", columnList = "github_id") + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class User extends BaseSoftDeleteEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "github_id", nullable = false, unique = true) + private Long githubId; + + @Column(name = "github_username", nullable = false, length = 100) + private String githubUsername; + + @Column(length = 255) + private String email; + + @Column(name = "avatar_url", length = 500) + private String avatarUrl; + + @Column(name = "github_access_token", nullable = false, length = 500) + private String githubAccessToken; +} diff --git a/backend/src/main/java/com/stackup/stackup/user/domain/consent/UserConsent.java b/backend/src/main/java/com/stackup/stackup/user/domain/consent/UserConsent.java new file mode 100644 index 00000000..2cd85720 --- /dev/null +++ b/backend/src/main/java/com/stackup/stackup/user/domain/consent/UserConsent.java @@ -0,0 +1,58 @@ +package com.stackup.stackup.user.domain.consent; + +import com.stackup.stackup.common.entity.BaseTimeEntity; +import com.stackup.stackup.user.domain.User; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Getter +@Entity +@Table( + name = "user_consents", + indexes = { + @Index(name = "idx_user_consents_user", columnList = "user_id"), + @Index(name = "idx_user_consents_type", columnList = "user_id, consent_type") + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class UserConsent extends BaseTimeEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = false) + private User user; + + @Column(name = "consent_type", nullable = false, length = 50) + private String consentType; + + @Column(name = "consent_version", nullable = false, length = 20) + private String consentVersion; + + @Column(name = "is_agreed", nullable = false) + private boolean agreed = true; + + @Column(name = "agreed_at", nullable = false) + private LocalDateTime agreedAt; + + @Column(name = "revoked_at") + private LocalDateTime revokedAt; + + @Column(name = "ip_address", length = 45) + private String ipAddress; +} diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties new file mode 100644 index 00000000..356f9477 --- /dev/null +++ b/backend/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name=stackup diff --git a/backend/src/test/java/com/stackup/stackup/StackupApplicationTests.java b/backend/src/test/java/com/stackup/stackup/StackupApplicationTests.java new file mode 100644 index 00000000..c43aa8ff --- /dev/null +++ b/backend/src/test/java/com/stackup/stackup/StackupApplicationTests.java @@ -0,0 +1,13 @@ +package com.stackup.stackup; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class StackupApplicationTests { + + @Test + void contextLoads() { + } + +}