feat(api): add backend
routes and WebSockets
This commit is contained in:
9
services/api/app/schemas/audio.py
Normal file
9
services/api/app/schemas/audio.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class AudioPoint(BaseModel):
|
||||
time: datetime
|
||||
rms_db: float
|
||||
frequency_hz: int
|
||||
is_silence: bool
|
||||
19
services/api/app/schemas/base.py
Normal file
19
services/api/app/schemas/base.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Generic, TypeVar
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
class ApiError(BaseModel):
|
||||
code: str = Field(..., examples=["validation_error", "db_error"])
|
||||
message: str
|
||||
details: dict | None = None
|
||||
|
||||
|
||||
class ApiResponse(BaseModel, Generic[T]):
|
||||
success: bool = True
|
||||
errors: list[ApiError] | None = None
|
||||
count: int | None = None
|
||||
data: T | None = None
|
||||
9
services/api/app/schemas/events.py
Normal file
9
services/api/app/schemas/events.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class LoudEvent(BaseModel):
|
||||
time: datetime
|
||||
rms_db: float
|
||||
frequency_hz: int
|
||||
duration_sec: float | None = None
|
||||
8
services/api/app/schemas/stats.py
Normal file
8
services/api/app/schemas/stats.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class StatsSummary(BaseModel):
|
||||
avg_db: float
|
||||
max_db: float
|
||||
dominant_freq: int
|
||||
silence_percent: float
|
||||
Reference in New Issue
Block a user