A comprehensive lecture management system built with React, Firebase, and TypeScript. This system allows universities to manage lectures, users, and educational content with role-based access control.
- 🔐 Role-based authentication (Admin, Teacher, Student)
- 📚 Lecture management with PDF support
- 👥 User management system
- 🏷️ Category management for subjects and stages
- ❤️ Favorite lectures functionality
- ✅ Lecture completion tracking
- 🔍 Advanced search and filtering
- 📱 Responsive design
Before you begin, ensure you have the following installed:
-
Clone the repository:
git clone https://github.com/yourusername/lecture-management-system.git cd lecture-management-system -
Install dependencies:
npm install
-
Create a Firebase project:
- Go to Firebase Console
- Create a new project
- Enable Authentication with Email/Password
- Create a Firestore database
- Create a Storage bucket
- Get your Firebase configuration
-
Set up Firebase configuration:
- Create a
.envfile in the root directory - Add your Firebase configuration to the
.envfile using the following format:VITE_FIREBASE_API_KEY=your_api_key VITE_FIREBASE_AUTH_DOMAIN=your_project_id.firebaseapp.com VITE_FIREBASE_PROJECT_ID=your_project_id VITE_FIREBASE_STORAGE_BUCKET=your_project_id.appspot.com VITE_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id VITE_FIREBASE_APP_ID=your_app_id VITE_FIREBASE_MEASUREMENT_ID=your_measurement_id - Note: The
.envfile is excluded from git to protect your API keys and sensitive information
- Create a
-
Start the development server:
npm run dev
Make sure to set up the following security rules in your Firebase console:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Allow authenticated users to read all documents
match /{document=**} {
allow read: if request.auth != null;
}
// Allow authenticated users to create and update lectures
match /lectures/{lectureId} {
allow create, update: if request.auth != null;
allow delete: if request.auth != null && (
// Allow admins to delete any lecture
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin' ||
// Allow users to delete their own lectures
resource.data.uploadedBy == request.auth.uid
);
}
// Allow admins to manage users
match /users/{userId} {
allow create: if request.auth != null;
allow update, delete: if request.auth != null &&
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin';
}
}
}
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
// Allow read access to all authenticated users
match /{allPaths=**} {
allow read: if request.auth != null;
}
// Allow write access to the lectures folder for authenticated users
match /lectures/{fileName} {
allow write: if request.auth != null;
}
}
}
The system includes an AI Chat feature powered by n8n workflows. This allows users to chat with an AI assistant that can be customized via n8n.
- Frontend: React component (
AIChat.tsx) sends POST requests with user message, name, and role. - Proxy: Vite (
vite.config.ts) forwards requests from/api/n8nto the actual n8n server to handle CORS. - Backend (n8n): Receives the webhook, processes the message (e.g., using OpenAI/Anthropic), stores the chat in PostgreSQL, and returns a response.
-
Environment Variables: Add your n8n webhook URL to
.env:# Use the local proxy path (recommended for dev) VITE_N8N_WEBHOOK_URL=/api/n8n/webhook/your-workflow-name -
n8n Workflow:
- Create a Webhook node:
- Method:
POST - Path:
your-postgresql-table-name
- Method:
- Create a PostgreSQL node (to store chats):
- Operation:
Execute Query - Query:
INSERT INTO "your-postgresql-table-name" (user_name, user_role, message, "date", "timestamp") VALUES ('{{ $json.body.user }}', '{{ $json.body.role }}', '{{ $json.body.message }}', '{{ $json.body.date }}', '{{ $json.body.timestamp }}');
- Note: Ensure you handle single quotes in messages safely.
- Operation:
- Create a Webhook node:
-
Database Schema: Run this SQL in your PostgreSQL database to create the required table:
CREATE TABLE "your-postgresql-table-name" ( id SERIAL PRIMARY KEY, user_name VARCHAR(255) NOT NULL, user_role VARCHAR(50) NOT NULL, message TEXT NOT NULL, date DATE, timestamp TIMESTAMPTZ, created_at TIMESTAMPTZ DEFAULT NOW() );
src/
├── App.tsx # Main application component
├── App.css # Application styles
├── firebase.ts # Firebase configuration
├── index.css # Global styles
├── main.tsx # Application entry point
└── vite-env.d.ts # TypeScript declarations
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production build locallynpm run lint- Run ESLint
This project is configured for easy deployment to Netlify. You can deploy in two ways:
-
Netlify CLI:
npm install -g netlify-cli netlify deploy
-
Netlify UI:
- Connect your GitHub repository
- Configure build settings:
- Build command:
npm run build - Publish directory:
dist
- Build command:
- Deploy
- Fork the repository
- Create your 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
Made with ❤️ by @AhmadTchnology [github.com/AhmadTchnology]