How tanishpoddar/neuralnexus works
Project Type and Purpose
• NeuralNexus is a full-stack AI chatbot application. It combines a Flask-based web server (backend) with a modern web interface (frontend), and an NLP/ML module that trains and serves a neural network model for conversational AI.
Top-Level Components
a. Frontend
• Browser/client running templates/index.html (HTML, CSS, JS)
• Sends user messages via HTTP (e.g., AJAX or Fetch) to the Flask API
b. Backend (Flask App)
• Entry point: main-host.py (Flask server)
• May import main.py (core logic: training & inference)
• Loads configuration from .env (via python-dotenv)
• Exposes REST endpoints for chat and possibly status/training
c. NLP/ML Module
• Data loader: reads intents.json
• Preprocessor: uses NLTK to tokenize, stem, bag-of-words
• Model trainer: TensorFlow-based network (layers, dropout)
• Inference engine: loads model.weights.h5 & data.pickle, generates responses
d. Data Storage
• Static JSON: intents.json (training data)
• Binary artifacts: model.weights.h5, data.pickle (persisted in project root or storage folder)
e. External Dependencies
• TensorFlow, NLTK, NumPy, Flask, python-dotenv
Interactions and Data Flows
• 1) User opens the web page (index.html) in browser.
• 2) Browser sends user input via HTTP POST to Flask endpoint (e.g., /chat).
• 3) Flask app receives request in main-host.py, calls NLP module in main.py:
• If model not yet trained or weights missing, trigger training subroutine
• Otherwise load persisted model and data (from model.weights.h5, data.pickle)
• 4) NLP module preprocesses input, runs inference, selects a response tag and text.
• 5) Flask app returns JSON payload containing chatbot response.
• 6) Frontend JavaScript updates the UI with the chatbot reply.
Architectural Patterns and Principles
• Layered architecture:
• Presentation layer (frontend)
• API layer (Flask routes)
• Business logic layer (NLP pipeline, model training/inference)
• Data layer (intents JSON, trained artifacts)
• Separation of concerns: each layer handles a specific responsibility.
• Stateless request handling: each HTTP request is independent (model loading cached in memory).
• Extensibility: adding new intents via intents.json only requires editing the JSON file.
Diagramming Recommendations
• Client (Browser)
• Web UI (HTML/JS)
• Flask API (main-host.py)
• NLP Engine (main.py modules: Preprocessor, Trainer, Inference)
• Data Store (intents.json, model.weights.h5, data.pickle)
• Relationships: