A Streamlit web application for managing a small library's operations including members, books, and loans. Provides a user-friendly interface for CRUD operations, searching, and bulk data management.
- User Authentication
- Secure login system for administrators and users.
- Member Management
- Add, update, delete, and retrieve members.
- Bulk upload via CSV.
- Delete prevention if active loans exist.
- Book Management
- Manage books with ISBN, title, author, etc.
- Bulk upload and search by title/author.
- Delete prevention if book is loaned out.
- Loan Management
- Record, update, and delete loans.
- Send email reminders for overdue loans.
- Bulk upload via CSV.
- Data Persistence
- PostgreSQL backend hosted on Neon.tech.
- Security
- Passwords hashed with
bcrypt.
- Passwords hashed with
Passwords are hashed using bcrypt before storage.
- Each password is salted uniquely.
- Prevents rainbow table and brute-force attacks.
- Hashing logic in
sql_auth_functions.py.
| Layer | Technology |
|---|---|
| Frontend | Streamlit |
| Backend | Python |
| Database | PostgreSQL (Neon.tech) |
| ORM | SQLAlchemy |
| Adapter | psycopg2-binary |
| Security | bcrypt |
| Data | Pandas |
| Deploy | Streamlit Cloud |
git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name
### 2. Create a Virtual Environment
```bash
python -m venv venv
# Activate (Windows)
.\venv\Scripts\activate
# Activate (macOS/Linux)
source venv/bin/activatepip install -r requirements.txtMinimal requirements.txt should include:
streamlit
pandas
sqlalchemy
bcrypt
psycopg2-binary
- Sign in to Neon.tech
- Create a new project and database
- Copy the
postgresql://...connection string
- Use DBeaver or similar tool
- Connect with your Neon connection string
- Run the SQL dump and data in the SQL scripts folder to populate database and tables
Run the following SQL commands to avoid ID conflicts:
SELECT setval('members_memberid_seq', (SELECT MAX(memberid) FROM members) + 1, false);
SELECT setval('loans_loanid_seq', (SELECT MAX(loanid) FROM loans) + 1, false);
SELECT setval('users_userid_seq', (SELECT MAX(userid) FROM users) + 1, false);# .streamlit/secrets.toml
DATABASE_URL = "postgresql://user:password@host:port/dbname?project=yourproject"Never commit secrets.toml to public repos.
You can hash passwords using this script:
import bcrypt
password = "your_password".encode('utf-8')
hashed = bcrypt.hashpw(password, bcrypt.gensalt())
print(hashed.decode('utf-8'))Then, insert via SQL:
INSERT INTO users (username, passwordhash, role)
VALUES ('new_user', '$2b$12$EXAMPLEHASHSTRING...', 'user');streamlit run st_app.py- Push code to GitHub (including
requirements.txtand.streamlit/secrets.toml) - Go to Streamlit Cloud
- Log in and create a new app
- Select your repo and main file (
st_app.py) - Click Deploy
📁 your-repo-name/
├── st_app.py # Main entry point
├── p1_overview.py # Library overview UI
├── p2_datainput.py # Forms and data input logic
├── sql_auth_functions.py # User authentication functions
├── sql_con.py # Database connection
├── sql_crud_functions.py # Create, Update, Delete logic
├── sql_read_functions.py # Read/query functions
├── requirements.txt # Dependencies
└── SQL scripts/
└── liana_library_data.sql # Configured scripts for PostgreSQL (data)
└── liana_library_dump.sql # Configured scripts for PostgreSQL (schema)
└── .streamlit/
└── secrets.toml # Secrets (e.g., DATABASE_URL)
- Login: Use provided credentials (e.g.,
admin/admin,liana/user) - Navigate Tabs: Switch between Members, Books, and Loans
- Manage Data: Add, update, delete records or bulk upload CSVs
Thanks to Neon.tech for free PostgreSQL hosting and the Streamlit community for awesome tools!
For any questions or feedback, feel free to reach out: