Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
214 commits
Select commit Hold shift + click to select a range
f874d06
🏗️🏗️🏗️ basic route setup
Miyamura80 Sep 8, 2025
d47f770
Merge pull request #17 from Miyamura80/main
Miyamura80 Sep 8, 2025
cf9667d
Merge branch 'saas' of github.com:Miyamura80/Python-Template into saas
Miyamura80 Sep 8, 2025
9a70650
Merge pull request #20 from Miyamura80/main
Miyamura80 Sep 8, 2025
cf527c3
Merge branch 'saas' of github.com:Miyamura80/Python-Template into saas
Miyamura80 Sep 8, 2025
8d98702
🏗️ importing E2E tests
Miyamura80 Sep 8, 2025
4075837
🔨write script that updates railway env vars
Miyamura80 Sep 29, 2025
62a9861
⚙️add requests
Miyamura80 Sep 30, 2025
13b06ee
✨fmt
Miyamura80 Sep 30, 2025
954b223
✨fmt
Miyamura80 Sep 30, 2025
53a3f53
✨fmt
Miyamura80 Sep 30, 2025
1699491
✨fmt
Miyamura80 Sep 30, 2025
75824d2
📝create todo
Miyamura80 Sep 30, 2025
619ca8e
✨fmt
Miyamura80 Sep 30, 2025
43368c6
⚙️new packages
Miyamura80 Sep 30, 2025
a11f805
🔨stripe gitignore
Miyamura80 Sep 30, 2025
38ead82
🏗️stripe setup
Miyamura80 Sep 30, 2025
d13f925
🏗️E2E test base
Miyamura80 Sep 30, 2025
188ef04
🏗️🏗️🏗️ telegram to alert admin
Miyamura80 Sep 30, 2025
b274ccd
💽add user sub DB
Miyamura80 Oct 12, 2025
1d1f1e9
⚙️ add stripe to uv
Miyamura80 Oct 12, 2025
0708064
🏗️update global config
Miyamura80 Oct 12, 2025
3fd4fc0
🏗️🏗️ setup server.py and test_stripe
Miyamura80 Oct 12, 2025
169b95d
🔨fix __init__
Miyamura80 Oct 18, 2025
9693e21
✨fix vulture
Miyamura80 Oct 18, 2025
9eabb6c
🔨🔨🔨 implement workos setup
Miyamura80 Oct 19, 2025
7bebe90
🔨implement workos
Miyamura80 Oct 19, 2025
9a9a626
🐛fix vulture
Miyamura80 Oct 19, 2025
cf14839
🐛fix api routes
Miyamura80 Oct 19, 2025
11a153a
🔨test ping
Miyamura80 Oct 19, 2025
4ade886
📝cursorrules for routes
Miyamura80 Oct 19, 2025
be4afc0
🐛fix global config
Miyamura80 Oct 20, 2025
fc2c3d0
💽remove rls
Miyamura80 Oct 20, 2025
ce88ad7
✨fmt
Miyamura80 Oct 20, 2025
44d995c
✨fmt
Miyamura80 Oct 20, 2025
afcdfa7
📝docs for cursor rules for coding style
Miyamura80 Oct 20, 2025
df4b986
🏗️🏗️ add new agent route
Miyamura80 Oct 20, 2025
45a7911
🐛fix E2E test base
Miyamura80 Oct 20, 2025
620099e
📝adding todo
Miyamura80 Oct 20, 2025
b06dab4
🏗️add procfile
Miyamura80 Oct 20, 2025
2d3be76
🐛fix jwt package
Miyamura80 Oct 20, 2025
581f9f1
⚙️update dspy version
Miyamura80 Oct 20, 2025
6559307
🐛fix jwt issue
Miyamura80 Oct 20, 2025
50a92d1
🐛fix pydantic issues
Miyamura80 Oct 20, 2025
c6c5609
✨vulture
Miyamura80 Oct 20, 2025
836f393
✨fix vulture issues
Miyamura80 Oct 20, 2025
2ce1724
🔨remove DRY code
Miyamura80 Oct 20, 2025
3705444
✨🔨fix vulture
Miyamura80 Oct 20, 2025
0a279f6
✨✨ address vulture
Miyamura80 Oct 20, 2025
1c307da
✨fmt
Miyamura80 Oct 20, 2025
af19866
📝agent behaviour
Miyamura80 Oct 20, 2025
829a495
✨ruff
Miyamura80 Oct 20, 2025
db32cd3
🔨add server
Miyamura80 Oct 20, 2025
ece9a40
✅add streaming to dspy inference
Miyamura80 Oct 21, 2025
739092b
Add STRIPE_API_KEY to environment variables and organize TODOs
Miyamura80 Nov 26, 2025
429d2d1
Rename STRIPE_API_KEY to STRIPE_SECRET_KEY
Miyamura80 Nov 26, 2025
e771923
Fix WorkOS JWT authentication: Add PyJWKClientError exception handling
Miyamura80 Nov 26, 2025
1a56d3e
railway mcp
Miyamura80 Nov 26, 2025
fdf180b
Add user_subscriptions table and missing foreign key constraints
Miyamura80 Nov 26, 2025
25eaef3
Fix WorkOS authentication for tests
Miyamura80 Nov 26, 2025
422cf7c
Add message deletion to Telegram tests and refactor test helpers
Miyamura80 Nov 26, 2025
edddb5a
Fix message deletion to delete all test messages
Miyamura80 Nov 26, 2025
427b5fb
todo update
Miyamura80 Nov 26, 2025
429a0df
TODO.md update
Miyamura80 Nov 26, 2025
9a8bc86
✨fix vulture warnings
Miyamura80 Dec 2, 2025
7cf71fd
✨fix type checker issues
Miyamura80 Dec 3, 2025
7c4c9ab
✨fix typing
Miyamura80 Dec 3, 2025
14a7589
🐛fix dspy streaming
Miyamura80 Dec 3, 2025
6218a8b
🏗️add subscription
Miyamura80 Dec 4, 2025
d96f62e
✨fix vulture
Miyamura80 Dec 4, 2025
66c2893
✨fmt
Miyamura80 Dec 4, 2025
dac35a8
✨clear railway
Miyamura80 Dec 5, 2025
2afe640
💽update subscription DB to update pricing
Miyamura80 Dec 5, 2025
87182cb
🏗️🏗️🏗️ stripe usage based billing impl
Miyamura80 Dec 5, 2025
ea03ca9
🐛fix global config to contain stripe
Miyamura80 Dec 5, 2025
910f574
🐛fix stripe tests
Miyamura80 Dec 5, 2025
396a286
✨ruff
Miyamura80 Dec 5, 2025
0588ba6
🐛🐛 bugfixes - stripe, prod webhooks, db handling
Miyamura80 Dec 5, 2025
94fcf86
🔨🔨 update webhook creation scripts
Miyamura80 Dec 5, 2025
94d456b
🔨implement session key for server.py
Miyamura80 Dec 6, 2025
e5aebea
🏗️🏗️ uses railway DB to avoid egress fees
Miyamura80 Dec 6, 2025
564f252
🐛implement todo
Miyamura80 Dec 6, 2025
1df5f96
✅Fix agent streaming with tool calls.
Miyamura80 Dec 6, 2025
de3edb0
Add API key authentication and schema
Miyamura80 Dec 6, 2025
671a2e9
📝 add api auth
Miyamura80 Dec 6, 2025
73db480
✅Add WorkOS access-token issuer
Miyamura80 Dec 6, 2025
d01a2d5
🐛bugfix prefix
Miyamura80 Dec 6, 2025
909e713
🐛fix workos_auth
Miyamura80 Dec 6, 2025
6b9c500
📝docs workos
Miyamura80 Dec 6, 2025
45241d0
use groq gpt oss
Miyamura80 Dec 6, 2025
683db9a
add cerbras support
Miyamura80 Dec 6, 2025
fd5e157
🐛fix api base
Miyamura80 Dec 6, 2025
681040f
✨fmt
Miyamura80 Dec 6, 2025
7114c81
🐛fix vulture
Miyamura80 Dec 6, 2025
6cca614
💽add agent conversation
Miyamura80 Dec 6, 2025
2ccd36a
✅implement agent route
Miyamura80 Dec 6, 2025
bf28121
🐛fix uuid
Miyamura80 Dec 6, 2025
4930bde
📝update docs
Miyamura80 Dec 6, 2025
8facf66
🐛db uri resolver
Miyamura80 Dec 6, 2025
2ec9541
🐛fix make ci
Miyamura80 Dec 6, 2025
1b08a26
move agent history to different endpoint
Miyamura80 Dec 6, 2025
b82034c
✅✅ add subscription limits
Miyamura80 Dec 6, 2025
9e04e98
🐛fix chat history not accumulating agent response
Miyamura80 Dec 6, 2025
33566b0
📝📝📝 add documentation
Miyamura80 Dec 6, 2025
df19c99
🔨🔨 code uses db_transaction
Miyamura80 Dec 6, 2025
03e3be9
fix rate limit issue
Miyamura80 Dec 6, 2025
2909874
⚙️litellm bump
Miyamura80 Dec 7, 2025
78d0bf3
✨ add agent chat history management with configurable message limit
Miyamura80 Dec 7, 2025
2b7217e
🔧 improve agent chat history management with enhanced message limit c…
Miyamura80 Dec 7, 2025
cef669b
🔨🐛 add WorkOS API client integration to fetch user details when email…
Miyamura80 Dec 7, 2025
2a65e37
✨fmt
Miyamura80 Dec 7, 2025
4cca4e9
🔍 enhance logging for user authentication with detailed request infor…
Miyamura80 Dec 8, 2025
3e7bfdc
✨ enhance agent conversation structure with new payload models and up…
Miyamura80 Dec 11, 2025
8eba6f5
✨ update dependency versions and enhance chat history models with imp…
Miyamura80 Dec 11, 2025
b827658
🔧 improve subscription webhook handling by ensuring user_id is valida…
Miyamura80 Dec 11, 2025
ec8b4f9
🔧 refactor payment routes to consistently use user_uuid for database …
Miyamura80 Dec 11, 2025
ff5dd41
update agent.py
Miyamura80 Dec 11, 2025
2230f86
✨ enhance checkout process by updating local subscription records and…
Miyamura80 Dec 11, 2025
7564afc
🔧 update webhook endpoint to use environment-specific Stripe API keys…
Miyamura80 Dec 11, 2025
a6482eb
🔧 update webhook handling to improve error logging and ensure consist…
Miyamura80 Dec 11, 2025
41e36ab
✨ add profile existence check in checkout and webhook handlers to ens…
Miyamura80 Dec 11, 2025
266f8d4
📝 commit message update
Miyamura80 Dec 11, 2025
06385f5
📝edit commit msg cursorrule
Miyamura80 Dec 11, 2025
40e5657
🔧 refactor logging levels in agent and limit handling for improved cl…
Miyamura80 Dec 11, 2025
c10f38c
🔧 fix type casting in daily limits test and ensure user ID is correct…
Miyamura80 Dec 11, 2025
f48c223
✨fix CI
Miyamura80 Dec 11, 2025
1428a51
✨ add fast and cheap model configurations to global_config.yaml
Miyamura80 Dec 12, 2025
c4a45b0
📝 update documentation to clarify commit message rules and include sp…
Miyamura80 Dec 12, 2025
9cd7877
📝 update documentation to specify that cursor rules include `.mdc` files
Miyamura80 Dec 12, 2025
9785e8c
📝 add agent route system prompt documentation for LLM interaction gui…
Miyamura80 Dec 12, 2025
5f050ae
📝 add frontend chat side panel specifications to documentation
Miyamura80 Dec 12, 2025
77dcdde
📝 remove redundant lines from commit message rules in `.mdc` file
Miyamura80 Dec 12, 2025
803c615
📝 update README to enhance configuration management section and impro…
Miyamura80 Dec 12, 2025
80c1862
🔧 refactor DSPYInference constructor to handle None for tools paramet…
Miyamura80 Dec 12, 2025
7515b31
🔧 refactor LangFuseDSPYCallback to improve error handling and add too…
Miyamura80 Dec 12, 2025
0bf8c43
✨ add utils and LLM utilities packages for enhanced functionality
Miyamura80 Dec 12, 2025
9431516
🔧 update dependencies in pyproject.toml to include pydantic-settings …
Miyamura80 Dec 12, 2025
5a0219c
📝 add missing newline at the end of utils package and LLM utilities p…
Miyamura80 Dec 12, 2025
0c0cf66
✅ add Pydantic models for global configuration and enhance global_con…
Miyamura80 Dec 12, 2025
df23356
📝 update commit message rules in `.mdc` file to clarify feature chang…
Miyamura80 Dec 12, 2025
c4deafe
🔧 refactor generate_banner.py to use pathlib for media directory mana…
Miyamura80 Dec 12, 2025
6982cc9
🔧 refactor _should_log_level function to handle None for overrides pa…
Miyamura80 Dec 12, 2025
ca31ceb
📝 update health check test documentation to clarify configuration loa…
Miyamura80 Dec 12, 2025
1c6a677
✨ refactor LangFuseDSPYCallback to enhance code readability by standa…
Miyamura80 Dec 12, 2025
f3c0905
📝 update AGENTS.md to clarify environment variable setup and enhance …
Miyamura80 Dec 12, 2025
1b19af4
✨ add GitHub Actions workflow for automatic deletion of merged branch…
Miyamura80 Dec 12, 2025
5fa3ff0
📝 update logging.mdc to include validation details for logging config…
Miyamura80 Dec 12, 2025
6454985
📝 update common.mdc to enhance global configuration documentation wit…
Miyamura80 Dec 12, 2025
f543f2e
🔧 remove unused langfuse decorators from agent history endpoint to st…
Miyamura80 Dec 12, 2025
28fc3d2
✨ implement flexible authentication in unified_auth.py, introducing A…
Miyamura80 Dec 12, 2025
bf79ebe
🔨 enhance agent streaming functionality by integrating LangFuse traci…
Miyamura80 Dec 12, 2025
2336bc1
🔧 add type ignore comments to global_config instantiation and test fo…
Miyamura80 Dec 12, 2025
dd7427d
🔧 refactor DSPYInference and LangFuseDSPYCallback to remove unused @o…
Miyamura80 Dec 12, 2025
53ad8d9
🐛fix tool call name getting erased
Miyamura80 Dec 13, 2025
db493a0
🔧 refactor global_config and db_transaction to improve parameter nami…
Miyamura80 Dec 13, 2025
bfd9ab3
🔧 refactor alert_admin function to replace UUID generation with user_…
Miyamura80 Dec 13, 2025
3195435
🔧 modify tool wrapper docstring to remove user_id parameter documenta…
Miyamura80 Dec 13, 2025
79796a9
🐛 fix pydantic-settings parameter name causing Railway deployment fai…
Miyamura80 Dec 13, 2025
cf7db6d
🔧 enhance alert_admin function to escape special characters for Markd…
Miyamura80 Dec 13, 2025
ab88a3d
🔧 modify tool wrapper docstring to streamline user_id parameter remov…
Miyamura80 Dec 13, 2025
5b0eb57
🐛 Fix foreign key violation when syncing subscription status: ensure …
Miyamura80 Dec 13, 2025
c666cf6
🔧🔧 enhance Procfile with timeout settings for graceful shutdown; upda…
Miyamura80 Dec 13, 2025
d379931
🔧 update global_config.yaml to switch default LLM model to Gemini 2.5…
Miyamura80 Dec 13, 2025
c919036
🔧 Refactor agent_stream_endpoint and DSPYInference to improve logging…
Miyamura80 Dec 13, 2025
29dbe1a
🔧 update global_config.yaml to disable debug logging by default, enha…
Miyamura80 Dec 13, 2025
cc723ee
⚙️ Update DSPy 3.0.3 → 3.0.4 (streaming improvements)
Miyamura80 Dec 17, 2025
635e265
🐛 Fix nonlocal last_activity_time in stream_with_inference()
Miyamura80 Dec 17, 2025
96ab16a
✨fmt
Miyamura80 Dec 17, 2025
6b9e306
✨fix ty
Miyamura80 Dec 17, 2025
f6a7873
🔧 Add current_tool_call_id context variable to LangFuseDSPYCallback f…
Miyamura80 Dec 17, 2025
2ebc90b
🔧 Refactor DSPYInference to utilize LiteLLM's built-in retry mechanis…
Miyamura80 Dec 20, 2025
2fb6663
✨fmt
Miyamura80 Dec 20, 2025
09f31c8
fix: resolve type errors and fixture naming collision in e2e tests
Miyamura80 Dec 20, 2025
afc4205
Refactor agent streaming to use worker thread and tool callbacks
cursoragent Dec 20, 2025
21828b4
Merge pull request #45 from Miyamura80/cursor/agent-tool-execution-st…
Miyamura80 Dec 20, 2025
7b81c6d
📝update TODO
Miyamura80 Dec 25, 2025
2b34c3f
Merge branch 'saas' of github.com:Miyamura80/Python-Template into saas
Miyamura80 Dec 26, 2025
33d4b72
📝 Update AGENTS.md with Cursor rules
google-labs-jules[bot] Dec 26, 2025
05e9ca8
fix(alert_admin): add missing status key to error responses
google-labs-jules[bot] Dec 26, 2025
c2a5c11
📝 Restore comment in AGENTS.md
google-labs-jules[bot] Dec 26, 2025
ef18840
📝 Update AGENTS.md based on PR feedback
google-labs-jules[bot] Dec 26, 2025
b35d5e5
Merge pull request #53 from Miyamura80/fix-alert-admin-keyerror-17017…
Miyamura80 Dec 26, 2025
d87f567
Merge pull request #52 from Miyamura80/update-agents-md-cursor-rules-…
Miyamura80 Dec 26, 2025
05c2016
feat(payments): auto-downgrade on payment failure
google-labs-jules[bot] Dec 26, 2025
85d5e18
feat: Add referral system
google-labs-jules[bot] Dec 26, 2025
bb37fdc
feat(payments): auto-downgrade on payment failure
google-labs-jules[bot] Dec 26, 2025
436f5d4
📝update TODO.md
Miyamura80 Dec 26, 2025
4ca0566
Merge pull request #54 from Miyamura80/feature/stripe-auto-downgrade-…
Miyamura80 Dec 26, 2025
a31f3ec
feat: Add referral system
google-labs-jules[bot] Dec 26, 2025
1980bd8
feat: Add referral system with lazy code generation
google-labs-jules[bot] Dec 26, 2025
ecb1e4c
Merge branch 'saas' of github.com:Miyamura80/Python-Template into saas
Miyamura80 Dec 26, 2025
f4d26a7
feat: Add referral system with lazy code generation
google-labs-jules[bot] Dec 26, 2025
7238f9e
feat: Include user email in admin alert logs
google-labs-jules[bot] Dec 26, 2025
9dcb1fa
Merge pull request #56 from Miyamura80/update-alert-msg-7871813697673…
Miyamura80 Dec 26, 2025
f55424a
feat: Add referral system with lazy code generation
google-labs-jules[bot] Dec 26, 2025
4795549
feat: Add referral system with lazy code generation
google-labs-jules[bot] Dec 26, 2025
9b701e4
Update src/api/services/referral_service.py
Miyamura80 Dec 26, 2025
748853f
feat: Add referral system with lazy code generation
google-labs-jules[bot] Dec 26, 2025
97a98df
Update src/db/utils/users.py
Miyamura80 Dec 26, 2025
0be240f
refactor: Rely on unique constraint for referral code generation
google-labs-jules[bot] Dec 26, 2025
6672338
fix: Use db_transaction in apply_referral
google-labs-jules[bot] Dec 26, 2025
594ec32
Update src/db/utils/users.py
Miyamura80 Dec 26, 2025
d321480
Update src/db/utils/users.py
Miyamura80 Dec 26, 2025
19e1a68
feat: Add referral system with lazy code generation
google-labs-jules[bot] Dec 26, 2025
f181820
Apply suggestion from @greptile-apps[bot]
Miyamura80 Dec 27, 2025
6fac01b
Apply suggestions from code review
Miyamura80 Dec 27, 2025
5892aa5
fix: Use atomic update for referral count
google-labs-jules[bot] Dec 27, 2025
2563c4d
Merge pull request #55 from Miyamura80/feature/referral-system-655505…
Miyamura80 Dec 27, 2025
e993557
feat(agent): add /agent/limits endpoint for usage tracking
google-labs-jules[bot] Dec 27, 2025
49574aa
feat(agent): add /agent/limits endpoint for usage tracking
google-labs-jules[bot] Dec 27, 2025
7e2e8b3
Merge pull request #58 from Miyamura80/agent-limits-endpoint-38549211…
Miyamura80 Dec 27, 2025
409dbda
🔒 Fix critical auth vulnerability and improve observability
google-labs-jules[bot] Dec 27, 2025
636c000
Merge pull request #60 from Miyamura80/critical-fixes-security-observ…
Miyamura80 Dec 27, 2025
fbc977a
🔨 Merge saas branch: add SaaS infrastructure (DB, auth, payments, str…
claude Mar 14, 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
3 changes: 3 additions & 0 deletions .cursor/mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mcpServers": {}
}
6 changes: 6 additions & 0 deletions .cursor/rules/railway.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
description: Railway.app is the service we use for production environments
globs:
alwaysApply: false
---
The build container system deletes any .md files, so if you need prompts, always use a .txt file
92 changes: 92 additions & 0 deletions .cursor/rules/routes.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
globs: src/api/routes/**
alwaysApply: false
---
# API Routes

All routes are automatically registered through `src/api/routes/__init__.py` → `server.py`.

## Quick Start: Adding a New Route

### 1. Create Route Module (e.g., `src/api/routes/my_feature.py`)

```python
"""My Feature Route - description"""

from fastapi import APIRouter
from pydantic import BaseModel

router = APIRouter()

class MyResponse(BaseModel):
"""Response model."""
message: str
data: dict

@router.get("/my-feature", response_model=MyResponse)
async def my_feature() -> MyResponse:
"""Endpoint description."""
return MyResponse(message="success", data={"key": "value"})
```

### 2. Register in `src/api/routes/__init__.py`

```python
from .ping import router as ping_router
from .my_feature import router as my_feature_router # Add import

all_routers = [
ping_router,
my_feature_router, # Add to list
]

__all__ = ["all_routers", "ping_router", "my_feature_router"] # Add to exports
```

### 3. Write Tests in `tests/e2e/test_my_feature.py`

```python
"""E2E tests for my feature endpoint"""
from tests.e2e.e2e_test_base import E2ETestBase

class TestMyFeature(E2ETestBase):
"""Tests for my feature endpoint"""

def test_my_feature_endpoint(self):
"""Test that endpoint works"""
response = self.client.get("/my-feature")
assert response.status_code == 200
assert response.json()["message"] == "success"
```

## Authentication

For protected endpoints:

```python
from fastapi import Request, Depends
from sqlalchemy.orm import Session
from src.api.auth.unified_auth import get_authenticated_user_id
from src.db.database import get_db_session

@router.get("/protected")
async def protected(request: Request, db: Session = Depends(get_db_session)):
user_id = await get_authenticated_user_id(request, db) # Validates WorkOS JWT
return {"user_id": user_id}
```

## Subdirectory Routes

For routes in subdirectories (e.g., `src/api/routes/payments/checkout.py`):

```python
# src/api/routes/payments/__init__.py
from .checkout import router as checkout_router
__all__ = ["checkout_router"]

# src/api/routes/__init__.py
from .payments import checkout_router
all_routers = [ping_router, checkout_router]
```

## Reference: See `src/api/routes/ping.py` and `tests/e2e/test_ping.py` for complete examples
61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ ralph: check_jq ## Run Ralph agent loop
@echo "$(GREEN)✅ Ralph Agent finished.$(RESET)"


########################################################
# Run Server
########################################################

server: check_uv ## Start the server with uvicorn
@echo "$(GREEN)🚀Starting server...$(RESET)"
@PYTHONWARNINGS="ignore::DeprecationWarning:pydantic" uv run uvicorn src.server:app --host 0.0.0.0 --port $${PORT:-8000}
@echo "$(GREEN)✅Server stopped.$(RESET)"


########################################################
# Run Tests
########################################################
Expand Down Expand Up @@ -259,3 +269,54 @@ requirements:
@echo "$(YELLOW)🔍Checking requirements...$(RESET)"
@cp requirements-dev.lock requirements.txt
@echo "$(GREEN)✅Requirements checked.$(RESET)"

########################################################
# Database & Migrations
########################################################

db_test: check_uv ## Test database connection and validate it's remote
@echo "$(YELLOW)🔍Testing database connection...$(RESET)"
@uv run python -c "from common import global_config; from urllib.parse import urlparse; \
db_uri = str(global_config.database_uri); \
assert db_uri, f'Invalid database: {db_uri}'; \
parsed = urlparse(db_uri); \
host = parsed.hostname or 'Unknown'; \
print(f'✅ Remote database configured: {host}')"
@uv run alembic current >/dev/null 2>&1 && echo "$(GREEN)✅Database connection successful$(RESET)" || echo "$(RED)❌Database connection failed$(RESET)"

db_migrate: check_uv ## Run pending database migrations
@echo "$(YELLOW)🔄Running database migrations...$(RESET)"
@uv run alembic upgrade head
@echo "$(GREEN)✅Database migrations completed.$(RESET)"

db_validate: check_uv ## Validate database models and dependencies before migration
@echo "$(YELLOW)🔍Validating database models and dependencies...$(RESET)"
@uv run python scripts/validate_models.py
@echo "$(GREEN)✅Database validation completed.$(RESET)"

db_migration: check_uv db_validate ## Create new database migration (requires msg='message')
@echo "$(YELLOW)📝Creating new migration...$(RESET)"
@if [ -z '$(msg)' ]; then \
echo "$(RED)❌ Please provide a message: make db_migration msg='your migration message'$(RESET)"; \
exit 1; \
fi
@uv run alembic revision --autogenerate -m '$(msg)'
@echo "$(GREEN)✅Migration created successfully.$(RESET)"

db_downgrade: check_uv ## Downgrade database by one revision
@echo "$(YELLOW)⬇️ Downgrading database by 1 revision...$(RESET)"
@uv run alembic downgrade -1
@echo "$(GREEN)✅Database downgraded.$(RESET)"

db_status: check_uv ## Show database migration status
@echo "$(YELLOW)📊Checking database migration status...$(RESET)"
@uv run alembic current
@uv run alembic history --verbose
@echo "$(GREEN)✅Database status check completed.$(RESET)"

db_reset: check_uv ## Reset database (WARNING: destructive operation)
@echo "$(RED)🗑️ WARNING: This will drop all database tables!$(RESET)"
@read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1
@uv run alembic downgrade base
@uv run alembic upgrade head
@echo "$(GREEN)✅Database reset completed.$(RESET)"
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: PYTHONWARNINGS="ignore::DeprecationWarning:pydantic" uvicorn src.server:app --host 0.0.0.0 --port $PORT --timeout-keep-alive 300 --timeout-graceful-shutdown 30
Loading
Loading