Skip to content

RogerC-dev/MasterLaw

Repository files navigation

MasterLaw

A comprehensive iOS application designed for law exam preparation, specifically tailored for judicial officer and lawyer examinations in Taiwan.

Overview

MasterLaw is a native iOS app built with SwiftUI and SwiftData, providing an intelligent study platform with practice questions, spaced repetition flashcards, learning analytics, and AI-powered assistance.

Key Features

Practice Mode

  • Complete collection of past examination questions
  • Multiple-choice question practice
  • Instant feedback and explanations
  • Category-based question filtering
  • Bookmark difficult questions for review

Flashcard System

  • SM-2 algorithm for spaced repetition learning
  • Create and manage custom flashcards
  • Subject categorization (e.g., Constitutional Law, Criminal Law, Civil Law)
  • Review scheduling based on performance
  • Flip cards to reveal answers

Learning Analytics

  • Activity heatmap tracking daily study sessions
  • Performance charts and statistics
  • Progress visualization
  • Identify weak areas for focused study
  • Track study streaks and active days

iOS Widget Support

  • Home screen widgets displaying flashcards for quick review
  • Multiple widget sizes (small, medium, large)
  • Shuffle functionality to see different cards
  • Deep linking to open specific flashcards in the app
  • Activity summary widget showing weekly progress

AI Chat Assistant

  • AI-powered question and answer support
  • Get explanations for difficult concepts
  • Interactive problem-solving assistance
  • Context-aware legal topic discussions

Offline Support

  • Cached questions and flashcards for offline access
  • Sync data when connection is restored
  • Offline banner indicating cached content
  • Pending review tracking for later synchronization

User Management

  • Secure authentication system
  • User profiles with study statistics
  • Subscription tiers (Free and Premium)
  • Badge and achievement system

Technical Stack

Platform

  • iOS (SwiftUI)
  • Minimum iOS version: iOS 17+

Architecture

  • SwiftUI for declarative UI
  • SwiftData for local data persistence
  • MVVM (Model-View-ViewModel) architecture
  • App Groups for widget data sharing

Key Technologies

  • SwiftData: Core data persistence layer for all models
  • Charts: Native chart framework for analytics visualization
  • WidgetKit: Home screen widget implementation
  • App Intents: Widget interactivity and deep linking
  • ActivityKit: Support for Live Activities
  • Observation Framework: State management with @Observable

Data Models

  • Question & QuestionOption
  • Flashcard with SM-2 spaced repetition
  • User & UserBadge
  • ActivityDay for heatmap tracking
  • Attempt for practice session history
  • ChatMessage for AI conversations
  • Cached models for offline support

Project Structure

MasterLaw/
├── Models/                  # SwiftData models
├── Views/                   # SwiftUI views
│   ├── Auth/               # Login and authentication
│   ├── Practice/           # Question practice interface
│   ├── Flashcard/          # Flashcard study interface
│   ├── Analytics/          # Charts and statistics
│   ├── Profile/            # User profile and settings
│   └── Components/         # Reusable UI components
├── ViewModels/             # Business logic and state management
├── Services/               # API calls and data services
├── Utilities/              # Helper functions and extensions
├── Config.swift            # App configuration and constants
└── MasterLawApp.swift      # App entry point

MasterLawWidget/            # Widget extension target
├── MasterLawWidget.swift   # Widget definitions
├── AppIntent.swift         # Widget interactions
└── WidgetDataManager.swift # Data sharing with main app

Setup and Installation

Prerequisites

  • Xcode 15.0 or later
  • iOS 17.0 SDK or later
  • Apple Developer account (for device testing and App Groups)

Configuration

  1. Clone the repository

  2. Open MasterLaw.xcodeproj in Xcode

  3. Configure App Groups:

    • Select the MasterLaw target
    • Go to Signing & Capabilities
    • Add App Groups capability
    • Enable group.com.masterlaw.shared
    • Repeat for MasterLawWidget target
  4. Update API endpoint in Config.swift:

    static let baseURL = "YOUR_API_BASE_URL"
  5. Build and run on simulator or device

Features in Detail

Spaced Repetition Algorithm

The app uses the SM-2 algorithm to schedule flashcard reviews:

  • Cards are shown at increasing intervals based on recall difficulty
  • Quality ratings from 0-5 determine next review date
  • Optimizes long-term retention with minimal review time

Deep Linking

The app supports custom URL schemes for widget and notification actions:

  • masterlaw://practice - Open practice mode
  • masterlaw://flashcard - Open flashcard list
  • masterlaw://flashcard/[id] - Open specific flashcard
  • masterlaw://analytics - Open analytics view
  • masterlaw://random - Start random question

Activity Tracking

  • Automatic session tracking when app becomes active/inactive
  • Heatmap visualization similar to GitHub contributions
  • Tracks study time and question attempts
  • Weekly and monthly activity summaries

Data Persistence

All data is stored locally using SwiftData with automatic iCloud sync support through CloudKit. The app maintains cached copies of essential data for offline access.

App Groups

Widget and main app share data through App Groups (group.com.masterlaw.shared), allowing the widget to display up-to-date information without launching the main app.

Authentication

The app uses token-based authentication:

  • Login with username and password
  • JWT token stored securely in Keychain
  • Automatic token refresh
  • Logout clears all cached credentials

Future Enhancements

Potential areas for expansion:

  • iPad multi-window support
  • Apple Pencil annotation support
  • Study group collaboration features
  • Advanced AI tutoring with GPT-4
  • Audio explanations for questions
  • Dark mode customization

License

This project is proprietary software for law examination preparation.

Support

For issues or questions, please open an issue in this repository.

About

A comprehensive iOS application designed for law exam preparation, specifically tailored for judicial examinations in Taiwan.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages