2026-04-29 09:39:56 -05:00
|
|
|
from fastapi import APIRouter, Depends, Response, status
|
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>
2026-04-28 09:49:41 -05:00
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
|
|
|
|
|
|
from app.core.database import get_db
|
|
|
|
|
from app.core.dependencies import get_current_business, get_current_user
|
|
|
|
|
from app.modules.business import schemas, service
|
|
|
|
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/me", response_model=schemas.BusinessRead)
|
|
|
|
|
async def get_my_business(
|
|
|
|
|
business_id: int = Depends(get_current_business),
|
|
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
|
|
|
|
return await service.get_business(db, business_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.put("/me", response_model=schemas.BusinessRead)
|
|
|
|
|
async def update_my_business(
|
|
|
|
|
body: schemas.BusinessUpdate,
|
|
|
|
|
business_id: int = Depends(get_current_business),
|
|
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
|
|
|
|
return await service.update_business(db, business_id, body)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/me/config", response_model=schemas.BusinessConfigRead)
|
|
|
|
|
async def get_my_config(
|
|
|
|
|
business_id: int = Depends(get_current_business),
|
|
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
|
|
|
|
return await service.get_business_config(db, business_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.put("/me/config", response_model=schemas.BusinessConfigRead)
|
|
|
|
|
async def update_my_config(
|
|
|
|
|
body: schemas.BusinessConfigUpdate,
|
|
|
|
|
business_id: int = Depends(get_current_business),
|
|
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
|
|
|
|
return await service.update_business_config(db, business_id, body)
|
2026-04-29 09:39:56 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/me/tables", response_model=list[schemas.TableTypeRead])
|
|
|
|
|
async def list_tables(
|
|
|
|
|
business_id: int = Depends(get_current_business),
|
|
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
|
|
|
|
return await service.list_table_types(db, business_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.post("/me/tables", response_model=schemas.TableTypeRead, status_code=201)
|
|
|
|
|
async def create_table(
|
|
|
|
|
body: schemas.TableTypeCreate,
|
|
|
|
|
business_id: int = Depends(get_current_business),
|
|
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
|
|
|
|
return await service.create_table_type(db, business_id, body)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.put("/me/tables/{table_id}", response_model=schemas.TableTypeRead)
|
|
|
|
|
async def update_table(
|
|
|
|
|
table_id: int,
|
|
|
|
|
body: schemas.TableTypeUpdate,
|
|
|
|
|
business_id: int = Depends(get_current_business),
|
|
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
|
|
|
|
return await service.update_table_type(db, business_id, table_id, body)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.delete("/me/tables/{table_id}", status_code=204)
|
|
|
|
|
async def delete_table(
|
|
|
|
|
table_id: int,
|
|
|
|
|
business_id: int = Depends(get_current_business),
|
|
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
|
|
|
|
await service.delete_table_type(db, business_id, table_id)
|
|
|
|
|
return Response(status_code=204)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/me/services", response_model=list[schemas.ServiceRead])
|
|
|
|
|
async def list_services(
|
|
|
|
|
business_id: int = Depends(get_current_business),
|
|
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
|
|
|
|
return await service.list_services(db, business_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.post("/me/services", response_model=schemas.ServiceRead, status_code=201)
|
|
|
|
|
async def create_service(
|
|
|
|
|
body: schemas.ServiceCreate,
|
|
|
|
|
business_id: int = Depends(get_current_business),
|
|
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
|
|
|
|
return await service.create_service(db, business_id, body)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.put("/me/services/{service_id}", response_model=schemas.ServiceRead)
|
|
|
|
|
async def update_service(
|
|
|
|
|
service_id: int,
|
|
|
|
|
body: schemas.ServiceUpdate,
|
|
|
|
|
business_id: int = Depends(get_current_business),
|
|
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
|
|
|
|
return await service.update_service(db, business_id, service_id, body)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.delete("/me/services/{service_id}", status_code=204)
|
|
|
|
|
async def delete_service(
|
|
|
|
|
service_id: int,
|
|
|
|
|
business_id: int = Depends(get_current_business),
|
|
|
|
|
db: AsyncSession = Depends(get_db),
|
|
|
|
|
):
|
|
|
|
|
await service.delete_service(db, business_id, service_id)
|
|
|
|
|
return Response(status_code=204)
|