This guide covers the complete development workflow for AuthentiVoice, including environment setup, architecture patterns, and best practices for contributing to the codebase.
๐ Development Environment Setup
Prerequisites
Ensure you have all required tools installed:
Node.js 18+ for frontend development
Python 3.10+ for backend development
Docker for containerized services
ffmpeg for audio processing
Git for version control
Clone and Install
# Clone the repository
git clone https://github.com/authentivoice/authentivoice.git
cd authentivoice
# Install frontend dependencies
cd frontend && npm install
# Install backend dependencies
cd ../backend
pip install uv # Fast Python package manager
uv sync
Environment Configuration
Create .env files from templates: # Frontend
cp frontend/.env.example frontend/.env
# Backend
cp backend/.env.example backend/.env
Essential Environment Variables
Frontend (.env) :
VITE_SUPABASE_URL - Your Supabase project URL
VITE_SUPABASE_ANON_KEY - Supabase anonymous key
VITE_API_BASE_URL - Backend API URL (default: http://localhost:8006 )
VITE_API_KEY - API key for backend authentication
VITE_DEMO_ENABLED - Enable demo mode features
VITE_LOCAL_DEV - Enable local development features
Backend (.env) :
GEMINI_API_KEY - Google AI API key for fraud analysis
S3_* - MinIO/S3 configuration for file storage
SUPABASE_* - Supabase service key and URL
API_KEY - Must match frontend API key
Start Development Servers
Use the Makefile for easy startup: # Terminal 1 - Frontend (http://localhost:5173)
make run-frontend
# Terminal 2 - Backend (http://localhost:8006)
make run-backend
# Terminal 3 - Documentation (http://localhost:3333)
make docs-dev
๐๏ธ Architecture Overview
Frontend Architecture
frontend/
โโโ src/
โ โโโ components/ # Reusable UI components
โ โ โโโ dashboard/ # Dashboard-specific components
โ โ โโโ landing/ # Landing page components
โ โ โโโ analysis/ # Call analysis components
โ โ โโโ review/ # Review system components
โ โ โโโ ui/ # shadcn-ui base components
โ โโโ pages/ # Route-based page components
โ โ โโโ Index.tsx # Landing page
โ โ โโโ Dashboard.tsx # Main dashboard
โ โ โโโ AnalysisDetail.tsx # Analysis details
โ โ โโโ Settings/ # Settings pages
โ โโโ hooks/ # Custom React hooks
โ โ โโโ useAnalyses.ts # Analysis data hooks
โ โ โโโ useReviews.ts # Review system hooks
โ โ โโโ useIntegrations.ts # Integration hooks
โ โโโ lib/ # Utilities and configurations
โ โ โโโ api.ts # API client
โ โ โโโ supabase.ts # Supabase client
โ โ โโโ utils.ts # Helper functions
โ โโโ types/ # TypeScript definitions
โ โ โโโ analysis.ts # Analysis types
โ โ โโโ review.ts # Review types
โ โ โโโ integration.ts # Integration types
โ โโโ integrations/ # Third-party integrations
โโโ public/ # Static assets
โโโ supabase/ # Database migrations and types
Backend Architecture
backend/
โโโ app/
โ โโโ api/ # API route handlers
โ โ โโโ endpoints/ # Endpoint modules
โ โ โโโ audio.py # Audio processing
โ โ โโโ analysis.py # Analysis endpoints
โ โ โโโ review.py # Review endpoints
โ โ โโโ integrations.py # Integration APIs
โ โโโ core/ # Core business logic
โ โ โโโ audio_processing/ # Audio manipulation
โ โ โโโ transcription/ # Multiple engines
โ โ โโโ analysis/ # AI fraud detection
โ โ โโโ review/ # Review logic
โ โโโ services/ # External services
โ โ โโโ s3_service.py # File storage
โ โ โโโ supabase_service.py # Database
โ โ โโโ ai_service.py # AI providers
โ โ โโโ notification_service.py # Alerts
โ โโโ models/ # Pydantic models
โ โ โโโ audio.py # Audio models
โ โ โโโ analysis.py # Analysis models
โ โ โโโ review.py # Review models
โ โโโ utils/ # Helper utilities
โโโ modal/ # Modal cloud deployment
โโโ tests/ # Test suite
โโโ alembic/ # Database migrations (if needed)
๐ ๏ธ Common Development Tasks
Working with New Features
Our platform has recently added several major features. Hereโs how to work with them:
Multi-Reviewer Workflows
PDF Export
Integrations
Backend Implementation :# app/api/endpoints/review.py
@router.post ( "/analyses/ {analysis_id} /reviews" )
async def create_review (
analysis_id : str ,
review : ReviewCreate,
current_user : User = Depends(get_current_user)
) -> ReviewResponse:
# Implement review creation with scoring
pass
@router.post ( "/reviews/bulk-assign" )
async def bulk_assign_reviews (
assignments : BulkAssignmentRequest,
current_user : User = Depends(require_supervisor)
) -> BulkAssignmentResponse:
# Assign multiple calls to reviewers
pass
Frontend Implementation :// hooks/useReviews.ts
export function useCreateReview ( analysisId : string ) {
return useMutation ({
mutationFn : ( review : ReviewCreate ) =>
createReview ( analysisId , review ),
onSuccess : () => {
queryClient . invalidateQueries ([ 'reviews' , analysisId ]);
}
});
}
Development Patterns
All API calls go through a centralized client: // lib/api.ts
async function request < T >(
endpoint : string ,
options ?: RequestInit
) : Promise < T > {
const token = await supabase . auth . getSession ();
const headers = {
'Content-Type' : 'application/json' ,
'X-API-Key' : import . meta . env . VITE_API_KEY ,
... options ?. headers ,
};
if ( token ?. session ?. access_token ) {
headers [ 'Authorization' ] = `Bearer ${ token . session . access_token } ` ;
}
const response = await fetch ( ` ${ API_BASE_URL }${ endpoint } ` , {
... options ,
headers ,
});
if ( ! response . ok ) {
throw new APIError ( response );
}
return response . json ();
}
Use React Query for all data fetching: // hooks/useAnalyses.ts
export function useAnalyses ( filters ?: AnalysisFilters ) {
return useQuery ({
queryKey: [ 'analyses' , filters ],
queryFn : () => fetchAnalyses ( filters ),
staleTime: 5 * 60 * 1000 , // 5 minutes
});
}
export function useAnalysis ( id : string ) {
return useQuery ({
queryKey: [ 'analysis' , id ],
queryFn : () => fetchAnalysis ( id ),
enabled: !! id ,
});
}
Consistent error handling across the app: // components/ErrorBoundary.tsx
export function QueryErrorBoundary ({ children } : Props ) {
return (
< ErrorBoundary
fallbackRender = {({ error , resetErrorBoundary }) => (
<Alert variant = "destructive" >
<AlertCircle className = "h-4 w-4" />
<AlertTitle>Error</AlertTitle>
<AlertDescription>
{ error . message }
<Button onClick = { resetErrorBoundary } > Try again </ Button >
</AlertDescription>
</Alert>
)}
>
{ children }
</ ErrorBoundary >
);
}
๐งช Testing Strategy
Frontend Testing
Type Checking
Linting
Unit Tests
E2E Tests
Backend Testing
Type Checking
Linting
Unit Tests
Integration Tests
Writing Tests
Frontend Tests
Backend Tests
// __tests__/hooks/useAnalyses.test.ts
import { renderHook , waitFor } from '@testing-library/react' ;
import { useAnalyses } from '@/hooks/useAnalyses' ;
describe ( 'useAnalyses' , () => {
it ( 'fetches analyses successfully' , async () => {
const { result } = renderHook (() => useAnalyses ());
await waitFor (() => {
expect ( result . current . isSuccess ). toBe ( true );
});
expect ( result . current . data ). toHaveLength ( 10 );
});
});
๐ง Advanced Development
Security Best Practices
Always follow these security practices when developing AuthentiVoice features.
Input Validation
# Always validate input
from pydantic import BaseModel, validator
class AudioUpload ( BaseModel ):
file_size: int
file_type: str
@validator ( 'file_size' )
def validate_size ( cls , v ):
if v > 100 * 1024 * 1024 : # 100MB
raise ValueError ( 'File too large' )
return v
Authentication
# Always verify user permissions
from app.core.auth import require_role
@router.delete ( "/analyses/ {id} " )
@require_role ([ "admin" , "supervisor" ])
async def delete_analysis ( id : str ):
# Only admins/supervisors can delete
pass
Rate Limiting
# Implement rate limiting
from slowapi import Limiter
limiter = Limiter( key_func = get_remote_address)
@router.post ( "/analyses" )
@limiter.limit ( "10/minute" )
async def create_analysis ():
pass
๐ Deployment
Local Docker Development
# Build and run with docker-compose
docker-compose up --build
# Run specific service
docker-compose up frontend backend
# View logs
docker-compose logs -f backend
Production Build
Frontend Build
Backend Build
Documentation Build
cd frontend
npm run build
# Output in dist/
๐ Resources & References
๐ค Contributing
We welcome contributions! Please:
Fork the repository
Create a feature branch
Make your changes with tests
Submit a pull request
See our Contributing Guide for detailed instructions.