Skip to content

Commit 2a577c8

Browse files
ImTotemclaude
andcommitted
refactor: move shared modules to core/, delete legacy code
Move to core/: config.py, database.py, repository.py, tables.py, id_gen.py, timezone.py, slack_log.py → core/ Delete legacy (unused): sheets/ — Google Sheets client + migrations (PG is sole DB) sync/ — Sheets→PG seed script (initial migration done) permission.py — replaced by SpiceDB authz tests/test_sheets_delete.py — tested deleted module Remove from deploy.sh: Sheets→PG seed step (no longer exists) Update all imports across 15+ files. 20 tests passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9e3ed2a commit 2a577c8

38 files changed

+40
-495
lines changed

alembic/env.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
from alembic import context
77

8-
from bcsd_api.config import Settings
9-
from bcsd_api.database import metadata
10-
import bcsd_api.tables # noqa: F401 — registers tables on metadata
8+
from bcsd_api.core.config import Settings
9+
from bcsd_api.core.database import metadata
10+
import bcsd_api.core.tables # noqa: F401 — registers tables on metadata
1111

1212
config = context.config
1313

infra/scripts/deploy.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,10 @@ $COMPOSE build "api-${NEXT}"
8888
echo "3. Running DB migrations..."
8989
$COMPOSE run --rm --no-deps "api-${NEXT}" alembic upgrade head
9090

91-
echo "4. Seeding PG from Sheets (if empty)..."
92-
$COMPOSE run --rm --no-deps "api-${NEXT}" python -m bcsd_api.sync.seed
93-
94-
echo "5. Starting $NEXT..."
91+
echo "4. Starting $NEXT..."
9592
$COMPOSE up -d --remove-orphans "api-${NEXT}"
9693

97-
echo "6. Health check on api-${NEXT}..."
94+
echo "5. Health check on api-${NEXT}..."
9895
if ! health_check "$NEXT"; then
9996
echo "FAIL: $NEXT did not become healthy"
10097
echo "--- Container logs ---"
@@ -104,17 +101,17 @@ if ! health_check "$NEXT"; then
104101
exit 1
105102
fi
106103

107-
echo "7. Switching nginx → $NEXT"
104+
echo "6. Switching nginx → $NEXT"
108105
sed -i "s/proxy_pass http:\/\/api_${CURRENT}/proxy_pass http:\/\/api_${NEXT}/g" "$NGINX_CONF"
109106
sudo mkdir -p /var/www/certbot
110107
sudo cp "$NGINX_CONF" "$NGINX_AVAILABLE"
111108
sudo ln -sf "$NGINX_AVAILABLE" "$NGINX_ENABLED"
112109
sudo nginx -t && sudo nginx -s reload
113110

114-
echo "8. Stopping old ($CURRENT)..."
111+
echo "7. Stopping old ($CURRENT)..."
115112
$COMPOSE stop "api-${CURRENT}"
116113

117-
echo "9. Initializing n8n..."
114+
echo "8. Initializing n8n..."
118115
bash infra/scripts/init_n8n.sh
119116

120117
echo "=== Deploy complete: $NEXT is live ==="

src/bcsd_api/apply/pg_repository.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from sqlalchemy import Connection, insert, select, update
22

3-
from bcsd_api.repository import BaseRepository
4-
from bcsd_api.tables import application_answers, applications
3+
from bcsd_api.core.repository import BaseRepository
4+
from bcsd_api.core.tables import application_answers, applications
55

66

77
class PgApplicationRepository(BaseRepository):

src/bcsd_api/apply/service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
from bcsd_api.exception import BadRequest, Conflict, Forbidden, NotFound
55
from bcsd_api.form.pg_repository import PgFormRepository, PgQuestionRepository
6-
from bcsd_api.id_gen import generate_id
6+
from bcsd_api.core.id_gen import generate_id
77
from bcsd_api.member.pg_repository import PgMemberRepository
88
from bcsd_api.setting.pg_repository import PgSettingRepository
9-
from bcsd_api.timezone import KST
9+
from bcsd_api.core.timezone import KST
1010

1111
from .pg_repository import PgAnswerRepository, PgApplicationRepository
1212
from .schema import (

src/bcsd_api/auth/router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from fastapi import APIRouter, Depends, Response
22
from sqlalchemy import Connection
33

4-
from bcsd_api.config import Settings
4+
from bcsd_api.core.config import Settings
55
from bcsd_api.dependencies import (
66
current_user, get_conn, get_email_sender, get_member_repo, get_settings,
77
)

src/bcsd_api/auth/service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
from sqlalchemy import Connection, select
44

5-
from bcsd_api.config import Settings
5+
from bcsd_api.core.config import Settings
66
from bcsd_api.email.sender import EmailSender
77
from bcsd_api.exception import Conflict, Unauthorized
8-
from bcsd_api.id_gen import generate_id
8+
from bcsd_api.core.id_gen import generate_id
99
from bcsd_api.member.pg_repository import PgMemberRepository
10-
from bcsd_api.tables import app_settings
11-
from bcsd_api.timezone import KST
10+
from bcsd_api.core.tables import app_settings
11+
from bcsd_api.core.timezone import KST
1212

1313
from . import google as google_auth
1414
from . import token as jwt_token

0 commit comments

Comments
 (0)