raymondEDS commited on
Commit
05152ad
Β·
1 Parent(s): 4e16788
Files changed (2) hide show
  1. README.md +23 -6
  2. src/streamlit_app.py +26 -37
README.md CHANGED
@@ -16,7 +16,7 @@ short_description: LMS with login and PDF upload
16
 
17
  # Dev LMS - Learning Management System
18
 
19
- A comprehensive Learning Management System built with Streamlit that provides user authentication and PDF document management capabilities.
20
 
21
  ## πŸš€ Features
22
 
@@ -31,6 +31,7 @@ A comprehensive Learning Management System built with Streamlit that provides us
31
  - Text extraction from PDF files
32
  - Document preview and search functionality
33
  - Document library with user ownership tracking
 
34
 
35
  ### πŸ“Š Dashboard
36
  - User activity metrics
@@ -56,6 +57,7 @@ The system comes with three default user accounts:
56
 
57
  ## πŸ› οΈ Installation & Usage
58
 
 
59
  1. **Install Dependencies:**
60
  ```bash
61
  pip install -r requirements.txt
@@ -65,21 +67,28 @@ The system comes with three default user accounts:
65
  ```bash
66
  streamlit run src/streamlit_app.py
67
  ```
 
 
 
 
68
 
69
  3. **Access the Application:**
70
  - Open your browser and go to `http://localhost:8501`
71
  - Login with one of the default credentials
72
  - Start uploading and managing PDF documents!
73
 
 
 
 
74
  ## πŸ“ Application Structure
75
 
76
  ```
77
  β”œβ”€β”€ src/
78
  β”‚ └── streamlit_app.py # Main application file
79
- β”œβ”€β”€ data/ # Data storage (created automatically)
80
- β”‚ β”œβ”€β”€ documents/ # Document storage
81
- β”‚ └── users/ # User configuration
82
  β”œβ”€β”€ requirements.txt # Python dependencies
 
83
  └── README.md # This file
84
  ```
85
 
@@ -88,8 +97,9 @@ The system comes with three default user accounts:
88
  - **Framework:** Streamlit
89
  - **Authentication:** streamlit-authenticator
90
  - **PDF Processing:** PyPDF2
91
- - **Data Storage:** Session state + YAML configuration
92
  - **Security:** bcrypt password hashing
 
93
 
94
  ## 🎯 Use Cases
95
 
@@ -106,6 +116,13 @@ The system comes with three default user accounts:
106
  - Document ownership tracking
107
  - Secure file upload handling
108
 
 
 
 
 
 
 
 
109
  ## πŸ“ˆ Future Enhancements
110
 
111
  - Database integration for persistent storage
@@ -117,4 +134,4 @@ The system comes with three default user accounts:
117
 
118
  ---
119
 
120
- **Built with ❀️ using Streamlit**
 
16
 
17
  # Dev LMS - Learning Management System
18
 
19
+ A comprehensive Learning Management System built with Streamlit that provides user authentication and PDF document management capabilities. **Cloud-ready and optimized for Hugging Face Spaces deployment.**
20
 
21
  ## πŸš€ Features
22
 
 
31
  - Text extraction from PDF files
32
  - Document preview and search functionality
33
  - Document library with user ownership tracking
34
+ - **Cloud-ready storage using session state**
35
 
36
  ### πŸ“Š Dashboard
37
  - User activity metrics
 
57
 
58
  ## πŸ› οΈ Installation & Usage
59
 
60
+ ### Local Development
61
  1. **Install Dependencies:**
62
  ```bash
63
  pip install -r requirements.txt
 
67
  ```bash
68
  streamlit run src/streamlit_app.py
69
  ```
70
+ Or use the convenient startup script:
71
+ ```bash
72
+ python run_app.py
73
+ ```
74
 
75
  3. **Access the Application:**
76
  - Open your browser and go to `http://localhost:8501`
77
  - Login with one of the default credentials
78
  - Start uploading and managing PDF documents!
79
 
80
+ ### Cloud Deployment
81
+ The application is optimized for deployment on Hugging Face Spaces and other cloud platforms. No file system permissions required - all data is stored in session state.
82
+
83
  ## πŸ“ Application Structure
84
 
85
  ```
86
  β”œβ”€β”€ src/
87
  β”‚ └── streamlit_app.py # Main application file
88
+ β”œβ”€β”€ .streamlit/
89
+ β”‚ └── config.toml # Streamlit configuration
 
90
  β”œβ”€β”€ requirements.txt # Python dependencies
91
+ β”œβ”€β”€ run_app.py # Startup script
92
  └── README.md # This file
93
  ```
94
 
 
97
  - **Framework:** Streamlit
98
  - **Authentication:** streamlit-authenticator
99
  - **PDF Processing:** PyPDF2
100
+ - **Data Storage:** Session state (cloud-ready)
101
  - **Security:** bcrypt password hashing
102
+ - **Deployment:** Optimized for Hugging Face Spaces
103
 
104
  ## 🎯 Use Cases
105
 
 
116
  - Document ownership tracking
117
  - Secure file upload handling
118
 
119
+ ## ☁️ Cloud Features
120
+
121
+ - **No file system dependencies** - works on read-only environments
122
+ - **Session-based storage** - data persists during user session
123
+ - **Optimized for Hugging Face Spaces** - ready for immediate deployment
124
+ - **Lightweight and fast** - minimal resource requirements
125
+
126
  ## πŸ“ˆ Future Enhancements
127
 
128
  - Database integration for persistent storage
 
134
 
135
  ---
136
 
137
+ **Built with ❀️ using Streamlit | Cloud-ready for Hugging Face Spaces**
src/streamlit_app.py CHANGED
@@ -24,50 +24,39 @@ if 'username' not in st.session_state:
24
  st.session_state.username = None
25
  if 'uploaded_documents' not in st.session_state:
26
  st.session_state.uploaded_documents = {}
27
-
28
- # Create data directory if it doesn't exist
29
- os.makedirs('data', exist_ok=True)
30
- os.makedirs('data/documents', exist_ok=True)
31
- os.makedirs('data/users', exist_ok=True)
32
-
33
- # User configuration file
34
- USERS_FILE = 'data/users/users.yaml'
35
 
36
  def create_default_users():
37
- """Create default users if the users file doesn't exist"""
38
- if not os.path.exists(USERS_FILE):
39
- default_users = {
40
- 'credentials': {
41
- 'usernames': {
42
- 'admin': {
43
- 'email': 'admin@example.com',
44
- 'name': 'Administrator',
45
- 'password': stauth.Hasher(['admin123']).generate()[0]
46
- },
47
- 'teacher': {
48
- 'email': 'teacher@example.com',
49
- 'name': 'Teacher',
50
- 'password': stauth.Hasher(['teacher123']).generate()[0]
51
- },
52
- 'student': {
53
- 'email': 'student@example.com',
54
- 'name': 'Student',
55
- 'password': stauth.Hasher(['student123']).generate()[0]
56
- }
57
  }
58
  }
59
  }
60
-
61
- os.makedirs(os.path.dirname(USERS_FILE), exist_ok=True)
62
- with open(USERS_FILE, 'w') as file:
63
- yaml.dump(default_users, file, default_flow_style=False)
64
 
65
  def load_users():
66
- """Load users from YAML file"""
67
- create_default_users()
68
- with open(USERS_FILE) as file:
69
- config = yaml.load(file, Loader=SafeLoader)
70
- return config
71
 
72
  def save_document_info(username, filename, file_content, file_type):
73
  """Save document information to session state"""
 
24
  st.session_state.username = None
25
  if 'uploaded_documents' not in st.session_state:
26
  st.session_state.uploaded_documents = {}
27
+ if 'users_config' not in st.session_state:
28
+ st.session_state.users_config = None
 
 
 
 
 
 
29
 
30
  def create_default_users():
31
+ """Create default users configuration"""
32
+ default_users = {
33
+ 'credentials': {
34
+ 'usernames': {
35
+ 'admin': {
36
+ 'email': 'admin@example.com',
37
+ 'name': 'Administrator',
38
+ 'password': stauth.Hasher(['admin123']).generate()[0]
39
+ },
40
+ 'teacher': {
41
+ 'email': 'teacher@example.com',
42
+ 'name': 'Teacher',
43
+ 'password': stauth.Hasher(['teacher123']).generate()[0]
44
+ },
45
+ 'student': {
46
+ 'email': 'student@example.com',
47
+ 'name': 'Student',
48
+ 'password': stauth.Hasher(['student123']).generate()[0]
 
 
49
  }
50
  }
51
  }
52
+ }
53
+ return default_users
 
 
54
 
55
  def load_users():
56
+ """Load users configuration"""
57
+ if st.session_state.users_config is None:
58
+ st.session_state.users_config = create_default_users()
59
+ return st.session_state.users_config
 
60
 
61
  def save_document_info(username, filename, file_content, file_type):
62
  """Save document information to session state"""