This project is part of the AIMlearning project, which is co-funded by the European Union. The project will run from 1.2.2024 to 30.4.2027.
A web application for COPSA tutors to log their tutoring hours and for administrators to review and manage submissions. Built with Express.js, MongoDB, and EJS templating.
This application allows tutors to:
- Log in via Google OAuth
- Submit tutoring session entries with details (date, location, description, hours)
- Track the status of their submissions (draft, submitted, approved, rejected)
- Switch between English and Finnish languages
Administrators can:
- View all tutor submissions
- Approve or reject tutoring entries
- Export data for reporting
- Send email notifications to tutors
- Google OAuth Authentication: Secure login using Google accounts
- Role-Based Access Control: Separate interfaces for tutors and administrators
- Internationalization (i18n): Full support for English and Finnish languages
- Session Management: Secure session handling with configurable cookies
- Email Notifications: Automated email alerts for submission status changes
- Status Tracking: Track submissions through draft, submitted, approved, and rejected states
- Admin Dashboard: Comprehensive overview of all tutoring sessions
- Audit Logging: Complete history of admin review actions
- Responsive Design: Mobile-friendly interface
The landing page with Google OAuth authentication
Tutor dashboard showing session management and submission tracking
Detailed form for logging tutoring sessions with validation
Administrator dashboard with session review and filtering options
Admin interface for reviewing and approving/rejecting submissions
- Backend: Node.js with Express.js
- Database: MongoDB with Mongoose ODM
- Authentication: Passport.js with Google OAuth 2.0
- Templating: EJS (Embedded JavaScript)
- Email: Nodemailer
- Internationalization: i18n
- Testing: Jest with Supertest and MongoDB Memory Server
- Session Management: express-session
Before running this application, ensure you have:
- Node.js: v14 or higher
- MongoDB: v4.4 or higher (local or cloud instance)
- Google OAuth Credentials: Client ID and Client Secret from Google Cloud Console
- Email Account: SMTP credentials for sending emails (Gmail recommended)
-
Clone the repository
git clone https://github.com/AIMlearningProject/tutor-application/ cd Tutor-Application--main -
Install dependencies
npm install
-
Configure environment variables
Copy the
.envfile and update with your credentials:cp .env .env.local
Edit
.envwith your actual values:# Server Configuration PORT=3000 NODE_ENV=development # Session Secret (generate a secure random string) SESSION_SECRET=your_secure_random_session_secret_here # Google OAuth 2.0 Credentials GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret GOOGLE_CALLBACK_URL=http://localhost:3000/auth/google/callback # MongoDB Connection MONGO_URI=mongodb://localhost:27017/copsa_tutor_app # Admin Configuration ADMIN_EMAIL=admin@example.com # Email Configuration (for Nodemailer) EMAIL_USER=your_email@gmail.com EMAIL_PASS=your_app_specific_password
-
Set up Google OAuth
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URI:
http://localhost:3000/auth/google/callback - Copy Client ID and Client Secret to
.envfile
-
Set up MongoDB
Option A - Local MongoDB:
# Start MongoDB service mongod --dbpath=/path/to/data/directoryOption B - MongoDB Atlas (Cloud):
- Create account at MongoDB Atlas
- Create a cluster
- Get connection string and add to
MONGO_URIin.env
npm startThe application will be available at http://localhost:3000
Run all tests:
npm testRun tests with watch mode:
npm run test:watchRun unit tests only:
npm run test:unitRun integration tests only:
npm run test:integrationView test coverage:
npm test
# Coverage report will be in ./coverage directoryTutor-Application--main/
├── src/
│ ├── app.js # Main application entry point
│ ├── emailService.js # Email notification service
│ ├── locales/ # Internationalization files
│ │ ├── en.json # English translations
│ │ └── fi.json # Finnish translations
│ ├── middleware/ # Custom middleware
│ │ ├── auth.js # Authentication middleware
│ │ └── validation.js # Input validation middleware
│ ├── models/ # Mongoose data models
│ │ ├── AdminReviewLog.js # Admin review audit log
│ │ ├── TutorSession.js # Tutoring session entries
│ │ └── User.js # User accounts
│ ├── routes/ # Express route handlers
│ │ ├── adminRoutes.js # Admin-specific routes
│ │ ├── authRoutes.js # Authentication routes
│ │ └── tutorRoutes.js # Tutor-specific routes
│ └── views/ # EJS templates
│ ├── adminDashboard.ejs # Admin dashboard view
│ ├── dashboard.ejs # Tutor dashboard view
│ ├── error.ejs # Error page
│ ├── index.ejs # Landing page
│ └── tutorForm.ejs # Session submission form
├── public/ # Static assets
│ ├── index.html # Static HTML files
│ └── styles.css # CSS stylesheets
├── tests/ # Test files
│ ├── unit/ # Unit tests
│ └── integration/ # Integration tests
├── coverage/ # Test coverage reports
├── .env # Environment variables (not in git)
├── package.json # Node.js dependencies and scripts
├── softwareplan.md # Original software requirements
└── README.md # This file
{
googleId: String, // Google OAuth ID
name: String, // User's full name
email: String, // User's email address
role: String, // 'tutor' or 'admin'
language_preference: String, // 'en' or 'fi'
created_at: Date,
updated_at: Date
}{
user_id: ObjectId, // Reference to User
tutorName: String, // Tutor's name
tutorEmail: String, // Tutor's email
date: Date, // Session date
location: String, // Session location
description: String, // Session description
hours: Number, // Hours worked (min: 0.5)
status: String, // 'draft', 'submitted', 'approved', 'rejected'
submitted_at: Date, // When submitted
reviewed_at: Date, // When reviewed
review_note: String, // Admin's review note
created_at: Date,
updated_at: Date
}{
admin_id: ObjectId, // Reference to admin User
entry_id: ObjectId, // Reference to TutorSession
action: String, // 'approved' or 'rejected'
note: String, // Review notes
timestamp: Date
}GET /auth/google- Initiate Google OAuth loginGET /auth/google/callback- Google OAuth callbackGET /auth/logout- Logout user
GET /tutor/sessions- View tutor's own sessionsPOST /tutor/sessions- Create new sessionPUT /tutor/sessions/:id- Update session (draft only)DELETE /tutor/sessions/:id- Delete session (draft only)POST /tutor/sessions/:id/submit- Submit session for review
GET /admin/sessions- View all sessionsGET /admin/sessions/:id- View session detailsPOST /admin/sessions/:id/approve- Approve sessionPOST /admin/sessions/:id/reject- Reject sessionGET /admin/export- Export sessions to CSV/Excel
GET /- Landing pageGET /dashboard- User dashboard (role-based)GET /language/:lang- Switch language (en/fi)
The application supports English and Finnish languages. Language files are located in src/locales/:
en.json- English translationsfi.json- Finnish translations
Users can switch languages using the language selector in the UI. Language preference is:
- Stored in user profile (if logged in)
- Stored in cookie (if not logged in)
- Auto-detected from browser settings
- Log tutoring sessions
- Submit sessions for approval
- View own session history
- Track submission status
- Edit/delete draft sessions
- View all tutor sessions
- Approve or reject submissions
- Add review notes
- Export data for reporting
- Manage user roles
- Send email notifications
The application sends automated emails for:
- New session submissions (to admin)
- Session approval (to tutor)
- Session rejection (to tutor)
Configure email settings in .env:
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_app_specific_passwordNote: For Gmail, use App-Specific Passwords
- OAuth 2.0: Secure authentication via Google
- Session Management: Secure cookies with httpOnly and secure flags
- Role-Based Access: Route protection based on user roles
- Input Validation: Server-side validation for all inputs
- CSRF Protection: Session-based CSRF tokens
- Secure Headers: Production-ready security headers
- Audit Logging: Complete history of admin actions
Update .env for production:
NODE_ENV=production
PORT=3000
SESSION_SECRET=<generate-strong-random-string>
GOOGLE_CALLBACK_URL=https://yourdomain.com/auth/google/callback
MONGO_URI=<production-mongodb-uri>Option 1 - Heroku
heroku create copsa-tutor-app
heroku config:set SESSION_SECRET=<secret>
heroku config:set GOOGLE_CLIENT_ID=<id>
heroku config:set GOOGLE_CLIENT_SECRET=<secret>
heroku config:set MONGO_URI=<uri>
git push heroku mainOption 2 - Render
- Connect GitHub repository
- Set environment variables in Render dashboard
- Deploy automatically on git push
Option 3 - Docker
FROM node:14
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
EXPOSE 3000
CMD ["npm", "start"]-
Create a feature branch
git checkout -b feature/your-feature-name
-
Make changes and test
npm test -
Commit changes
git add . git commit -m "Description of changes"
-
Push and create PR
git push origin feature/your-feature-name
- Ensure MongoDB is running:
mongod - Check
MONGO_URIin.env - Verify network connectivity for cloud MongoDB
- Verify Client ID and Secret in
.env - Check authorized redirect URIs in Google Console
- Ensure callback URL matches
.envconfiguration
- Verify
SESSION_SECRETis set - Clear browser cookies
- Check session configuration in
app.js
- Verify email credentials in
.env - Use app-specific password for Gmail
- Check spam folder for test emails
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new features
- Ensure all tests pass
- Submit a pull request
ISC
For issues, questions, or contributions, please:
- Open an issue in the repository
- Contact the development team
- Refer to
softwareplan.mdfor design decisions
- COPSA - Community Peer Support Association
- Centria University of Applied Sciences
- All tutors and administrators using this application