feat: initial commit — HermesMessages SaaS platform
Backend (FastAPI + Python 3.12): - Multi-tenant auth with JWT: login, register, refresh, Meta OAuth - Business & BusinessConfig management - WhatsApp webhook with HMAC signature verification - Bot engine powered by Claude AI - Calendar availability with Redis caching - Reservations CRUD with status management - Dashboard analytics (stats, agenda, peak hours) - Billing & plan management - Admin panel with platform-wide stats - Async bcrypt via asyncio.to_thread - IntegrityError handling for concurrent registration race conditions Frontend (React 18 + Vite + Tailwind CSS): - Multi-step guided registration form with helper text on every field - Login page with show/hide password toggle - Protected routes with AuthContext - Dashboard with stats cards, bar chart, and daily agenda - Reservations list with search, filters, and inline status actions - Calendar with weekly view, slot availability, and date blocking - Config page: business info, schedules, bot personality - Billing page with plan comparison and usage bar Design system: - Bricolage Grotesque + DM Sans typography - Emerald primary palette with semantic color tokens - scale(0.97) button press feedback, ease-out animations - Skeleton loaders, stagger animations, prefers-reduced-motion support - Accessible: aria-labels, visible focus rings, 4.5:1 contrast Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
0
backend/app/modules/dashboard/__init__.py
Normal file
0
backend/app/modules/dashboard/__init__.py
Normal file
35
backend/app/modules/dashboard/router.py
Normal file
35
backend/app/modules/dashboard/router.py
Normal file
@ -0,0 +1,35 @@
|
||||
from datetime import date
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.core.dependencies import get_current_business
|
||||
from app.modules.dashboard import schemas, service
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/stats", response_model=schemas.ReservationStats)
|
||||
async def get_stats(
|
||||
business_id: int = Depends(get_current_business),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
return await service.get_stats(db, business_id)
|
||||
|
||||
|
||||
@router.get("/agenda", response_model=list[schemas.AgendaItem])
|
||||
async def get_agenda(
|
||||
date: date,
|
||||
business_id: int = Depends(get_current_business),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
return await service.get_agenda(db, business_id, date)
|
||||
|
||||
|
||||
@router.get("/peak-hours", response_model=list[schemas.PeakHour])
|
||||
async def get_peak_hours(
|
||||
business_id: int = Depends(get_current_business),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
return await service.get_peak_hours(db, business_id)
|
||||
26
backend/app/modules/dashboard/schemas.py
Normal file
26
backend/app/modules/dashboard/schemas.py
Normal file
@ -0,0 +1,26 @@
|
||||
from datetime import date as Date, time as Time
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class ReservationStats(BaseModel):
|
||||
today: int
|
||||
this_week: int
|
||||
this_month: int
|
||||
|
||||
|
||||
class AgendaItem(BaseModel):
|
||||
id: int
|
||||
client_name: str
|
||||
client_phone: str
|
||||
time_start: Time
|
||||
time_end: Time
|
||||
party_size: int
|
||||
status: str
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class PeakHour(BaseModel):
|
||||
hour: int
|
||||
total: int
|
||||
65
backend/app/modules/dashboard/service.py
Normal file
65
backend/app/modules/dashboard/service.py
Normal file
@ -0,0 +1,65 @@
|
||||
from datetime import date, timedelta
|
||||
|
||||
from sqlalchemy import and_, extract, func, select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.modules.dashboard.schemas import AgendaItem, PeakHour, ReservationStats
|
||||
from app.modules.reservations.models import Reservation
|
||||
|
||||
|
||||
async def get_stats(db: AsyncSession, business_id: int) -> ReservationStats:
|
||||
today = date.today()
|
||||
week_start = today - timedelta(days=today.weekday())
|
||||
month_start = today.replace(day=1)
|
||||
|
||||
async def count(start: date, end: date) -> int:
|
||||
result = await db.execute(
|
||||
select(func.count(Reservation.id)).where(
|
||||
and_(
|
||||
Reservation.business_id == business_id,
|
||||
Reservation.date >= start,
|
||||
Reservation.date <= end,
|
||||
Reservation.status.in_(["pending", "confirmed"]),
|
||||
)
|
||||
)
|
||||
)
|
||||
return result.scalar_one()
|
||||
|
||||
return ReservationStats(
|
||||
today=await count(today, today),
|
||||
this_week=await count(week_start, today),
|
||||
this_month=await count(month_start, today),
|
||||
)
|
||||
|
||||
|
||||
async def get_agenda(db: AsyncSession, business_id: int, target_date: date) -> list[AgendaItem]:
|
||||
result = await db.execute(
|
||||
select(Reservation)
|
||||
.where(
|
||||
and_(
|
||||
Reservation.business_id == business_id,
|
||||
Reservation.date == target_date,
|
||||
Reservation.status.in_(["pending", "confirmed"]),
|
||||
)
|
||||
)
|
||||
.order_by(Reservation.time_start)
|
||||
)
|
||||
return result.scalars().all()
|
||||
|
||||
|
||||
async def get_peak_hours(db: AsyncSession, business_id: int) -> list[PeakHour]:
|
||||
result = await db.execute(
|
||||
select(
|
||||
extract("hour", Reservation.time_start).label("hour"),
|
||||
func.count(Reservation.id).label("total"),
|
||||
)
|
||||
.where(
|
||||
and_(
|
||||
Reservation.business_id == business_id,
|
||||
Reservation.status.in_(["confirmed", "no_show"]),
|
||||
)
|
||||
)
|
||||
.group_by("hour")
|
||||
.order_by("hour")
|
||||
)
|
||||
return [PeakHour(hour=int(row.hour), total=row.total) for row in result.all()]
|
||||
Reference in New Issue
Block a user