How itsnotrin/betterclasscharts works
Project Type and Its Purpose
• The project is a native iOS application built using SwiftUI. Its purpose is to provide an alternative client for ClassCharts, letting users view homework, timetables, and change themes.
• The README highlights several UI screens (login, homework list, timetable views, settings), as well as numerous theme options (Catppuccin, Dracula, etc.). It also mentions technical details such as networking via URLSession, secure credential storage, error handling, and automatic token refresh.
File Structure for Architectural Insights
• At the top level, you have an Xcode project (BetterClasscharts.xcodeproj) and a main application directory (BetterClasscharts) that contains the source code.
• App Electron: BetterClasschartsApp.swift – the entry point.
• Various SwiftUI view files (ContentView.swift, DayTimetableView.swift, HomeworkDetailView.swift, HomeworkListItemView.swift, MainTabView.swift, SettingsView.swift) that define the UI components.
• Models.swift and LoginState.swift which hold the application’s state and data models.
• StudentClient.swift, which likely handles the networking logic, interacting with ClassCharts via URLSession.
• Theme.swift and StringExtension.swift add application-wide support (for theming and possible utility functions).
• Test directories (BetterClasschartsTests and BetterClasschartsUITests) indicate unit/integration testing of functionality, which suggests an emphasis on testing.
• The repository also includes assets, previews, and workflow configuration in the .github/workflows directory.
Component Interaction and System Layers
• Application/Entry Layer: BetterClasschartsApp.swift initializes the app, configures environment objects (e.g., LoginState), and sets up the initial view hierarchy.
• Presentation/UI Layer: SwiftUI view components (such as ContentView, HomeworkListItemView, etc.) render data and provide user interactions. The MainTabView handles the tab-based navigation (dividing homework view, timetable, settings).
• Networking Layer: StudentClient.swift acts as the API client using URLSession, interacting with ClassCharts API endpoints. It incorporates token refresh and error handling.
• Data & State Management: LoginState.swift stores the current user session state and credentials using secure storage techniques (UserDefaults as mentioned). Models.swift represents data models passed between the UI and network layers.
• Theming: Theme.swift together with various assets (in Assets.xcassets) manage the look and feel of the application with multiple theme options.
• Testing Layers: Unit tests and UI tests ensure the quality of the individual components and user workflows.