How xi2p/zju-motis works
Based on our analysis of the file structure and README, MOTIS is a scheduling optimization tool tailored to help Zhejiang University students generate the “best” timetable based on multiple criteria. In terms of design, it is primarily a Python-based application that combines a user interface (with options for both a UI executable and code-based configuration), domain-specific business logic (course entities, scheduling rules, teacher and time preferences), and some supporting modules (such as libraries for highlighting and network requests).
Main components
• User Interface Layer – Represented by the UI.py file (and possibly related helpers like network.py) and the entry point for the executable (MOTIS.exe or UI.py). This layer handles user login, code entry for course requirements, and displays timetable results.
• Domain/Business Logic Layer – This includes all “Entities” (e.g. Course, Teacher, Time, WishList, etc.). These classes implement the core scheduling algorithm and rule-based decision making. They capture user preferences (priority, teacher choice, preferred time slots, etc.) and execution of the selection algorithm.
• Data and Configuration Components – Files such as teacher.json, data.py, and requirements.txt together with the “lib” folder (with modules like colorizer and highlightKw) indicate supportive functionality, such as external data input, configuration management, and user feedback (e.g., syntax highlighting).
• Integration/Interface Layer – The interface.py file (mentioned in the readme and Entities/WishList.py) appears to act as the bridge between raw user input and the manipulation of business objects. It facilitates transforming the user-specified scheduling requirements into internal representations.
Relationships and interactions
• The UI layer interacts with the Domain/Business Logic by capturing user input (manually written Python code for course requests) and then calling functions (e.g., wishList.append and other chainable methods) to populate the internal state.
• The Business Logic layer holds the domain objects (from Entities) that encapsulate course information and scheduling rules. This layer processes user preferences (including scheduling strategies, teacher and time preferences) and implements algorithms to generate an optimal timetable.
• The Data layer supplies required static information (like teacher details from teacher.json) and might also connect to online services via network.py for fetching real-time course information.
• The support modules in “lib” (such as colorizer and highlightKw) assist in enhancing the UI experience, most likely by formatting or highlighting code syntax input.
Architectural patterns and design principles
• The code structure suggests a modular design with separation of concerns – the business logic (Entities) is independent of the UI, enabling flexibility if one wishes to change the front-end later.
• There is also evidence of domain-driven design, where core concepts (Course, Teacher, ClassTime) are reflected cleanly in their dedicated modules.
Relevant technologies and frameworks
• The project is Python-based (as shown by usage of Python 3 and dependencies listed in requirements.txt).
• The use of JSON for teacher information (teacher.json) and libraries for HTTP/network requests indicate that standard Python libraries or popular dependencies such as requests are in play.
• Although it’s a desktop/command-line application rather than a web-based full-stack app, clear layering (UI vs. Domain vs. Data) is maintained.
Elements
• “User Interface (UI.py, network.py)” for handling login/input and results display.
• “Domain/Business Logic (Entities/)” covering Course, WishList, ClassTable, Teacher, etc.
• “Data & Configuration (data.py, teacher.json)” for data sources.
• “Support Libraries (lib/)” for auxiliary functions (syntax highlighting, etc.).
• Data/configuration module to Domain to represent dependency injection or data retrieval.
• Annotations that highlight key design patterns:
• Mention “Fluent Interface” near the chainable Course API.
• “Separation of Concerns” between UI, Business Logic, and Data layers.