feat: Initialize FastAPI application with Azure authentication and transaction management

- Added .env.example for environment variable configuration.
- Created app initialization files and core settings management.
- Implemented API routers for reporting and transaction endpoints.
- Developed transaction management service with CRUD operations.
- Integrated Azure OAuth for user authentication.
- Designed dashboard view with transaction filtering and display.
- Added Swagger UI documentation with custom dark theme.
- Created static and template files for frontend styling and layout.
This commit is contained in:
2026-05-10 22:17:30 +12:00
parent e86513d5ea
commit d50c1c5bba
26 changed files with 800 additions and 182 deletions
+3
View File
@@ -0,0 +1,3 @@
from app.core.app_factory import create_app
__all__ = ["create_app"]
+40
View File
@@ -0,0 +1,40 @@
from pathlib import Path
from fastapi import FastAPI
from starlette.middleware.sessions import SessionMiddleware
from fastapi.staticfiles import StaticFiles
from app.api.reporting import router as reporting_router
from app.api.transactions import router as transactions_router
from app.core.settings import get_settings
from app.views.auth import router as auth_router
from app.views.dashboard import router as dashboard_router
from app.views.docs import router as docs_router
def create_app() -> FastAPI:
settings = get_settings()
app = FastAPI(
title="Recon Ranger",
description="Financial crime reconciliation API — patrol your data landscape for inconsistencies.",
version="0.1.0",
docs_url=None,
)
app.add_middleware(
SessionMiddleware,
secret_key=settings.session_secret_key,
same_site="lax",
https_only=False,
)
project_root = Path(__file__).resolve().parents[2]
static_dir = project_root / "data" / "static"
app.mount("/static", StaticFiles(directory=str(static_dir)), name="static")
app.include_router(transactions_router)
app.include_router(reporting_router)
app.include_router(auth_router)
app.include_router(dashboard_router)
app.include_router(docs_router)
return app
+22
View File
@@ -0,0 +1,22 @@
from functools import lru_cache
from authlib.integrations.starlette_client import OAuth
from app.core.settings import get_settings
@lru_cache
def get_oauth() -> OAuth:
settings = get_settings()
oauth = OAuth()
oauth.register(
name="azure",
client_id=settings.azure_client_id,
client_secret=settings.azure_client_secret,
server_metadata_url=(
f"https://login.microsoftonline.com/{settings.azure_tenant_id}"
"/v2.0/.well-known/openid-configuration"
),
client_kwargs={"scope": "openid profile email"},
)
return oauth
+26
View File
@@ -0,0 +1,26 @@
from functools import lru_cache
from os import getenv
from pathlib import Path
from dotenv import load_dotenv
PROJECT_ROOT = Path(__file__).resolve().parents[2]
load_dotenv(PROJECT_ROOT / ".env")
class Settings:
def __init__(self) -> None:
self.session_secret_key = getenv("SESSION_SECRET_KEY", "change-me-in-production")
self.azure_tenant_id = getenv("AZURE_TENANT_ID")
self.azure_client_id = getenv("AZURE_CLIENT_ID")
self.azure_client_secret = getenv("AZURE_CLIENT_SECRET")
@property
def azure_configured(self) -> bool:
return bool(self.azure_tenant_id and self.azure_client_id and self.azure_client_secret)
@lru_cache
def get_settings() -> Settings:
return Settings()