How saadan-hashmi-0p/dualis_ai works
Project Type and Purpose
• This is a lightweight, monolithic full-stack web application built with Streamlit. It serves as a chatbot UI (“frontend”) and chat-processing engine (“backend”) in one Python script (Dualis.py), augmented by custom CSS (style.css). It relies on the Hugging Face API as an external NLP service.
File Structure Analysis
• Dualis.py (the main app entrypoint: UI definitions, session-state management, mode-switching logic, API calls)
• style.css (custom styling for Streamlit components)
• README.md (project description, setup, tech stack)
• .gitattributes (VCS settings)
No separate folders for “frontend” vs. “backend”—both live in Dualis.py.
Key Components
a. Client Browser (User)
b. Streamlit App Server (Dualis.py)
– UI Layer: Streamlit widgets, chat history panels, typing animation
– Application Layer: Mode controller (General vs. Focused), session state for histories
– Utility Layer: PIL for logo handling, requests to external APIs
c. External NLP Service: Hugging Face API (authentication via secrets.toml)
d. Assets: style.css (injected into the UI)
Relationships & Data Flows
1. User enters a message in the browser → HTTP to Streamlit server
2. Streamlit UI invokes Dualis.py chat handler
3. Chat handler selects mode → formats request → uses requests library to call Hugging Face API
4. API returns generated text → Dualis.py updates session state → Streamlit pushes new message to UI
5. Browser renders updated chat history (styled by style.css)
Architectural Patterns & Design Principles
• Three-tier separation (Presentation / Application / External Service)
• Single-page, event-driven UI (Streamlit’s rerun model)
• Stateless external API calls, with session state held in memory
• Extendable modules (future OCR/PDF/TTS blocks can slot into Utility Layer)