Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
f07ab6d
[add]ci.yml
ARISA1115 Apr 26, 2025
920788d
[add]cd.yml
ARISA1115 Apr 26, 2025
4c257c5
[add]ci.yml
ARISA1115 Apr 26, 2025
ddb09a7
Merge pull request #8 from 2025SpringTeamA/infra
sasakifuruta Apr 27, 2025
53927a7
チャットのCRUD処理作成と履歴表示用schema追記
sasakifuruta Apr 27, 2025
10ddd68
[add]SECRET_KEY を .env ファイルから読み込むための処理を追加
ARISA1115 Apr 27, 2025
e3485fc
[add]各Routerをまとめる処理を追加
ARISA1115 Apr 27, 2025
d2381bb
[add]ユーザー登録、ログイン、ログアウト機能のエンドポイントを実装
ARISA1115 Apr 27, 2025
63f16ba
[add]感情の追加、取得機能のエンドポイントを実装
ARISA1115 Apr 27, 2025
92f49e1
[add]メッセージのお気に入り登録、解除機能のエンドポイントを実装
ARISA1115 Apr 27, 2025
f46dd08
[add]生成されたメディアの追加、取得機能のエンドポイントを実装
ARISA1115 Apr 27, 2025
0cf7c93
[add]チャットセッションの作成、取得、更新、削除機能のエンドポイントを実装
ARISA1115 Apr 27, 2025
7501ff1
[add]ユーザー情報の取得、更新、削除機能のエンドポイントを実装
ARISA1115 Apr 27, 2025
469a6f7
[add]チャットメッセージの作成、更新、削除、履歴取得機能のエンドポイントを実装
ARISA1115 Apr 27, 2025
faaf65d
[add]JWT認証トークンの生成、パスワードのハッシュ化および検証、認証ユーザーの取得処理を実装
ARISA1115 Apr 27, 2025
73f4565
[add]データベース接続のセッション管理を行う処理を実装
ARISA1115 Apr 27, 2025
dc53a97
チャット履歴 削除機能
sasakifuruta Apr 27, 2025
a75d952
models変更 マイグレーションし直し
sasakifuruta Apr 27, 2025
bff8aff
メッセージのCRUD処理動作確認OK
sasakifuruta Apr 28, 2025
214d9de
[add]管理者機能のユーザー管理(削除・凍結)や設定変更に対応したAPIエンドポイントを実装
ARISA1115 Apr 28, 2025
208b098
[add]Adminモデルにpin_codeフィールド、is_activeフラグを追加
ARISA1115 Apr 28, 2025
d4f6e99
[add]ユーザーのis_activeフラグを追加し、ユーザーの状態管理機能を実装
ARISA1115 Apr 28, 2025
8cac3f6
[add]adminルーターをAPIに追加し、管理者機能用のエンドポイントをルーティングに組み込み
ARISA1115 Apr 28, 2025
9db523e
[add] 管理者の登録・ログイン時に使用するPydanticスキーマを定義
ARISA1115 Apr 28, 2025
bced6dd
[add]認証関連のロジックを追加
ARISA1115 Apr 28, 2025
6abfb91
Merge pull request #9 from 2025SpringTeamA/api
sasakifuruta Apr 28, 2025
ca65344
Merge branch 'develop' of github.com:2025SpringTeamA/backend into fea…
sasakifuruta Apr 29, 2025
a9d4619
[fix]お気に入り登録処理をsession_idベースに修正
ARISA1115 Apr 30, 2025
c9002a6
Merge pull request #10 from 2025SpringTeamA/api
sasakifuruta Apr 30, 2025
f1587b4
Merge branch 'develop' of github.com:2025SpringTeamA/backend into fea…
sasakifuruta Apr 30, 2025
81ad95a
認証機能API確認完了
sasakifuruta May 3, 2025
b2ac7a8
全体のコード微修正
sasakifuruta May 3, 2025
aafa69a
Merge pull request #11 from 2025SpringTeamA/feature/chat-history
sasakifuruta May 3, 2025
9431692
alembic/versionsディレクトリの作成
free-honda May 3, 2025
8b8f12d
Update Makefile
sasakifuruta May 3, 2025
ecd61be
管理者ログイン途中
sasakifuruta May 3, 2025
e5a9c4c
AIキャラの返答生成と管理者操作の実装
sasakifuruta May 4, 2025
b764ee5
日記投稿と同時にSessionデータ新規作成
sasakifuruta May 6, 2025
02d5e3f
AIレスポンス返答 実装途中
sasakifuruta May 6, 2025
3768dc6
AWS Bedrock用のAI返答生成を実装
sasakifuruta May 8, 2025
d388e3d
Rename Dockerfile.prd to Dockerfile.prod
free-honda May 10, 2025
075dfee
Update Dockerfile.prod
free-honda May 10, 2025
cddcc75
Create dev.yml
free-honda May 10, 2025
9f9c5a0
日記投稿を1日1回に制限する
sasakifuruta May 11, 2025
dc69f2a
テスト部分をコメントアウト
sasakifuruta May 11, 2025
0b76469
Merge pull request #12 from 2025SpringTeamA/feature/chat-history
sasakifuruta May 11, 2025
6177c52
chore: 環境変数関連の設定を修正
free-honda May 11, 2025
97c8476
Merge pull request #13 from 2025SpringTeamA/env/update-env-settings
free-honda May 13, 2025
1413743
管理者画面の処理OK
sasakifuruta May 14, 2025
19a9e6b
履歴の削除動作確認OK
sasakifuruta May 15, 2025
c33862e
Merge pull request #14 from 2025SpringTeamA/feature/chat-history
sasakifuruta May 15, 2025
f97a5a4
不要な関数削除
sasakifuruta May 16, 2025
c40e45d
Merge pull request #15 from 2025SpringTeamA/feature/chat-history
sasakifuruta May 16, 2025
8f1d370
Amazon Bedrock以外の動作確認完了
sasakifuruta May 17, 2025
78b89b5
Amazon Bedrockの動作確認完了
sasakifuruta May 18, 2025
6d0acf3
不要なコードを削除
sasakifuruta May 24, 2025
0f9d0dc
Amazon Bedrock仕様に変更
sasakifuruta May 25, 2025
014b6ac
[fix]正しいパスで動作するように修正
ARISA1115 May 25, 2025
c3011f5
[fix]checkout パスを修正して requirements.txt を認識出来るように修正
ARISA1115 May 25, 2025
60d273d
[fix]Set up Pythonのパスを修正
ARISA1115 May 25, 2025
00e9ba5
[fix]checkout パスを backend に修正
ARISA1115 May 25, 2025
6c228b6
[fix]checkout path を修正
ARISA1115 May 25, 2025
ce40e7b
[fix]cache-dependencyとディレクトリ構造統一
ARISA1115 May 25, 2025
f004e85
[fix]requirements.txtのパスを修正
ARISA1115 May 25, 2025
7f47d4c
[fix]Dockerビルドのcontextパスを修正
ARISA1115 May 25, 2025
4760d78
[fix]artifact が存在しないエラーを修正
ARISA1115 May 25, 2025
9ec71ef
[fix]ターゲット名を修正
ARISA1115 May 25, 2025
3053edf
[fix]Terraform で出力された rds_endpoint をもとに DATABASE_URL を Secrets Manage…
ARISA1115 May 26, 2025
0349e7a
[fix]workflow_runトリガーでのアーティファクト取得制限によるエラーを回避
ARISA1115 May 26, 2025
dc911e8
[fix][fix] Dockerビルド時のcontextパスを修正
ARISA1115 May 26, 2025
a741a6b
[add]エラーハンドリングを追加
ARISA1115 May 26, 2025
5cea54e
[fix]Docker buildのtarget: api指定を削除
ARISA1115 May 26, 2025
40e708c
[fix]ECRリポジトリ名とマイグレーション用コンテナ名の不一致を修正
ARISA1115 May 26, 2025
971884d
[fix]ECSタスク定義のレンダリングを削除
ARISA1115 May 26, 2025
694e6d1
[fix]ECR push、Secrets Manager更新、DBマイグレーションの不具合を修正
ARISA1115 May 26, 2025
9d7d90a
[fix]COPY app ./appへ修正
ARISA1115 May 26, 2025
702c159
[fix]パスを修正
ARISA1115 May 26, 2025
43f5a72
[fix]パスを修正
ARISA1115 May 26, 2025
cf05931
[fix]RunTaskを削除
ARISA1115 May 28, 2025
24251b2
Update main.py
sasakifuruta May 31, 2025
37f4931
[add]ルートエンドポイントを追加し、404エラー解消
ARISA1115 Jun 1, 2025
c6c8e40
[fix]ECRプッシュのみに変更
ARISA1115 Jun 1, 2025
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
Binary file added .DS_Store
Binary file not shown.
48 changes: 48 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy FastAPI to ECR

on:
workflow_run:
workflows: ["Build and Test FastAPI Backend"]
types:
- completed
branches:
- main
workflow_dispatch:

jobs:
deploy-to-ecr:
name: Deploy to ECR
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'workflow_dispatch') || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main') }}
environment: production

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Log in to Amazon ECR
run: |
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} \
| docker login --username AWS --password-stdin \
$(aws sts get-caller-identity --query 'Account' --output text).dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com

- name: Build Docker image
run: |
docker build -t ${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG }} -f Dockerfile.prod .

- name: Tag Docker image
run: |
docker tag ${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG }} \
$(aws sts get-caller-identity --query 'Account' --output text).dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG }}

- name: Push Docker image to Amazon ECR
run: |
docker push \
$(aws sts get-caller-identity --query 'Account' --output text).dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG }}
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build and Test FastAPI Backend

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch:

jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: 'app/requirements.txt'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest flake8
pip install -r app/requirements.txt

- name: Lint with flake8
run: flake8 app/ --count --select=E9,F63,F7,F82 --show-source --statistics

- name: Test with pytest
working-directory: ./app
run: pytest || echo "No tests configured"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build API Docker image (local)
uses: docker/build-push-action@v5
with:
context: .
push: false
load: true
tags: saburo-api:local-test
cache-from: type=gha
cache-to: type=gha,mode=max
48 changes: 48 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Push to ECR

on:
push:
branches:
- develop
workflow_dispatch:

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
# リポジトリのクローン
- name: Checkout code
uses: actions/checkout@v3

# AWS CLI のセットアップ
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

# Dockerログイン
- name: Log in to Amazon ECR
run: |
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} \
| docker login --username AWS --password-stdin \
$(aws sts get-caller-identity --query 'Account' --output text).dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com

# Dockerイメージのビルド
- name: Build Docker image
run: |
docker build -t ${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG }} -f Dockerfile.prod .

# Dockerイメージのタグ付け
- name: Tag Docker image
run: |
docker tag ${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG }} \
$(aws sts get-caller-identity --query 'Account' --output text).dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG }}

# Dockerイメージのプッシュ
- name: Push Docker image to Amazon ECR
run: |
docker push \
$(aws sts get-caller-identity --query 'Account' --output text).dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

### Alembic ###
alembic/__pycache__/
alembic/versions/__pycache__/
# alembic/versions/__pycache__/

### Python ###
# Byte-compiled / optimized / DLL files
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ RUN apt-get update && \
COPY app/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY app/ .
COPY app ./app
ENV PYTHONPATH=/app

EXPOSE 8000

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
3 changes: 2 additions & 1 deletion Dockerfile.prd → Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ RUN pip install --no-cache-dir -r requirements.txt

# アプリケーション本体をすべてコンテナにコピー(app ディレクトリの中身を /app にコピー)
COPY app/ .
ENV PYTHONPATH=/app

# アプリケーションで使用するポートを開放(FastAPI や uvicorn のデフォルトに近い 8000 番を使用)
EXPOSE 8000

# コンテナ起動時に実行されるコマンドを指定(uvicorn で main.py 内の app を起動)
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "info"]
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "info"]
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,26 @@ logs:
docker compose logs

exec-app:
docker exec -it fastapi-app bash
docker compose exec -it web bash

exec-db:
docker exec -it mysql-db bash
docker compose exec -it db bash

db-shell:
docker compose exec -it db bash -c "mysql -u root -p"

down:
docker compose down

migrate:
docker compose exec fastapi-app sh -c "cd /app && alembic upgrade head"
docker compose exec -it web bash -c "cd /app && alembic upgrade head"

makemigration:
@read -p "Migration name: " name; \
docker compose exec fastapi-app sh -c "cd /app && alembic revision --autogenerate -m $$name"
docker compose exec -it web bash -c "cd /app && alembic revision --autogenerate -m $$name"

show:
docker compose exec fastapi-app sh -c "cd /app && alembic history"
docker compose exec -it web bash -c "cd /app && alembic history"

downgrade:
docker compose exec fastapi-app sh -c "cd /app && alembic downgrade -1"
docker compose exec -it web bash -c "cd /app && alembic downgrade -1"
17 changes: 17 additions & 0 deletions app/api/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from fastapi import APIRouter
from api.endpoints import auth, admin, user, session, message


router = APIRouter()


# 認証用エンドポイント
router.include_router(auth.router, tags=["Auth"])
# 管理者用エンドポイント
router.include_router(admin.router, tags=["Admin"])
# アカウント情報用エンドポイント
router.include_router(user.router, tags=["User"])
# チャット用エンドポイント
router.include_router(session.router, tags=["Session"])
# メッセージ用エンドポイント
router.include_router(message.router, tags=["Message"])
7 changes: 7 additions & 0 deletions app/api/deps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from sqlalchemy.orm import Session
from app.db.session import get_db
from fastapi import Depends

# データベースセッションを依存関係として注入する
def get_db_dependency(db: Session = Depends(get_db)):
return db
Loading