How ashrafino/web-application-for-hr-management-with-rag-chatbot-integration works
Project type and purpose
• This is a full-stack web application (HRMS) built with Flask (Python) on the backend, SQLAlchemy/SQLite for persistence, and a Bootstrap/HTML/CSS/JavaScript frontend.
• It includes core HR features (leave, event, user management), Excel import/export, and an intelligent RAG-based chatbot via Ollama.
File structure
• Top-level files:
• app.py – Flask application entry point
• config.py – environment and DB configuration
• routes.py – HTTP endpoints / controller logic
• data.db – SQLite database file
• requirements.txt – Python dependencies
• log/ – application logs
• test_import.xlsx – sample data for import
• Directories:
• static/ – client assets (CSS, JS, images, calendar widget)
• templates/ – Jinja2 HTML views, one per major page (add/edit/list for users/events, chatbot, import, login, home)
• Key patterns: MVC-style separation (templates = Views, routes = Controllers, SQLAlchemy models = Models), plus an external service integration (Ollama).
README for stack details
• Backend: Flask, SQLAlchemy, Pandas for Excel, Ollama API for RAG
• Frontend: Bootstrap, custom JS (calendar drag/drop, chatbot UI)
• Data store: SQLite (data.db) via ORM
• No microservices—monolithic codebase with third-party service call.
Main components and interactions
a. Frontend (Browser/UI)
• Serves HTML templates, CSS, JS.
• Pages: login, dashboard (leave, event, user management), chatbot interface.
• JS calls backend endpoints (e.g., /api/events, /api/chatbot).
b. Backend (Flask Server)
• app.py initializes Flask, loads config.py settings.
• routes.py defines endpoints:
• CRUD for users, events, leaves
• Excel import/export (Pandas)
• Chatbot endpoint that queries DB and forwards context to Ollama
• Business logic + SQLAlchemy ORM models handle data operations.
c. Database (SQLite)
• data.db: persistent store for user profiles, leave records, events.
• SQLAlchemy sessions abstract queries.
d. External Service (Ollama)
• RAG pipeline: backend queries SQLite for relevant HR data → packages “retrieved” context → sends to Ollama API → returns generated answer → backend returns JSON to client.
e. Logging & Configuration
• log/ folder captures application and error logs.
• config.py holds DB path, Flask secret keys, Ollama endpoint credentials.
Architectural patterns & design principles
• MVC-inspired layering
• Single responsibility: routes.py / app.py separate from templates and static assets
• Modular: each feature (leave, event, user, chatbot) grouped by route + template
• RAG pattern for chatbot (Data Retrieval + Language Generation)