How sahanasankar13/abby_chatbot works
Main Components
• API/Web Server: The entry point is app.py, which initializes your FastAPI application. This component handles incoming HTTP requests, routing, and ties together business logic.
• Chatbot Core Logic: Located in the chatbot/ directory, this contains various modules for processing conversations (e.g., conversation_manager.py, preprocessor.py, response_composer.py) and integrating with external services (e.g., gpt_integration.py, citation_manager.py, policy_handler.py). Each module represents a distinct responsibility in handling language processing, classification, and response generation.
• Machine Learning Models: The models/ directory encapsulates the data structures and algorithms that power feedback, metric calculations, user data handling, etc.
• Configuration & Environment Handling: The config/ directory includes model_config.py, server configuration files (e.g., gunicorn.conf.py), and multiple dependency and environment configuration files (such as .env.example and requirements files). This area governs runtime behavior and deployment settings.
• Data Management: The data/ directory holds training data, conversation transcripts, and supplementary files (e.g., FAQs, clinic data). These are vital for the chatbot’s knowledge base.
• Deployment Pipeline: The deployment/ directory contains AWS CloudFormation templates, deployment scripts, and related policies. It’s where the infrastructure as code is defined for deploying the chatbot on AWS.
• Frontend Components: The templates/ and static/ directories support the user interface aspect, where HTML, CSS, and JavaScript (including chat.js, maps.js, etc.) offer the client-side interface.
• Utility & Testing Components: Directories like utils/, scripts/, and tests/ provide supplemental functionality, handling scripts for model management, text processing utilities, and comprehensive test suites.
Relationships and Interactions
• User Interaction: Start at the client (web browser or API consumer) which makes requests. The frontend (HTML & JS) interacts with the API (app.py).
• API Layer: The FastAPI application processes the request and delegates tasks to the chatbot core logic.
• Chatbot Engine: Inside chatbot/, individual modules work collaboratively to preprocess input, classify queries, manage conversation state, and generate responses possibly via integrations like GPT or policy APIs.
• Data & Model Handling: The chatbot interacts with models in the models/ directory to push/pop data for feedback, metrics, and user management. It also consults the data/ repository for static data and NLTK data (nltk_data/) for language processing.
• Configuration & Deployment: The configurations in config/ inform the running environment of the API and server. Meanwhile, the deployment/ folder defines how the code and infrastructure are pushed to AWS, including CloudFormation templates, Codedeploy policies, scripts for managing application state (start, stop, health check), etc.
Architectural Patterns and Design Principles
• Modular Design: The separation into distinct directories (chatbot, config, models, utils) indicates a clear separation of concerns. Each module or service has its own responsibility.
• API-Driven Architecture: The FastAPI app acts as the orchestration layer. This design facilitates scalability (possibly via microservices or standalone modules if needed) and testing.
• Extensibility: The breakdown of the chatbot logic into smaller, manageable units (e.g., response composers, policy handlers) makes it easy to extend functionality.
• Deployment as Code: With CloudFormation, Terraform (mentioned in README), and CI/CD setup in .github/workflows, the project follows infrastructure-as-code and automated deployment best practices.
Relevant Technologies and Frameworks
• Python 3.8+ as the main language.
• FastAPI for web serving and asynchronous request handling.
• NLTK for natural language processing (evident from the nltk_data directory).
• ML libraries and custom modeling in the models/ directory.
• AWS tools for deployment (CloudFormation, AWS CLI).
• Standard web technologies (HTML, CSS, JavaScript) for frontend presentation.
Final Advice
• Be detailed, ensuring each of the key modules (even submodules in the chatbot directory) is briefly represented.
• Don’t shy away from adding annotations or legends to explain technology stacks or interdependencies.