Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,12 @@ NEXT_PUBLIC_PLAUSIBLE_HOST=https://plausible.io

# Python Microservice
# ------------------------------------------------------------------------------------
ENGINE_BASE_URL=http://localhost:8000
ENGINE_BASE_URL=http://localhost:8000

# Frontend URL for CORS
FRONTEND_URL=http://localhost:3000

# Optional: API authentication
API_SECRET_KEY=VSbk6svpu3uwhU9e

SENTRY_DSN=https://xxx.ingest.de.sentry.io/
6 changes: 5 additions & 1 deletion engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This service provides a simple health check endpoint and can be extended with ad
- **UV Dependency Management**: Fast, reliable Python package management
- **Auto Scaling**: Scales to zero when not in use on Fly.io
- **Docker Support**: Containerized for easy deployment
- **Sentry Integration**: Error tracking and performance monitoring with FastAPI integration

## File Structure

Expand Down Expand Up @@ -179,6 +180,7 @@ Quick deploy:

```bash
fly launch
fly secrets set SENTRY_DSN=<your-sentry-dsn>
fly secrets set FRONTEND_URL=https://your-app.vercel.app
fly deploy
```
Expand All @@ -194,7 +196,9 @@ fly deploy
## Environment Variables

```bash
PORT=8000 # Optional, defaults to 8000
PORT=8000 # Optional, defaults to 8000
SENTRY_DSN=<your-dsn> # Optional, enables error tracking when set
ENVIRONMENT=development # development, staging, or production
```

## Future Enhancements
Expand Down
1 change: 1 addition & 0 deletions engine/fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ primary_region = 'fra'

[env]
PORT = '8000'
ENVIRONMENT = 'production'

[http_service]
internal_port = 8000
Expand Down
19 changes: 19 additions & 0 deletions engine/main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
import os
from datetime import UTC
from datetime import datetime

import sentry_sdk
from dotenv import load_dotenv
from fastapi import FastAPI
from sentry_sdk.integrations.fastapi import FastApiIntegration

from models import HealthResponse

load_dotenv()

# Initialize Sentry with FastAPI integration
sentry_dsn = os.getenv("SENTRY_DSN")
if sentry_dsn:
sentry_sdk.init(
dsn=sentry_dsn,
environment=os.getenv("ENVIRONMENT", "development"),
traces_sample_rate=0.1,
profiles_sample_rate=0.1,
enable_tracing=True,
integrations=[
FastApiIntegration(
transaction_style="endpoint",
),
],
)

app = FastAPI(
title="Engine Service", description="Core engine service for Kosuke Template", version="1.0.0"
)
Expand Down
1 change: 1 addition & 0 deletions engine/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies = [
"uvicorn==0.34.0",
"pydantic==2.10.6",
"python-dotenv==1.0.1",
"sentry-sdk[fastapi]==2.19.2",
]

[project.optional-dependencies]
Expand Down
29 changes: 29 additions & 0 deletions engine/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.