An intelligent HR management system with AI-powered policy chatbot, automated reimbursement workflows, and secure authentication.
- RAG (Retrieval-Augmented Generation) system using LangChain and Google Gemini
- Interactive chat interface for querying company HR policies
- Source document citations for transparency
- Powered by FAISS vector store for efficient semantic search
- Real-time responses with context-aware answers
- Bill submission with file upload
- AI-generated reimbursement email drafts
- Three categories: Gym, Medicine, Late Sitting Meal
- Automated email scheduling (monthly on last day at 9 AM)
- Draft, scheduled, and sent email tracking
- Multi-step registration: Email → OTP → Password
- Email verification with time-bound OTP (10-minute validity)
- Organization email domain restriction
- Password management
- 30-day email verification expiration
- Backend: Django 5.0.0, Python 3.x
- Database: SQLite3 (development), PostgreSQL recommended for production
- AI/ML:
- LangChain for RAG orchestration
- Google Gemini API for LLM
- HuggingFace Sentence Transformers for embeddings
- FAISS for vector similarity search
- Email: Django SMTP with Gmail
- Task Scheduling: django-crontab
- Frontend: HTML5, CSS3, Vanilla JavaScript
- Python 3.8+
- pip
- Virtual environment (recommended)
- Google Gemini API key
- Gmail account with app password
-
Clone the repository
git clone https://github.com/farooq78692/docsnow.git cd docsnow -
Create and activate virtual environment
python -m venv venv # On macOS/Linux: source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
cp .env.example .env
Edit
.envand add your credentials:DJANGO_SECRET_KEY=your-secret-key-here DEBUG=True ALLOWED_HOSTS=localhost,127.0.0.1 GOOGLE_API_KEY=your_google_gemini_api_key EMAIL_HOST_USER=your_email@gmail.com EMAIL_HOST_PASSWORD=your_gmail_app_password DEFAULT_FROM_EMAIL=your_email@gmail.com HR_EMAIL_RECIPIENT=hr@yourcompany.com
-
Run database migrations
python manage.py migrate
-
Create a superuser
python manage.py createsuperuser
-
Add HR policy document
- Place your HR policies PDF in
data/hr_policies.pdf - The system will automatically process it on first use
- Place your HR policies PDF in
-
Run the development server
python manage.py runserver
-
Access the application
- Main app: http://localhost:8000
- Admin panel: http://localhost:8000/admin
- Go to Google AI Studio
- Create a new API key
- Add it to your
.envfile asGOOGLE_API_KEY
- Enable 2-Factor Authentication on your Gmail account
- Generate an App Password
- Use the app password in
.envasEMAIL_HOST_PASSWORD
To restrict registration to specific email domains:
- Edit
authentication/utils.py:44 - Modify the
allowed_domainslist:allowed_domains = ['yourcompany.com', 'yourdomain.net']
Set the default HR recipient in .env:
HR_EMAIL_RECIPIENT=hr@yourcompany.com-
Registration
- Visit
/auth/register/ - Enter your organization email
- Verify with OTP sent to your email
- Complete registration with password
- Visit
-
HR Policy Chatbot
- Navigate to the chatbot after login
- Ask questions about company policies
- View source references for each answer
-
Submit Reimbursement
- Go to "Submit Bill" in navigation
- Upload bill image/document
- Select category and enter amount
- AI generates email draft automatically
- Review and edit email before scheduling
-
Manage Emails
- View all your scheduled/sent emails
- Edit draft emails
- Track email status
-
Access Admin Panel
- Visit
/admin/ - Login with superuser credentials
- Visit
-
Manage Users
- View registered users
- Check email verification status
- Manage user permissions
-
Monitor Bills & Emails
- Review submitted bills
- Track email sending status
- View scheduled emails
The system automatically sends scheduled reimbursement emails on the last day of each month at midnight UTC.
Setup cron job:
-
Add cron jobs to system:
python manage.py crontab add
-
Verify cron jobs:
python manage.py crontab show
-
Remove cron jobs (if needed):
python manage.py crontab remove
docsnow/
├── authentication/ # User auth, registration, email verification
│ ├── models.py # User, EmailVerification, RegistrationSession
│ ├── views.py # Registration, login, profile
│ ├── forms.py # Email, OTP, registration forms
│ └── utils.py # Email sending, OTP generation
├── chatbot/ # AI-powered HR chatbot
│ ├── views.py # Chat interface and API endpoint
│ └── utils/
│ └── langchain_utils.py # RAG chain setup
├── billings/ # Reimbursement management
│ ├── models.py # Bill, Email models
│ ├── views.py # Bill submission, email management
│ ├── forms.py # Bill and email forms
│ ├── cron.py # Scheduled email sending
│ └── utils.py # Email utilities
├── hr_chatbot/ # Django project settings
│ ├── settings.py # Configuration
│ └── urls.py # URL routing
├── templates/ # HTML templates
│ ├── authentication/ # Auth templates
│ ├── chatbot/ # Chat interface
│ ├── billings/ # Bill & email templates
│ └── shared/ # Base templates, navbar
├── data/
│ └── hr_policies.pdf # Source document for RAG
├── bills/ # Uploaded bill files
├── vectorstore/ # FAISS vector store cache
├── .env # Environment variables (DO NOT COMMIT)
├── .env.example # Environment template
├── .gitignore # Git ignore rules
├── requirements.txt # Python dependencies
└── manage.py # Django management script
POST /api/chat/
Send a question to the HR chatbot.
Request:
{
"question": "What is the vacation policy?"
}Response:
{
"answer": "According to company policy...",
"sources": [
{
"content": "Relevant excerpt from policy document...",
"metadata": {
"page": 5,
"source": "hr_policies.pdf"
}
}
]
}Authentication: Required (session-based)
CSRF: Required (include X-CSRFToken header)
User (extends AbstractUser)
email: Primary identifier (unique)email_verified: Boolean flagemail_verified_date: Verification timestampcreated_at: Account creation date
EmailVerification
id: UUID primary keyemail: Email addressotp: 6-digit verification codeis_used: Usage statusexpires_at: Expiration timestamp
RegistrationSession
id: UUID primary keyemail: Registration emailemail_verified: Email verification statusotp_verified: OTP verification statusexpires_at: Session expiration
Bill
file: Uploaded bill documentbill_category: Gym / Medicine / Late Sitting Mealbill_amount: Decimal fieldraw_text: OCR/extracted text (optional)uploaded_at: Upload timestamp
user: Foreign key to Usersubject: Email subjectbody: Email contentrecipient: Recipient email addresscc,bcc: Optional fieldsstatus: Draft / Scheduled / Sentbill: Foreign key to Bill (optional)scheduled_time: When to sendsent_at: Actual send timecreated_at,updated_at: Timestamps
- Never commit
.envfile - Contains sensitive credentials - Change Django SECRET_KEY - Generate a new one for production
- Set DEBUG=False in production
- Configure ALLOWED_HOSTS with your domain
- Use HTTPS in production
- Rotate API keys regularly
- Review file upload permissions on bills directory
- Set
DEBUG=False - Configure
ALLOWED_HOSTSwith your domain - Use PostgreSQL instead of SQLite
- Set up proper logging
- Configure static files with WhiteNoise or CDN
- Set up SSL/TLS certificates
- Use environment-specific settings
- Set up database backups
- Configure rate limiting
- Set up monitoring and alerts
- Review and update dependencies
1. Vector store error on first chatbot use
- Cause: FAISS index not created yet
- Solution: The system will automatically create it on first query (may take 30-60 seconds)
2. OTP not received
- Cause: Gmail authentication failure
- Solution: Verify Gmail app password is correct, check spam folder
3. CSRF verification failed on chat
- Cause: Missing CSRF token in request
- Solution: Clear browser cookies and reload page
4. Bill file upload fails
- Cause:
bills/directory permissions - Solution: Ensure
bills/directory exists and is writable
5. Scheduled emails not sending
- Cause: Cron job not configured
- Solution: Run
python manage.py crontab add
python manage.py testpython manage.py makemigrations
python manage.py migratepython manage.py collectstaticThis project follows PEP 8 guidelines. Use tools like black and flake8:
pip install black flake8
black .
flake8 .- Hosting: AWS EC2, DigitalOcean, Heroku, or Railway
- Database: PostgreSQL
- Web Server: Gunicorn + Nginx
- SSL: Let's Encrypt (Certbot)
- Static Files: AWS S3 or WhiteNoise
DJANGO_SECRET_KEY=<generate-strong-secret-key>
DEBUG=False
ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
DATABASE_URL=postgresql://user:pass@host:port/dbname
GOOGLE_API_KEY=<your-api-key>
EMAIL_HOST_USER=<your-email>
EMAIL_HOST_PASSWORD=<app-password>
DEFAULT_FROM_EMAIL=<from-email>
HR_EMAIL_RECIPIENT=<hr-email># Install Heroku CLI and login
heroku login
# Create app
heroku create your-app-name
# Set environment variables
heroku config:set DJANGO_SECRET_KEY=your-secret
heroku config:set DEBUG=False
# ... set all other env vars
# Add PostgreSQL
heroku addons:create heroku-postgresql:hobby-dev
# Deploy
git push heroku main
# Run migrations
heroku run python manage.py migrate
# Create superuser
heroku run python manage.py createsuperuserContributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.
For issues, questions, or contributions:
- GitHub Issues: https://github.com/farooq78692/docsnow/issues
- Email: Contact the maintainers
- Django framework and community
- LangChain for RAG infrastructure
- Google Gemini for AI capabilities
- HuggingFace for embedding models
- FAISS for vector search
Built with Django & AI | Made for efficient HR management