An intelligent healthcare documentation platform for hearing care professionals
Echo Notes revolutionizes healthcare documentation by using advanced AI to automatically generate SOAP (Subjective, Objective, Assessment, Plan) notes from patient visit transcripts. Built with a modern microservice architecture, it ensures scalability, security, and performance for healthcare professionals.
- π€ AI-Powered SOAP Generation - Automated medical note creation using LLaMA 3 and GPT-4
- π PII Protection - Advanced privacy-preserving text processing with Microsoft Presidio
- π RAG-based Queries - Intelligent patient data retrieval using vector embeddings
- π Document Management - Secure file storage and processing with AWS S3
- π Real-time Monitoring - Comprehensive service health and performance tracking
- π Modern UI/UX - Responsive Next.js interface with Tailwind CSS
Echo Notes follows a microservice architecture with clear separation between business logic and AI operations:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Production Environment β
β β
β βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββ β
β β Main Backend β β AI Service β β PostgreSQL β β
β β (Port 8001) β β (Port 8002) β β + pgvector β β
β β β β β β (Port 5432) β β
β β β’ FastAPI β β β’ FastAPI β β β β
β β β’ Business β β β’ AI Models β β β’ Shared DB β β
β β Logic β β β’ Model Cache β β β’ Vector β β
β β β’ HTTP Client ββββ€ β’ Transformers β β Search β β
β β β’ Database β β β’ OpenAI API β β β β
β β Operations β β β’ HuggingFace β β β β
β βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββ β
β β² β² β² β
β β β β β
β ββββββββββΌβββββ ββββββββββΌββββββ βββββββΌβββββββ β
β β Next.js β β AWS S3 β β Model β β
β β Frontend β β Document β β Cache β β
β β (Port 3000) β β Storage β β Volume β β
β βββββββββββββββ ββββββββββββββββ ββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββ
β HTTP Layer β
β βββββββββββββββββββ βββββββββββββββββββ β
β β Controllers β β Routes β β
β β β β β β
β β β’ AuthControllerβ β β’ /auth/* β β
β β β’ SOAPControllerβ β β’ /soap/* β β
β β β’ UserControllerβ β β’ /users/* β β
β β β’ RAGController β β β’ /rag/* β β
β βββββββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββ
β Business Logic Layer β
β βββββββββββββββββββ βββββββββββββββββββ β
β β Services β β Clients β β
β β β β β β
β β β’ AuthService β β β’ AIServiceClientβ β
β β β’ AISoapService β β β’ S3Client β β
β β β’ UserService β β β’ EmailClient β β
β β β’ PDFService β β β β
β βββββββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββ
β Data Access Layer β
β βββββββββββββββββββ βββββββββββββββββββ β
β β Repositories β β Models β β
β β β β β β
β β β’ PatientRepo β β β’ Professional β β
β β β’ SOAPNotesRepo β β β’ Patients β β
β β β’ SessionRepo β β β’ SOAPNotes β β
β βββββββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββ
β Database Layer β
β PostgreSQL + pgvector β
βββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββ
β API Layer β
β βββββββββββββββ βββββββββββββββββββββββ β
β β API Routes β β Endpoints β β
β β β β β β
β β soap_api.py β β POST /soap/generate β β
β β ner_api.py β β POST /ner/extract β β
β β pii_api.py β β POST /pii/anonymize β β
β β rag_api.py β β POST /embeddings/* β β
β βββββββββββββββ βββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββ
β AI Services Layer β
β βββββββββββββββ βββββββββββββββββββββββ β
β β AI Services β β Model Management β β
β β β β β β
β β SOAPService β β β’ Model Loading β β
β β NERService β β β’ Caching Strategy β β
β β PIIService β β β’ Performance Opt β β
β β RAGService β β β’ Memory Management β β
β βββββββββββββββ βββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββ
β External APIs Layer β
β OpenAI β’ HuggingFace β’ Presidio β
βββββββββββββββββββββββββββββββββββββββββββ
| Component | Technology | Purpose |
|---|---|---|
| Framework | FastAPI 0.104+ | High-performance async web framework |
| Language | Python 3.11+ | Modern Python with type hints |
| Database | PostgreSQL 17 + pgvector | Relational DB with vector operations |
| ORM | SQLAlchemy 2.0 + Alembic | Database modeling and migrations |
| Validation | Pydantic V2 | Data validation and serialization |
| Authentication | JWT + Bcrypt | Secure token-based auth |
| HTTP Client | httpx | Async HTTP client for microservice communication |
| Dependency Management | uv | Modern Python package manager |
| Component | Technology | Purpose |
|---|---|---|
| SOAP Generation | LLaMA 3 (70B) via HuggingFace | Advanced biomedical text generation |
| Judge LLM | GPT-4o-mini | Quality validation and scoring |
| Embeddings | OpenAI text-embedding-3-small | Vector embeddings for RAG |
| NER | d4data/biomedical-ner-all | Biomedical named entity recognition |
| PII Detection | Microsoft Presidio | Privacy-preserving text processing |
| Vector Search | pgvector | Cosine similarity search |
| ML Framework | Transformers + LangChain | Model orchestration |
| Component | Technology | Purpose |
|---|---|---|
| Framework | Next.js 15 | React-based full-stack framework |
| UI Library | React 19 | Modern component-based UI |
| Styling | Tailwind CSS 4 | Utility-first CSS framework |
| Components | Radix UI | Accessible component library |
| Forms | React Hook Form | Performant forms with validation |
| State Management | React Context + Hooks | Client state management |
| API Client | Fetch API | RESTful API communication |
| Icons | Lucide React | Beautiful SVG icons |
| Component | Technology | Purpose |
|---|---|---|
| Containerization | Docker + Docker Compose | Container orchestration |
| Deployment | Ubuntu EC2 + Nginx | Cloud deployment with load balancing |
| Storage | AWS S3 | Document and file storage |
| Monitoring | Structured Logging | Application observability |
| CI/CD | Git-based deployment | Automated deployment pipeline |
frontend/
βββ app/ # Next.js 13+ App Router
β βββ (auth)/ # Authentication pages
β β βββ login/ # User login
β β βββ register/ # User registration
β βββ dashboard/ # Main dashboard
β βββ patients/ # Patient management
β β βββ [id]/ # Patient details
β β βββ new/ # Add new patient
β βββ sessions/ # Visit sessions
β β βββ [id]/ # Session details
β β βββ new/ # New session
β βββ documents/ # Document management
β β βββ upload/ # File upload
β β βββ [id]/view/ # Document viewer
β βββ soap/ # SOAP note management
β β βββ generate/ # SOAP generation
β β βββ notes/[id]/ # Note viewer
β βββ rag/ # RAG queries
β βββ query/ # Knowledge base search
βββ components/ui/ # Reusable UI components
βββ lib/ # Utility functions
βββ routes/ # API route configurations
graph TD
A[Landing Page] --> B[Login/Register]
B --> C{Valid Credentials?}
C -->|Yes| D[Dashboard]
C -->|No| E[Error Message]
E --> B
D --> F[Main Application]
graph TD
A[Dashboard] --> B[New Session]
B --> C[Patient Selection]
C --> D[Document Upload]
D --> E[Text Extraction]
E --> F[AI Processing]
F --> G[SOAP Preview]
G --> H{User Approval?}
H -->|Yes| I[Save to Database]
H -->|No| J[Edit/Regenerate]
J --> F
I --> K[RAG Embedding]
graph TD
A[Patient List] --> B{Action}
B -->|View| C[Patient Details]
B -->|Edit| D[Update Form]
B -->|New| E[Create Form]
C --> F[Visit History]
C --> G[SOAP Notes]
D --> H[Save Changes]
E --> I[Create Patient]
graph TD
A[RAG Interface] --> B[Enter Query]
B --> C[Vector Search]
C --> D[Similarity Matching]
D --> E[Context Retrieval]
E --> F[Answer Generation]
F --> G[Response Display]
App Layout
βββ Navigation Bar
β βββ Logo
β βββ Menu Items
β βββ User Profile
βββ Sidebar
β βββ Dashboard Link
β βββ Patients Link
β βββ Sessions Link
β βββ SOAP Notes Link
βββ Main Content
β βββ Page Header
β βββ Breadcrumbs
β βββ Dynamic Content
βββ Footer
βββ Status Indicators
βββ Version Info
// Global State (React Context)
interface AppState {
user: User | null;
currentPatient: Patient | null;
activeSessions: Session[];
notifications: Notification[];
}
// Component State (React Hooks)
interface ComponentState {
formData: FormState;
loading: boolean;
errors: ValidationErrors;
modalOpen: boolean;
}- Dual LLM Architecture: Combines LLaMA 3 (70B) for generation with GPT-4o-mini for validation
- Biomedical Specialization: Custom-trained models for hearing care terminology
- Quality Assurance: AI judge validates note quality before saving
- Context Awareness: RAG system provides relevant historical context
- PII Protection: Microsoft Presidio integration for automatic PII detection
- Selective Anonymization: Preserves medical context while protecting privacy
- HIPAA Compliance: Designed with healthcare regulations in mind
- Audit Trail: Complete logging of all data access and modifications
- Independent Scaling: AI services scale separately from business logic
- Resource Optimization: Dedicated GPU resources for AI workloads
- Fault Tolerance: Circuit breaker patterns prevent cascading failures
- Performance: Async operations and intelligent caching
- Vector Search: pgvector enables semantic similarity search
- RAG Integration: Retrieve relevant patient history for context
- Smart Recommendations: AI suggests relevant information during note creation
- Continuous Learning: System improves with usage patterns
- Responsive Design: Works seamlessly across desktop, tablet, and mobile
- Real-time Updates: Live status indicators and progress tracking
- Intuitive Workflow: Streamlined process from upload to final note
- Accessibility: WCAG compliant interface design
- One-Command Deployment: Unified Docker Compose setup
- Modern Tooling: uv for Python, Next.js 15, TypeScript
- Comprehensive Testing: Automated testing for all components
- Clear Documentation: Extensive docs and architecture guides
# AIServiceClient in Main Backend
class AIServiceClient:
async def generate_soap_note(self, request_data: Dict) -> Dict:
"""Generate SOAP note via AI service"""
response = await self.client.post("/soap/generate", json=request_data)
return response.json()
async def extract_ner_entities(self, text: str) -> Dict:
"""Extract entities via AI service"""
response = await self.client.post("/ner/extract", json={"text": text})
return response.json()// API Client in Frontend
class ApiClient {
async generateSOAP(sessionId: string, text: string): Promise<SOAPNote> {
const response = await fetch("/api/soap/generate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ session_id: sessionId, text }),
});
return response.json();
}
}# Circuit Breaker Pattern
class AIServiceClient:
def __init__(self):
self.circuit_breaker = CircuitBreaker(
failure_threshold=5,
timeout=60,
expected_exception=httpx.HTTPError
)
@circuit_breaker
async def generate_soap_note(self, data: Dict) -> Dict:
# AI service call with automatic circuit breaking
pass-- Professional (Healthcare Workers)
professional (id, name, email, role, department)
β
-- Patients (Healthcare Recipients)
patients (id, name, email, phone, address)
β
-- Visit Sessions (Encounters)
patient_visit_sessions (session_id, patient_id, professional_id, visit_date)
β
-- Documents (Files/Transcripts)
uploaded_documents (document_id, session_id, s3_link, extracted_text)
β
-- SOAP Notes (Generated Notes with Vector Embeddings)
session_soap_notes (note_id, session_id, content, embedding[1536])-- Semantic similarity search for RAG
SELECT
note_id,
content,
1 - (embedding <=> $1) as similarity
FROM session_soap_notes
WHERE embedding IS NOT NULL
AND 1 - (embedding <=> $1) > 0.7
ORDER BY embedding <=> $1
LIMIT 10;- Docker & Docker Compose (Latest version)
- Python 3.11+ (for local development)
- Node.js 18+ (for frontend development)
- PostgreSQL (if running locally)
# Clone the repository
git clone <repository-url>
cd echo-notes-service
# Copy environment templates
cp .env.sample .env
cp backend/.env.sample backend/.env
cp ai_service/.env.sample ai_service/.env
cp frontend/.env.sample frontend/.env.local
# Update with your API keys
# Edit .env files with actual OpenAI and HuggingFace keys# Windows
run-dev-unified.bat
# Linux/Mac
./run-dev-unified.sh# Deploy to EC2
./deploy-ec2-unified.sh
# Or manual Docker deployment
docker-compose -f docker-compose.unified.yaml up --build -dAfter deployment, access the application at:
- π Main Application: http://localhost
- π¨ Frontend: http://localhost:3000
- π₯οΈ Backend API: http://localhost:8001
- π€ AI Service: http://localhost:8002
- π API Documentation:
- Backend: http://localhost:8001/docs
- AI Service: http://localhost:8002/docs
- Backend Architecture PRD - Comprehensive system design
- Unified Architecture - Container architecture guide
- EC2 Deployment Guide - Cloud deployment instructions
- Backend API: Available at
/docsendpoint (Swagger UI) - AI Service API: Available at
/docsendpoint (OpenAPI) - Frontend Routes: Documented in
frontend/routes/
- Backend Setup: See
backend/README.md - AI Service Setup: See
ai_service/README.md - Frontend Setup: See
frontend/README.md
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Backend: Follow PEP 8, use type hints, add docstrings
- Frontend: Use TypeScript, follow React best practices
- Testing: Write tests for new features
- Documentation: Update docs for API changes
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Check the comprehensive docs in
/docs - Issues: Report bugs via GitHub Issues
- Discussions: Join project discussions
- Email: Contact the development team
- Memory Issues: AI service requires 8GB+ RAM
- Model Loading: First startup takes 10-15 minutes
- API Keys: Ensure OpenAI and HuggingFace keys are valid
- Network: Check firewall settings for inter-service communication
- OpenAI - For GPT-4 and embedding models
- HuggingFace - For biomedical LLaMA models
- Microsoft - For Presidio PII detection
- Vercel - For Next.js framework
- FastAPI Team - For the excellent web framework
Built with β€οΈ for Healthcare Professionals
Transforming healthcare documentation through AI innovation