Implement Phase 1 backend: FastAPI upload API with MinIO and PostgreSQL

- Add FastAPI app with CORS and auth middleware (Bearer token)
- Add POST /api/v1/transactions/upload endpoint (multipart/form-data)
- Add MinIO storage service with date-partitioned object keys
- Add PostgreSQL database service for transaction metadata
- Add Dockerfile and docker-compose.yml for deployment
- Add config.example.yaml template

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-05-21 16:42:08 +08:00
parent a7ae5cba5d
commit e3c84540eb
16 changed files with 306 additions and 0 deletions

48
app/config.py Normal file
View File

@@ -0,0 +1,48 @@
from pathlib import Path
import yaml
from pydantic import BaseModel
class MinioConfig(BaseModel):
endpoint: str
bucket: str = "snapledger"
access_key: str
secret_key: str
class PostgresConfig(BaseModel):
host: str
port: int = 5432
database: str = "snapledger"
user: str
password: str
@property
def dsn(self) -> str:
return (
f"postgresql://{self.user}:{self.password}"
f"@{self.host}:{self.port}/{self.database}"
)
class ApiConfig(BaseModel):
token: str
class AppConfig(BaseModel):
minio: MinioConfig
postgresql: PostgresConfig
api: ApiConfig
def load_config(path: str = "config.yaml") -> AppConfig:
config_path = Path(path)
if not config_path.exists():
raise FileNotFoundError(f"Configuration file not found: {path}")
with open(config_path, encoding="utf-8") as f:
data = yaml.safe_load(f)
return AppConfig(**data)
settings = load_config()