Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0d305f4
[Feat]: 의존성 추가 - authlib, httpx
Jangmyun Jan 10, 2026
1b1acd5
[Feat]: postgresql DB에 대해 ORM 도입을 위해 sqlalchemy, psycopg2-binary 추가
Jangmyun Jan 10, 2026
f94edc1
[Feat]: 환경변수 중앙집중식 관리를 위한 pydantic-settings
Jangmyun Jan 10, 2026
544b22e
[Refactor]: app 패키지에 main.py 가 위치
Jangmyun Jan 10, 2026
76cb2b9
[Feat]: 현재 배포에 필요한 환경변수를 BaseSettings에 추가 (SECRET, DB 관련 등)
Jangmyun Jan 10, 2026
884e67b
[Feat]: .env 로부터 변수 가져오기
Jangmyun Jan 10, 2026
4474363
[Fix]: .env로부터 값을 읽음에도 초기값 없어서 발생하는 에러해결 (초기값 부여)
Jangmyun Jan 10, 2026
3df135b
[Feat]: lru_cache를 통해 settings 값을 한번만 읽기
Jangmyun Jan 10, 2026
59d6e1b
[Feat]: settings 변수로 환경변수 가져오기
Jangmyun Jan 10, 2026
9f02264
[Feat]: __init__.py 생성
Jangmyun Jan 10, 2026
6440dcc
[Feat]: Pydantic settings 값으로 Engine 생성
Jangmyun Jan 10, 2026
388d3b6
[Feat]: Session 클래스 생성
Jangmyun Jan 10, 2026
3ac02e6
[Feat]: Model 들이 상속받을 Base 클래스 생성
Jangmyun Jan 10, 2026
17a7eea
[Feat]: FastAPI 권장 방식으로 DB 세션 DI
Jangmyun Jan 10, 2026
b76c721
[Rename]: session.py -> database.py
Jangmyun Jan 10, 2026
a9ea26d
[Feat]: User model 예시 작성
Jangmyun Jan 10, 2026
54c40fb
[Fix]: User Model 기본 타입과 row 생성/업데이트 시 자동기록 로직 포함하도록 재작성
Jangmyun Jan 10, 2026
aa25526
[Feat]: Alembic(스키마 마이그레이션 도구) 도입 전 테이블 자동 생성 로직
Jangmyun Jan 10, 2026
47de395
[Chore]: Alembic 도입 필요성 TODO 작성
Jangmyun Jan 10, 2026
03b75d1
[Chore]: FastAPI app 객체 title 지정
Jangmyun Jan 10, 2026
8d338e8
[Feat]: Docker database data ignore
Jangmyun Jan 10, 2026
679c498
[Feat]: db 서버도 port(5432:5432) 뚫음
Jangmyun Jan 10, 2026
c160c04
[Feat]: db test 엔드포인트 작성 (차후 삭제 후 자체 test 코드 작성 필요)
Jangmyun Jan 10, 2026
1c6d9d2
Merge branch '4-feat-google-oauth' into 5-feat-sync-postgresql-with-orm
Jangmyun Jan 11, 2026
f321752
Merge pull request #6 from Computer-Research-Association/5-feat-sync-…
Jangmyun Jan 11, 2026
95698f5
[Feat]: Alembic 도입
Jangmyun Jan 11, 2026
112a8f6
[Feat]: alembic init
Jangmyun Jan 11, 2026
2f87ad7
[Feat]: sqlalchemy.url 은 보안을 위해 동적으로 주입
Jangmyun Jan 11, 2026
b4192b9
[Chore]: import 최적화
Jangmyun Jan 11, 2026
6cf9bfe
[Feat]: target metadata를 기존에 models Base 의 메타데이터로 설정
Jangmyun Jan 11, 2026
3e90adc
[Feat]: sqlalchemy.url 을 환경변수에서 동적으로 주입
Jangmyun Jan 11, 2026
190d65d
[Chore]: 설정 위치만 변경
Jangmyun Jan 11, 2026
5aaf6da
[Feat]: 첫 alembic migration
Jangmyun Jan 11, 2026
3a95ae4
[Document]: Alembic 사용 가이드 README ** model 수정 관련하여 잘 숙지 필요
Jangmyun Jan 11, 2026
49c4c72
[Document]: Alembic README에 실전 예시도 추가
Jangmyun Jan 11, 2026
5126e7d
[Feat]: apply ERD-based models and initial Alembic migration (#8)
Losecow Jan 16, 2026
8c3d466
[Chore]: restore docker-compose.yml and python version file
Losecow Jan 17, 2026
7d27be0
[Chore]: update gitignore
Losecow Jan 17, 2026
6967e34
[Fix]: correct UserStatus enum casing
Losecow Jan 17, 2026
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Docker database data
postgres_data/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
2 changes: 1 addition & 1 deletion fastapi-backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ RUN uv sync --frozen --no-cache
COPY . .

# 실행 (uv run을 통해 설치된 환경에서 실행)
CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
149 changes: 149 additions & 0 deletions fastapi-backend/alembic.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# A generic, single database configuration.

[alembic]
# path to migration scripts.
# this is typically a path given in POSIX (e.g. forward slashes)
# format, relative to the token %(here)s which refers to the location of this
# ini file
script_location = %(here)s/migrations

# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
# for all available tokens
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
# Or organize into date-based subdirectories (requires recursive_version_locations = true)
# file_template = %%(year)d/%%(month).2d/%%(day).2d_%%(hour).2d%%(minute).2d_%%(second).2d_%%(rev)s_%%(slug)s

# sys.path path, will be prepended to sys.path if present.
# defaults to the current working directory. for multiple paths, the path separator
# is defined by "path_separator" below.
prepend_sys_path = .


# timezone to use when rendering the date within the migration file
# as well as the filename.
# If specified, requires the tzdata library which can be installed by adding
# `alembic[tz]` to the pip requirements.
# string value is passed to ZoneInfo()
# leave blank for localtime
# timezone =

# max length of characters to apply to the "slug" field
# truncate_slug_length = 40

# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false

# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false

# version location specification; This defaults
# to <script_location>/versions. When using multiple version
# directories, initial revisions must be specified with --version-path.
# The path separator used here should be the separator specified by "path_separator"
# below.
# version_locations = %(here)s/bar:%(here)s/bat:%(here)s/alembic/versions

# path_separator; This indicates what character is used to split lists of file
# paths, including version_locations and prepend_sys_path within configparser
# files such as alembic.ini.
# The default rendered in new alembic.ini files is "os", which uses os.pathsep
# to provide os-dependent path splitting.
#
# Note that in order to support legacy alembic.ini files, this default does NOT
# take place if path_separator is not present in alembic.ini. If this
# option is omitted entirely, fallback logic is as follows:
#
# 1. Parsing of the version_locations option falls back to using the legacy
# "version_path_separator" key, which if absent then falls back to the legacy
# behavior of splitting on spaces and/or commas.
# 2. Parsing of the prepend_sys_path option falls back to the legacy
# behavior of splitting on spaces, commas, or colons.
#
# Valid values for path_separator are:
#
# path_separator = :
# path_separator = ;
# path_separator = space
# path_separator = newline
#
# Use os.pathsep. Default configuration used for new projects.
path_separator = os

# set to 'true' to search source files recursively
# in each "version_locations" directory
# new in Alembic version 1.10
# recursive_version_locations = false

# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8

# database URL. This is consumed by the user-maintained env.py script only.
# other means of configuring database URLs may be customized within the env.py
# file.
# sqlalchemy.url = driver://user:pass@localhost/dbname


[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples

# format using "black" - use the console_scripts runner, against the "black" entrypoint
# hooks = black
# black.type = console_scripts
# black.entrypoint = black
# black.options = -l 79 REVISION_SCRIPT_FILENAME

# lint with attempts to fix using "ruff" - use the module runner, against the "ruff" module
# hooks = ruff
# ruff.type = module
# ruff.module = ruff
# ruff.options = check --fix REVISION_SCRIPT_FILENAME

# Alternatively, use the exec runner to execute a binary found on your PATH
# hooks = ruff
# ruff.type = exec
# ruff.executable = ruff
# ruff.options = check --fix REVISION_SCRIPT_FILENAME

# Logging configuration. This is also consumed by the user-maintained
# env.py script only.
[loggers]
keys = root,sqlalchemy,alembic

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARNING
handlers = console
qualname =

[logger_sqlalchemy]
level = WARNING
handlers =
qualname = sqlalchemy.engine

[logger_alembic]
level = INFO
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
Empty file added fastapi-backend/app/__init__.py
Empty file.
Empty file.
30 changes: 30 additions & 0 deletions fastapi-backend/app/core/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from functools import lru_cache
from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
PROJECT_NAME: str = "Metamong"

# Google OAuth
GOOGLE_CLIENT_ID: str = ""
GOOGLE_CLIENT_SECRET: str = ""

# Security
JWT_SECRET: str = ""
SECRET_KEY: str = ""

# DB
DATABASE_URL: str = ""
DB_PASSWORD: str = ""

model_config = SettingsConfigDict(
env_file=".env"
)


@lru_cache
def get_settings():
return Settings()


settings = get_settings()
Empty file.
20 changes: 20 additions & 0 deletions fastapi-backend/app/db/database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base

from app.core.config import settings

engine = create_engine(settings.DATABASE_URL)

SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

Base = declarative_base()


# Dependency: DB 세션 주입
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
Loading