Skip to content

Commit e35cbbe

Browse files
authored
Merge pull request #158 from Pseudo-Lab/feat/signin-api
회원가입 및 로그인 API
2 parents 8850fe8 + d0ef538 commit e35cbbe

File tree

15 files changed

+586
-4
lines changed

15 files changed

+586
-4
lines changed

.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,14 @@ APP_HOST=localhost
2020
# Service Port (Removed)
2121
BACKEND_PORT=8000
2222
FRONTEND_PORT=3000
23+
24+
# DB
25+
MYSQL_USER=your_mysql_user
26+
MYSQL_PASSWORD=your_mysql_password
27+
MYSQL_HOST=localhost
28+
MYSQL_DATABASE=jobpt
29+
30+
# JWT Secret (필수)
31+
# 아래 명령어로 랜덤 값 하나 생성해서 사용하세요.
32+
# python -c "import secrets; print(secrets.token_hex(32))"
33+
SECRET_KEY=change_me!

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ docker compose up [-d] [--build]
9797

9898
### 로컬 환경에서 직접 실행
9999

100+
DB 실행(단독 docker container)
101+
```bash
102+
sh db/run.sh
103+
```
104+
105+
106+
DB 마이그레이션 (테이블 생성 및 수정)
107+
```bash
108+
cd backend
109+
alembic upgrade head
110+
```
111+
100112
API 실행
101113

102114
```bash

assets/DB_Schema.drawio

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36" version="29.1.1">
2+
<diagram name="Page-1" id="ds7uoCSE5kZKHZCeQILd">
3+
<mxGraphModel dx="1101" dy="596" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
4+
<root>
5+
<mxCell id="0" />
6+
<mxCell id="1" parent="0" />
7+
<mxCell id="SP06STEzAbsmYMUdUcmi-2" edge="1" parent="1" source="SP06STEzAbsmYMUdUcmi-3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.25;entryDx=0;entryDy=0;endArrow=ERmany;endFill=0;" target="SP06STEzAbsmYMUdUcmi-7">
8+
<mxGeometry relative="1" as="geometry" />
9+
</mxCell>
10+
<mxCell id="SP06STEzAbsmYMUdUcmi-3" parent="1" style="swimlane;childLayout=stackLayout;horizontal=1;startSize=50;horizontalStack=0;rounded=1;fontSize=14;fontStyle=0;strokeWidth=2;resizeParent=0;resizeLast=1;shadow=0;dashed=0;align=center;arcSize=4;whiteSpace=wrap;html=1;" value="users" vertex="1">
11+
<mxGeometry height="140" width="160" x="200" y="90" as="geometry" />
12+
</mxCell>
13+
<mxCell id="SP06STEzAbsmYMUdUcmi-4" parent="SP06STEzAbsmYMUdUcmi-3" style="align=left;strokeColor=none;fillColor=none;spacingLeft=4;spacingRight=4;fontSize=12;verticalAlign=top;resizable=0;rotatable=0;part=1;html=1;whiteSpace=wrap;" value="&lt;div&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));&quot;&gt;+ id (PK)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;+ user_id&lt;/div&gt;&lt;div&gt;+ password&lt;/div&gt;&lt;div&gt;+ created_at&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;" vertex="1">
14+
<mxGeometry height="90" width="160" y="50" as="geometry" />
15+
</mxCell>
16+
<mxCell id="SP06STEzAbsmYMUdUcmi-5" edge="1" parent="SP06STEzAbsmYMUdUcmi-3" source="SP06STEzAbsmYMUdUcmi-4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" target="SP06STEzAbsmYMUdUcmi-4">
17+
<mxGeometry relative="1" as="geometry" />
18+
</mxCell>
19+
<mxCell id="SP06STEzAbsmYMUdUcmi-6" parent="1" style="swimlane;childLayout=stackLayout;horizontal=1;startSize=50;horizontalStack=0;rounded=1;fontSize=14;fontStyle=0;strokeWidth=2;resizeParent=0;resizeLast=1;shadow=0;dashed=0;align=center;arcSize=4;whiteSpace=wrap;html=1;" value="resumes" vertex="1">
20+
<mxGeometry height="140" width="160" x="490" y="90" as="geometry" />
21+
</mxCell>
22+
<mxCell id="SP06STEzAbsmYMUdUcmi-7" parent="SP06STEzAbsmYMUdUcmi-6" style="align=left;strokeColor=none;fillColor=none;spacingLeft=4;spacingRight=4;fontSize=12;verticalAlign=top;resizable=0;rotatable=0;part=1;html=1;whiteSpace=wrap;" value="&lt;div&gt;&lt;div&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));&quot;&gt;+ id (PK)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));&quot;&gt;&amp;nbsp;&lt;/span&gt;user_id (FK -&amp;gt; user.id)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));&quot;&gt;pdf_url&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;+ created_at&lt;/div&gt;" vertex="1">
23+
<mxGeometry height="90" width="160" y="50" as="geometry" />
24+
</mxCell>
25+
<mxCell id="SP06STEzAbsmYMUdUcmi-8" edge="1" parent="SP06STEzAbsmYMUdUcmi-6" source="SP06STEzAbsmYMUdUcmi-7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" target="SP06STEzAbsmYMUdUcmi-7">
26+
<mxGeometry relative="1" as="geometry" />
27+
</mxCell>
28+
<mxCell id="SP06STEzAbsmYMUdUcmi-9" parent="1" style="swimlane;childLayout=stackLayout;horizontal=1;startSize=50;horizontalStack=0;rounded=1;fontSize=14;fontStyle=0;strokeWidth=2;resizeParent=0;resizeLast=1;shadow=0;dashed=0;align=center;arcSize=4;whiteSpace=wrap;html=1;" value="VectorDB" vertex="1">
29+
<mxGeometry height="210" width="160" x="200" y="375" as="geometry" />
30+
</mxCell>
31+
<mxCell id="SP06STEzAbsmYMUdUcmi-10" parent="SP06STEzAbsmYMUdUcmi-9" style="align=left;strokeColor=none;fillColor=none;spacingLeft=4;spacingRight=4;fontSize=12;verticalAlign=top;resizable=0;rotatable=0;part=1;html=1;whiteSpace=wrap;" value="&lt;div&gt;+ embedding vector(jd_chunk)&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;+ metadata: {&lt;/div&gt;&lt;div&gt;&amp;nbsp; - id(FK -&amp;gt; jd.id)&lt;/div&gt;&lt;div&gt;&amp;nbsp; - description&lt;/div&gt;&lt;div&gt;&amp;nbsp; -&amp;nbsp;experience_requirement&lt;/div&gt;&lt;div&gt;&amp;nbsp; - job_url&lt;/div&gt;&lt;div&gt;&amp;nbsp; - location&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;" vertex="1">
32+
<mxGeometry height="160" width="160" y="50" as="geometry" />
33+
</mxCell>
34+
<mxCell id="SP06STEzAbsmYMUdUcmi-11" edge="1" parent="SP06STEzAbsmYMUdUcmi-9" source="SP06STEzAbsmYMUdUcmi-10" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" target="SP06STEzAbsmYMUdUcmi-10">
35+
<mxGeometry relative="1" as="geometry" />
36+
</mxCell>
37+
<mxCell id="SP06STEzAbsmYMUdUcmi-12" parent="1" style="whiteSpace=wrap;html=1;" value="VectorDB" vertex="1">
38+
<mxGeometry height="30" width="120" x="220" y="335" as="geometry" />
39+
</mxCell>
40+
<mxCell id="SP06STEzAbsmYMUdUcmi-13" parent="1" style="swimlane;childLayout=stackLayout;horizontal=1;startSize=50;horizontalStack=0;rounded=1;fontSize=14;fontStyle=0;strokeWidth=2;resizeParent=0;resizeLast=1;shadow=0;dashed=0;align=center;arcSize=4;whiteSpace=wrap;html=1;" value="JD" vertex="1">
41+
<mxGeometry height="150" width="160" x="490" y="375" as="geometry" />
42+
</mxCell>
43+
<mxCell id="SP06STEzAbsmYMUdUcmi-14" parent="SP06STEzAbsmYMUdUcmi-13" style="align=left;strokeColor=none;fillColor=none;spacingLeft=4;spacingRight=4;fontSize=12;verticalAlign=top;resizable=0;rotatable=0;part=1;html=1;whiteSpace=wrap;" value="&lt;div&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));&quot;&gt;+ id (PK)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;+ jd_url&lt;/div&gt;&lt;div&gt;+ summary&lt;/div&gt;&lt;div&gt;+ description&lt;/div&gt;&lt;div&gt;+ deadline date&lt;/div&gt;&lt;div&gt;+ created_at&lt;/div&gt;" vertex="1">
44+
<mxGeometry height="100" width="160" y="50" as="geometry" />
45+
</mxCell>
46+
<mxCell id="SP06STEzAbsmYMUdUcmi-15" edge="1" parent="SP06STEzAbsmYMUdUcmi-13" source="SP06STEzAbsmYMUdUcmi-14" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" target="SP06STEzAbsmYMUdUcmi-14">
47+
<mxGeometry relative="1" as="geometry" />
48+
</mxCell>
49+
<mxCell id="SP06STEzAbsmYMUdUcmi-16" edge="1" parent="1" source="SP06STEzAbsmYMUdUcmi-14" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" target="SP06STEzAbsmYMUdUcmi-10" value="">
50+
<mxGeometry relative="1" as="geometry" />
51+
</mxCell>
52+
<mxCell id="h0gC5ZdMWejn1akaWV5i-1" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="JobPT (mySQL)" vertex="1">
53+
<mxGeometry height="30" width="120" x="210" y="50" as="geometry" />
54+
</mxCell>
55+
</root>
56+
</mxGraphModel>
57+
</diagram>
58+
</mxfile>

backend/alembic.ini

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# A generic, single database configuration.
2+
3+
[alembic]
4+
# path to migration scripts.
5+
# this is typically a path given in POSIX (e.g. forward slashes)
6+
# format, relative to the token %(here)s which refers to the location of this
7+
# ini file
8+
script_location = %(here)s/alembic
9+
10+
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
11+
# Uncomment the line below if you want the files to be prepended with date and time
12+
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
13+
# for all available tokens
14+
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
15+
16+
# sys.path path, will be prepended to sys.path if present.
17+
# defaults to the current working directory. for multiple paths, the path separator
18+
# is defined by "path_separator" below.
19+
prepend_sys_path = .
20+
21+
22+
# timezone to use when rendering the date within the migration file
23+
# as well as the filename.
24+
# If specified, requires the tzdata library which can be installed by adding
25+
# `alembic[tz]` to the pip requirements.
26+
# string value is passed to ZoneInfo()
27+
# leave blank for localtime
28+
# timezone =
29+
30+
# max length of characters to apply to the "slug" field
31+
# truncate_slug_length = 40
32+
33+
# set to 'true' to run the environment during
34+
# the 'revision' command, regardless of autogenerate
35+
# revision_environment = false
36+
37+
# set to 'true' to allow .pyc and .pyo files without
38+
# a source .py file to be detected as revisions in the
39+
# versions/ directory
40+
# sourceless = false
41+
42+
# version location specification; This defaults
43+
# to <script_location>/versions. When using multiple version
44+
# directories, initial revisions must be specified with --version-path.
45+
# The path separator used here should be the separator specified by "path_separator"
46+
# below.
47+
# version_locations = %(here)s/bar:%(here)s/bat:%(here)s/alembic/versions
48+
49+
# path_separator; This indicates what character is used to split lists of file
50+
# paths, including version_locations and prepend_sys_path within configparser
51+
# files such as alembic.ini.
52+
# The default rendered in new alembic.ini files is "os", which uses os.pathsep
53+
# to provide os-dependent path splitting.
54+
#
55+
# Note that in order to support legacy alembic.ini files, this default does NOT
56+
# take place if path_separator is not present in alembic.ini. If this
57+
# option is omitted entirely, fallback logic is as follows:
58+
#
59+
# 1. Parsing of the version_locations option falls back to using the legacy
60+
# "version_path_separator" key, which if absent then falls back to the legacy
61+
# behavior of splitting on spaces and/or commas.
62+
# 2. Parsing of the prepend_sys_path option falls back to the legacy
63+
# behavior of splitting on spaces, commas, or colons.
64+
#
65+
# Valid values for path_separator are:
66+
#
67+
# path_separator = :
68+
# path_separator = ;
69+
# path_separator = space
70+
# path_separator = newline
71+
#
72+
# Use os.pathsep. Default configuration used for new projects.
73+
path_separator = os
74+
75+
# set to 'true' to search source files recursively
76+
# in each "version_locations" directory
77+
# new in Alembic version 1.10
78+
# recursive_version_locations = false
79+
80+
# the output encoding used when revision files
81+
# are written from script.py.mako
82+
# output_encoding = utf-8
83+
84+
# database URL. This is consumed by the user-maintained env.py script only.
85+
# other means of configuring database URLs may be customized within the env.py
86+
# file.
87+
sqlalchemy.url = driver://user:pass@localhost/dbname
88+
89+
90+
[post_write_hooks]
91+
# post_write_hooks defines scripts or Python functions that are run
92+
# on newly generated revision scripts. See the documentation for further
93+
# detail and examples
94+
95+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
96+
# hooks = black
97+
# black.type = console_scripts
98+
# black.entrypoint = black
99+
# black.options = -l 79 REVISION_SCRIPT_FILENAME
100+
101+
# lint with attempts to fix using "ruff" - use the module runner, against the "ruff" module
102+
# hooks = ruff
103+
# ruff.type = module
104+
# ruff.module = ruff
105+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
106+
107+
# Alternatively, use the exec runner to execute a binary found on your PATH
108+
# hooks = ruff
109+
# ruff.type = exec
110+
# ruff.executable = ruff
111+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
112+
113+
# Logging configuration. This is also consumed by the user-maintained
114+
# env.py script only.
115+
[loggers]
116+
keys = root,sqlalchemy,alembic
117+
118+
[handlers]
119+
keys = console
120+
121+
[formatters]
122+
keys = generic
123+
124+
[logger_root]
125+
level = WARNING
126+
handlers = console
127+
qualname =
128+
129+
[logger_sqlalchemy]
130+
level = WARNING
131+
handlers =
132+
qualname = sqlalchemy.engine
133+
134+
[logger_alembic]
135+
level = INFO
136+
handlers =
137+
qualname = alembic
138+
139+
[handler_console]
140+
class = StreamHandler
141+
args = (sys.stderr,)
142+
level = NOTSET
143+
formatter = generic
144+
145+
[formatter_generic]
146+
format = %(levelname)-5.5s [%(name)s] %(message)s
147+
datefmt = %H:%M:%S

backend/alembic/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Generic single-database configuration.

backend/alembic/env.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import os
2+
import sys
3+
from logging.config import fileConfig
4+
5+
from sqlalchemy import engine_from_config
6+
from sqlalchemy import pool
7+
8+
from alembic import context
9+
10+
# Add the backend directory to sys.path so we can import from db
11+
sys.path.append(os.getcwd())
12+
13+
from db.database import Base, SQLALCHEMY_DATABASE_URL
14+
from db.models import User, Resume # Import all models here
15+
16+
# this is the Alembic Config object, which provides
17+
# access to the values within the .ini file in use.
18+
config = context.config
19+
20+
# Interpret the config file for Python logging.
21+
# This line sets up loggers basically.
22+
if config.config_file_name is not None:
23+
fileConfig(config.config_file_name)
24+
25+
# Set the sqlalchemy.url in the config object
26+
config.set_main_option("sqlalchemy.url", SQLALCHEMY_DATABASE_URL)
27+
28+
# add your model's MetaData object here
29+
# for 'autogenerate' support
30+
target_metadata = Base.metadata
31+
32+
# other values from the config, defined by the needs of env.py,
33+
# can be acquired:
34+
# my_important_option = config.get_main_option("my_important_option")
35+
# ... etc.
36+
37+
38+
def run_migrations_offline() -> None:
39+
"""Run migrations in 'offline' mode.
40+
41+
This configures the context with just a URL
42+
and not an Engine, though an Engine is acceptable
43+
here as well. By skipping the Engine creation
44+
we don't even need a DBAPI to be available.
45+
46+
Calls to context.execute() here emit the given string to the
47+
script output.
48+
49+
"""
50+
url = config.get_main_option("sqlalchemy.url")
51+
context.configure(
52+
url=url,
53+
target_metadata=target_metadata,
54+
literal_binds=True,
55+
dialect_opts={"paramstyle": "named"},
56+
)
57+
58+
with context.begin_transaction():
59+
context.run_migrations()
60+
61+
62+
def run_migrations_online() -> None:
63+
"""Run migrations in 'online' mode.
64+
65+
In this scenario we need to create an Engine
66+
and associate a connection with the context.
67+
68+
"""
69+
connectable = engine_from_config(
70+
config.get_section(config.config_ini_section, {}),
71+
prefix="sqlalchemy.",
72+
poolclass=pool.NullPool,
73+
)
74+
75+
with connectable.connect() as connection:
76+
context.configure(
77+
connection=connection, target_metadata=target_metadata
78+
)
79+
80+
with context.begin_transaction():
81+
context.run_migrations()
82+
83+
84+
if context.is_offline_mode():
85+
run_migrations_offline()
86+
else:
87+
run_migrations_online()

backend/alembic/script.py.mako

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""${message}
2+
3+
Revision ID: ${up_revision}
4+
Revises: ${down_revision | comma,n}
5+
Create Date: ${create_date}
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
import sqlalchemy as sa
12+
${imports if imports else ""}
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = ${repr(up_revision)}
16+
down_revision: Union[str, Sequence[str], None] = ${repr(down_revision)}
17+
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
18+
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
19+
20+
21+
def upgrade() -> None:
22+
"""Upgrade schema."""
23+
${upgrades if upgrades else "pass"}
24+
25+
26+
def downgrade() -> None:
27+
"""Downgrade schema."""
28+
${downgrades if downgrades else "pass"}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""Initial migraion
2+
3+
Revision ID: e9dbfc41c641
4+
Revises:
5+
Create Date: 2025-11-27 21:08:54.018013
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
import sqlalchemy as sa
12+
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = 'e9dbfc41c641'
16+
down_revision: Union[str, Sequence[str], None] = None
17+
branch_labels: Union[str, Sequence[str], None] = None
18+
depends_on: Union[str, Sequence[str], None] = None
19+
20+
21+
def upgrade() -> None:
22+
"""Upgrade schema."""
23+
# ### commands auto generated by Alembic - please adjust! ###
24+
pass
25+
# ### end Alembic commands ###
26+
27+
28+
def downgrade() -> None:
29+
"""Downgrade schema."""
30+
# ### commands auto generated by Alembic - please adjust! ###
31+
pass
32+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)