- Project Overview
- Key Features
- Problem Solving
- Technology Stack
- Frontend Implementation
- Backend Implementation
- Integration Points
- Deployment and CI/CD
- Database Structure
- URL Endpoints
- API Features
- Deployment
- Troubleshooting
- User Manual
The UWA Curriculum Rules Management System is a sophisticated web-based platform designed to streamline and enhance the process of managing course rules across various academic programs at the University of Western Australia.
By digitalizing and automating many aspects of course rule management, the system aims to reduce administrative burden, minimize errors, and improve the overall quality and consistency of course information.
The demo is hosted at curriculum-app.fudong.dev
-
Intuitive Rule Management:
- Drag-and-drop interface for easy rule ordering and structuring
- Support for nested rule hierarchies
- Real-time editing and updating of course rules
-
Flexible Course Handling:
- Creation and management of various course types (e.g., Graduate Certificate, Master's, Doctoral programs)
- Version control for course rules, allowing historical tracking and future planning
-
Smart Numbering System:
- Automatic numbering of rules and sub-rules
- Customizable numbering styles (Numeric, Alphabetic, Roman, None)
-
Role-Based Access Control:
- Distinct roles for administrators and regular users
- Tailored permissions ensuring appropriate access and editing rights
-
Standard Rules Library:
- Pre-defined set of standard rules for different course types
- Easy application and customization of standard rules to specific courses
-
Document Generation:
- Automated generation of course rule documents in PDF and HTML formats
- Consistent formatting adhering to university standards
-
User-Friendly Interface:
- Responsive design for desktop and mobile access
- Intuitive navigation and search functionality
This system addresses several key challenges faced by the university:
- Consistency: Ensures uniformity in rule structure and presentation across all courses.
- Efficiency: Reduces the time and effort required to update and manage course rules.
- Accuracy: Minimizes human error through automated processes and standardized templates.
- Accessibility: Provides easy access to up-to-date course information for all stakeholders.
- Compliance: Helps maintain adherence to university and regulatory standards.
The system leverages a modern, robust technology stack:
- Frontend: Next.js, React, TypeScript, Tailwind CSS
- Backend: NestJS, TypeORM
- Database: MySQL
- Authentication: JWT (JSON Web Tokens)
- Deployment: Docker, Jenkins
- Cloud Services: Oracle Cloud, Cloudflare
The frontend of the UWA Curriculum Rules Management System is built using modern web technologies to create a responsive, efficient, and user-friendly interface.
- Next.js: React framework for server-side rendering and routing
- React: JavaScript library for building user interfaces
- TypeScript: Adds static typing to JavaScript for improved code quality
- Tailwind CSS: Utility-first CSS framework for rapid UI development
- Shadcn UI: Custom UI component library built on top of Tailwind
-
Course Management Interface
- Implemented in
ManageCourse.tsx
- Provides CRUD operations for courses
- Uses React hooks for state management
- Integrates with backend API for data persistence
- Implemented in
-
Rule Editor
- Core component:
SortedTree.tsx
- Implements drag-and-drop functionality for rule ordering
- Supports nested rule structures
- Real-time updates and validation
- Core component:
-
Document Generation
CoursePDFGenerator.tsx
handles PDF generation requests- Integrates with backend API to trigger document creation
- Provides download links for generated documents
-
Authentication and Authorization
- Implemented using JWT (JSON Web Tokens)
withAuth.tsx
higher-order component for route protection- Role-based access control (Admin vs Normal User)
-
State Management
- Utilizes React Context API for global state management
- Custom hooks like
useUser
,useRules
for specific functionality
-
Responsive Design
- Tailwind CSS classes for responsive layouts
- Mobile-friendly interface components
-
Form Handling and Validation
- Custom form components with built-in validation
- Integration with backend for server-side validation
- Code splitting and lazy loading for improved initial load times
- Memoization of expensive computations
- Efficient re-rendering strategies using React's useCallback and useMemo
The backend of the system is built to handle complex business logic, data persistence, and provide a robust API for the frontend.
- NestJS: Progressive Node.js framework for building efficient and scalable server-side applications
- TypeORM: ORM for TypeScript and JavaScript
- MySQL: Relational database for data storage
- JWT: For secure authentication and authorization
-
API Architecture
- RESTful API design principles
- Modular structure following NestJS best practices
- Swagger documentation for API endpoints
-
Database Schema and ORM
- Entities defined in TypeORM (e.g.,
Course
,Rule
,Requirement
) - Complex relationships between entities (e.g., one-to-many, many-to-many)
- Migration support for database schema changes
- Entities defined in TypeORM (e.g.,
-
Authentication and Authorization
- JWT-based authentication system
- Role-based access control implementation
- Middleware for route protection
-
Business Logic Implementation
- Services for handling complex operations (e.g.,
CoursesService
,RulesService
) - Implementation of rule management logic
- Version control for courses and rules
- Services for handling complex operations (e.g.,
-
Document Generation
- Integration with Puppeteer for PDF generation
- HTML template rendering for document structure
- Asynchronous processing for large documents
-
Data Validation and Error Handling
- DTO (Data Transfer Object) validation using class-validator
- Global exception filters for consistent error responses
-
Caching and Performance
- Implementation of caching strategies for frequently accessed data
- Query optimization for database operations
- Input sanitization to prevent SQL injection
- CORS configuration
- Rate limiting to prevent abuse
- Secure password hashing using bcrypt
- Stateless architecture for horizontal scaling
- Database indexing for query performance
- Potential for implementing message queues for heavy processing tasks
- API endpoints in the backend correspond to service calls in the frontend
- Consistent data models between frontend and backend
- Error handling and status codes are uniformly interpreted
- Docker containerization for both frontend and backend
- Jenkins pipeline for automated testing and deployment
- Staging and production environments with different configurations
The UWA Curriculum Rules Management System utilizes a MySQL database with a structure designed to efficiently store and manage course-related data. The database schema is defined using TypeORM entities, which map directly to database tables.
-
Course
- Fields: id, code, name, type, version, created_at, updated_at
- Relationships:
- One-to-Many with Rule
-
Rule
- Fields: id, name, type, description, created_at, updated_at
- Relationships:
- Many-to-One with Course
- One-to-Many with Requirement
-
Requirement
- Fields: id, content, style, is_connector, order_index, parentId
- Relationships:
- Many-to-One with Rule
- Self-referencing One-to-Many (for nested requirements)
-
User
- Fields: id, username, email, password, role, created_at, updated_at
-
PresetCourse
- Fields: id, code, name, type, version, created_at, updated_at
- Relationships:
- One-to-Many with PresetRule
-
PresetRule
- Fields: id, name, type, description, created_at, updated_at
- Relationships:
- Many-to-One with PresetCourse
- One-to-Many with PresetRequirement
-
PresetRequirement
- Fields: id, content, style, is_connector, order_index, parentId
- Relationships:
- Many-to-One with PresetRule
- Self-referencing One-to-Many (for nested requirements)
- Use of foreign keys to maintain referential integrity
- Indexes on frequently queried fields for improved performance
- Timestamp fields (created_at, updated_at) for auditing purposes
- Enum types for fields like rule types and numbering styles
The system provides a RESTful API with the following key endpoints:
- POST
/api/auth/register
: User registration - POST
/api/auth/login
: User login - GET
/api/auth/me
: Get current user profile - PUT
/api/auth/me
: Update user profile - PUT
/api/auth/password
: Change password - POST
/api/auth/forgot-password
: Initiate password reset - POST
/api/auth/reset-password
: Complete password reset
- GET
/api/courses
: Get all courses - GET
/api/courses/:id
: Get a specific course - POST
/api/courses
: Create a new course - PUT
/api/courses/:id
: Update a course - DELETE
/api/courses/:id
: Delete a course - GET
/api/courses/code/:code/version/:version
: Get course by code and version
- GET
/api/courses/:courseId/rules
: Get all rules for a course - GET
/api/courses/:courseId/rules/:id
: Get a specific rule - POST
/api/courses/:courseId/rules
: Create a new rule - PUT
/api/courses/:courseId/rules/:id
: Update a rule - DELETE
/api/courses/:courseId/rules/:id
: Delete a rule - GET
/api/courses/:courseId/rules/by-type/:type
: Get rules by type
- GET
/api/courses/:courseId/rules/:ruleId/requirements
: Get all requirements for a rule - POST
/api/courses/:courseId/rules/:ruleId/requirements
: Create new requirements - PUT
/api/courses/:courseId/rules/:ruleId/requirements
: Update requirements - DELETE
/api/courses/:courseId/rules/:ruleId/requirements/:requirementId
: Delete a requirement
- GET
/api/preset-courses
: Get all preset courses - GET
/api/preset-courses/:id
: Get a specific preset course - POST
/api/preset-courses
: Create a new preset course - PUT
/api/preset-courses/:id
: Update a preset course - DELETE
/api/preset-courses/:id
: Delete a preset course - Similar endpoints exist for preset rules and requirements, following the pattern of regular courses
- GET
/api/documents/course/:id/pdf
: Generate PDF for a course - GET
/api/documents/course/:id/html
: Generate HTML for a course
- Consistent use of HTTP methods (GET, POST, PUT, DELETE) for CRUD operations
- Query parameters for filtering, sorting, and pagination where applicable
- Use of status codes to indicate success, client errors, and server errors
- JWT token required in Authorization header for authenticated endpoints
- Role-based access control implemented on certain endpoints
- Node.js (v14 or later)
- MySQL (v8.0 or later)
- Git
-
Install MySQL if not already installed.
-
Log in to MySQL as root:
mysql -u root -p
-
Create the database:
CREATE DATABASE course_rules_db;
-
Create a user and grant privileges:
CREATE USER 'your_username'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON course_rules_db.* TO 'your_username'@'localhost'; FLUSH PRIVILEGES;
- First, ensure Node.js is installed. Then install Yarn globally:
npm install -g yarn
- Verify the installation:
yarn --version
-
Clone the repository:
git clone https://github.com/your-repo/uwa-curriculum-management-system.git cd uwa-curriculum-management-system/backend
-
Install dependencies:
yarn install
-
Create a
.env
file in the backend root directory with the following content:DB_HOST=your_host DB_PORT=3306 DB_USERNAME=your_username DB_PASSWORD=your_password DB_DATABASE=course_rules_db PDF_URL_PREFIX=/public/pdf HTML_URL_PREFIX=/public/html JWT_SECRET=your_secret_key PORT=6015
-
Run database migrations:
yarn typeorm migration:run
-
Start the backend server:
yarn start
-
Navigate to the frontend directory:
cd ../frontend
-
Install dependencies:
yarn install
-
Create a
.env
file in the frontend root directory with the following content:PORT=6014 NEXT_PUBLIC_API_BASE_URL=http://localhost:6015/api NEXT_PUBLIC_PDF_URL_PREFIX=http://localhost:6015
-
Build the frontend:
yarn build
-
Start the frontend server:
yarn start
- Frontend: Open a web browser and navigate to
http://localhost:6014
- Backend API: The API will be available at
http://localhost:6015/api
DB_HOST
,DB_PORT
,DB_USERNAME
,DB_PASSWORD
,DB_DATABASE
: MySQL connection detailsPDF_URL_PREFIX
,HTML_URL_PREFIX
: URL prefixes for generated documentsJWT_SECRET
: Secret key for JWT token generationPORT
: The port on which the backend server will run
PORT
: The port on which the frontend server will runNEXT_PUBLIC_API_BASE_URL
: The URL of the backend APINEXT_PUBLIC_PDF_URL_PREFIX
: The URL prefix for accessing generated PDF documents
For production deployment:
- Use a process manager like PM2 to keep the application running.
- Set up a reverse proxy (e.g., Nginx) to handle HTTPS and serve static files.
- Use environment-specific .env files and ensure sensitive data is properly secured.
- Set up monitoring and logging solutions.
- Configure regular database backups.
- If you encounter any "module not found" errors, try running
yarn install
again. - Ensure all required ports are open and not in use by other applications.
- Check the console and server logs for any error messages.
By following these steps, you should have a working deployment of the UWA Curriculum Rules Management System. Remember to replace placeholder values (like database credentials) with your actual production values when deploying to a live environment.
- Feel free to reference it as needed https://docs.google.com/document/d/1QfREd0iH-s2IguowtiEAbd4mgEv8GEtP9CjHcbnXfGI/edit?usp=sharing