This directory contains the frontend implementation for the Angelo State University Knowledge Chatbot. Built with Streamlit, it provides an interactive and responsive chat interface that communicates with the FastAPI backend.
- Streamlit - Web framework for building the interactive UI
- Docker - Containerization and deployment
- Python Libraries:
requests- API communication with backendpandas&plotly- Data visualizationpydantic- Settings managementpython-dotenv- Environment variable handling
frontend/
├── .streamlit/ # Streamlit configuration
│ └── secrets.toml # Secure credentials storage
├── src/
│ ├── api_client.py # Backend API communication
│ ├── config.py # Configuration management
│ └── ui_components.py # Reusable UI elements
├── pages/
│ ├── 1_About.py # About page
│ └── 2_Data_Sources.py # Data visualization page
├── app.py # Main application entry point
├── Dockerfile # Container configuration
└── requirements.txt # Python dependencies
-
Main Application (
app.py)- Entry point for the Streamlit application
- Manages chat interface and message history
- Handles user input and bot responses
-
Source Directory (
src/)api_client.py: Manages HTTP requests to backendconfig.py: Loads and validates configurationui_components.py: Contains reusable UI elements
-
Pages Directory (
pages/)- Additional pages for the multi-page Streamlit app
- About page with project information
- Data Sources page with Neo4j statistics
-
Docker Configuration
- Multi-stage build process
- Development and production configurations
- Runs on port 8501
- Includes health checks
The frontend communicates with the backend through these endpoints:
- Chat Endpoint:
POST http://localhost:8000/api/v1/chat- Sends user messages
- Receives AI-generated responses
- Handles conversation context
The frontend includes a production-ready Dockerfile with:
- Multi-stage build for optimization
- Non-root user for security
- Health checks
- Environment variable support
To build and run with Docker:
# Create .streamlit/secrets.toml
# frontend/.streamlit/secrets.toml
[server]
enableCORS = false
headless = true
port = 8501
address = "0.0.0.0"
[neo4j]
uri = "bolt://host.docker.internal:7687"
user = "neo4j"
password = "12345678"
database = "chatbot-database"
[frontend]
PROJECT_NAME = "asu_chatbot"
API_BASE_URL = "http://host.docker.internal:8000/api/v1"
FRONTEND_PORT = 8501
# Build the container
docker build -t asu-chatbot-frontend .
# Run the container
docker run -p 8501:8501 `
-v "<your .streamlit file path>:/app/.streamlit" `
frontend- Environment Configuration
# Create .streamlit directory
mkdir .streamlit
# Create secrets.toml
# frontend/.streamlit/secrets.toml
[server]
enableCORS = false
headless = true
port = 8501
address = "0.0.0.0"
[neo4j]
uri = "bolt://localhost:7687"
user = "neo4j"
password = "12345678"
database = "chatbot-database"
[frontend]
PROJECT_NAME = "asu_chatbot"
API_BASE_URL = "http://localhost:8000/api/v1"
FRONTEND_PORT = 8501- Install Dependencies
# Create virtual environment
python -m venv venv
# Activate (Windows)
.\venv\Scripts\activate
# Install requirements
pip install -r requirements.txt- Run the Application
# Start Streamlit server
streamlit run app.pyThe application will be available at http://localhost:8501
- Secure credential management via
secrets.toml - CORS protection
- Environment variable validation
- Non-root Docker user
- Sanitized user inputs
- Interactive components documentation in the About page
- API documentation available in the backend
- Inline code documentation for maintainability in the frontend
## Example of a chat session

