Flask web application for library operations — book catalog, member management, loans, role-based access, admin dashboards, backups, and reporting — backed by Microsoft SQL Server.
- System Design
- Features
- Technology Stack
- Getting Started
- Configuration
- Deployment
- Project Structure
- License
A server-rendered Flask monolith with blueprint-based auth and raw SQL via pyodbc. Role decorators gate access to Admin, Staff, Member, and Guest dashboards. Database bootstrap runs on startup to seed default roles and an admin account.
flowchart TB
Browser[Browser]
Flask[Flask App]
Auth[auth.py Blueprint]
SQL[(SQL Server)]
Templates[Jinja2 Templates]
Browser --> Flask
Flask --> Auth
Flask --> Templates
Flask --> SQL
| Layer | Role |
|---|---|
| app.py | Core routes, CRUD, reports, backup/restore |
| auth.py | Login, register, role decorators |
| models.py | Data classes (no ORM) |
| database/ | Setup scripts, sample data, triggers/procedures |
- Role-based dashboards: Admin, Staff, Member, Guest
- Book catalog CRUD, issue/return workflows
- Member management and loan history API
- User/role admin: add, edit, reset password, toggle status
- Activity logs, statistics, and report generation
- Database backup, restore, and download (admin)
- Auto-creates default roles, admin user, and categories on startup
| Component | Technology |
|---|---|
| Backend | Python 3, Flask 2.2 |
| Database | Microsoft SQL Server via pyodbc |
| Auth driver | ODBC Driver 17 for SQL Server |
| Templates | Jinja2 |
| Data access | Raw SQL (no ORM) |
- Python 3.8+
- Microsoft SQL Server
- ODBC Driver 17 for SQL Server
- pyodbc (
pip install pyodbc— not listed inrequirements.txt)
pip install -r requirements.txt
pip install pyodbc
# 1. Create database — run in SQL Server:
# database/setup_database.sql
# 2. Optional bootstrap:
python init_db.py
# 3. Start server:
python app.py
# → http://localhost:5000 (debug mode)| Variable | Default | Purpose |
|---|---|---|
SECRET_KEY |
mysecretlibrarysystem |
Flask session secret |
DB_DRIVER |
ODBC Driver 17 for SQL Server |
ODBC driver name |
Connection uses Windows Trusted Connection (Trusted_Connection=yes). Update config.py with your SQL Server host and database name for your environment.
Designed for on-premises Windows + SQL Server:
- Install SQL Server and ODBC Driver 17
- Run
database/setup_database.sql - Configure
config.pyfor your server - Run behind IIS or a WSGI server for production
No Docker configuration included.
Library-Management-System/
├── app.py
├── auth.py
├── config.py
├── models.py
├── init_db.py
├── database/
│ ├── setup_database.sql
│ ├── sample_data.sql
│ └── triggers_functions_procedures.sql
├── templates/
└── static/css|js/
See repository for license terms.