A Flask-based web application that serves local procedures through an intelligent chat-like interface. The application provides a user-friendly way to search, access, and manage technical procedures and documentation.
- Intent Detection: Automatically detects user intent (commands-only, how-to, what-is, explain, general)
- Smart Scoring: Uses keyword matching and intent-based scoring to find the most relevant procedures
- Context-Aware Responses: Formats answers based on detected intent (e.g., shows only commands when requested)
- Retry Support: Allows users to retry previous questions easily
- Modern, responsive chat UI
- Conversation history with localStorage persistence
- Copy-to-clipboard functionality for commands
- Support for greetings and casual conversation (English and Bulgarian)
- Common question pattern recognition
- Role-Based Access Control: Admin and regular user roles
- User Authentication: Secure password hashing with Werkzeug
- User Profile Management: Avatar selection, email updates, password changes
- Admin Features: Create, block/unblock, reset passwords, and delete users
- Default Superadmin: Auto-created on first run
- CRUD Operations: Create, read, update, and delete procedures
- Rich Content Support:
- Step-by-step instructions
- Commands with copy functionality
- Images (summary, verification, notes)
- File attachments (PDFs, documents, etc.)
- Prerequisites and verification steps
- Tags for better searchability
- Metadata Tracking: Created/updated by, timestamps
- Duplicate Prevention: Validates unique titles and IDs
- File Uploads: Support for images and documents (max 16MB)
- Automatic Cleanup: Removes unused files when procedures are deleted or updated
- Secure Filenames: Uses secure_filename to prevent path traversal
- Responsive design
- Dark theme with modern styling
- Font Awesome icons
- Smooth animations and transitions
- Mobile-friendly interface
The main chat interface where users can interact with the Knowledge Assistant
User management interface showing profile management and user administration features
Procedure administration interface with live preview functionality
- Python: 3.13 or higher
- Flask: >=3.0.0
- Werkzeug: >=3.0.0
cd /path/to/projectpython3 -m venv venvOn Linux/Mac:
source venv/bin/activateOn Windows:
venv\Scripts\activatepip install -r requirements.txtFor production, set a secure secret key:
export SECRET_KEY='your-secure-secret-key-here'python app.pyThe application will be available at http://localhost:5000
On first run, a default superadmin user is created:
- Username:
superadmin - Password:
SuperAdmin@2024
proj/
├── app.py # Main Flask application
├── greetings.py # Greeting response handlers
├── common_responses.py # Common question handlers
├── requirements.txt # Python dependencies
├── INSTALLATION.md # Detailed installation guide
├── static/ # Static files
│ ├── css/ # Stylesheets
│ │ ├── style.css
│ │ ├── admin.css
│ │ ├── auth.css
│ │ └── manage_users.css
│ ├── js/ # JavaScript files
│ │ ├── script.js
│ │ └── admin.js
│ ├── images/ # Images and avatars
│ │ └── avatars/
│ └── uploads/ # User-uploaded files
├── templates/ # HTML templates
│ ├── index.html # Main chat interface
│ ├── admin.html # Admin panel
│ ├── profile.html # User profile page
│ └── login.html # Login page
├── procedures/ # Procedure data storage
│ └── procedures.json
└── users/ # User data storage
└── users.json
- Login: Use your credentials to access the application
- Ask Questions: Type your question in the chat interface
- Get Answers: The system will find and display relevant procedures
- Copy Commands: Click the copy button next to any command
- View Sources: Click on source links to see detailed procedure information
- Manage Profile: Update your avatar, email, and password from the profile page
- Admin Panel: Access
/adminto manage procedures and users - Procedure Management:
- Create new procedures with rich content
- Edit existing procedures
- Delete procedures (with automatic file cleanup)
- Upload images and attachments
- User Management:
- Create new users
- Block/unblock users
- Reset user passwords
- Delete users
- View All Procedures: Browse and search all procedures in the system
The system intelligently handles different types of questions:
- Commands Only: "Give me the commands for X" → Shows only commands
- How-To: "How to install X" → Shows full step-by-step guide
- What-Is/Explain: "What is X" → Shows overview and explanation
- General: Other questions → Shows complete procedure information
POST /login- User login/logout- User logout/profile- User profile pagePOST /profile/update- Update user profile
GET /procedures- List all procedures (requires login)POST /procedures- Create new procedure (requires login)PUT /procedures/<id>- Update procedure (requires login)DELETE /procedures/<id>- Delete procedure (requires login)
POST /ask- Ask a question (requires login)
POST /upload- Upload files (requires login)
/admin- Admin panel (requires admin role)POST /admin/users/create- Create user (admin only)POST /admin/users/<username>/block- Block/unblock user (admin only)POST /admin/users/<username>/reset-password- Reset password (admin only)DELETE /admin/users/<username>/delete- Delete user (admin only)
- Maximum file size: 16MB (configurable in
app.py) - Allowed file types: Images, PDFs, documents
- Procedures: Stored in
procedures/procedures.json - Users: Stored in
users/users.json - Uploads: Stored in
static/uploads/
- Passwords are hashed using Werkzeug's password hashing
- Session-based authentication
- Secure filename handling for uploads
- CSRF protection (Flask default)
Solution: Make sure you've activated the virtual environment and installed requirements:
source venv/bin/activate
pip install -r requirements.txtSolution: Use a different port by modifying app.py:
app.run(host='0.0.0.0', port=5001, debug=True)Solution: Ensure the application has write permissions for:
static/uploads/users/procedures/
Solution:
- Check that
procedures/procedures.jsonexists - Verify the JSON file is valid
- Use the admin panel to create procedures
Solution:
- Check that
users/users.jsonexists - Verify default superadmin credentials
- Use
reset_superadmin.pyif needed to reset the superadmin password
The application runs in debug mode by default. For production:
- Set
debug=Falseinapp.py - Set a secure
SECRET_KEYenvironment variable - Use a production WSGI server (e.g., Gunicorn, uWSGI)
- New Response Types: Add patterns to
greetings.pyorcommon_responses.py - UI Changes: Modify templates in
templates/and styles instatic/css/ - Procedure Format: Extend the procedure JSON schema in
app.py
This project is provided as-is for internal use and owned by 1NF1N172.
Note: This application stores data in JSON files. For production use with many users or large datasets, consider migrating to a proper database (PostgreSQL, MySQL, etc.).