Skip to content

shfa-e/Togu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“˜ Togu

Share. Learn. Build Together.

Togu is a student-friendly learning platform where users can ask questions, share answers, and earn badges for being active and helpful. Think of it as a focused, community-driven Q&A platform designed for students to connect and learn together.

Swift iOS SwiftUI License


✨ Features

Core Functionality

  • πŸ” OneLogin Authentication - Secure sign-in with OneLogin OIDC
  • πŸ“ Ask Questions - Post questions with text, tags, code snippets, and images
  • πŸ’¬ Answer Questions - Help others by providing detailed answers
  • ⬆️ Voting System - Upvote helpful questions and answers
  • πŸ† Badges & Points - Earn achievements and XP for your contributions
  • πŸ‘€ User Profiles - View your stats, badges, questions, and answers
  • πŸ“Š Leaderboard - See top contributors ranked by points
  • πŸ” Search & Filter - Find questions by text or tags
  • πŸ“± Modern UI - Beautiful, intuitive SwiftUI interface

Advanced Features

  • ✨ Pull-to-Refresh - Refresh content with a simple swipe
  • πŸ“„ Pagination - Efficient loading of large question lists
  • 🎨 Code Snippet Support - Syntax-highlighted code blocks
  • 🏷️ Tag System - Organize content with predefined tags
  • πŸ“ˆ Activity Feed - Track your recent contributions
  • 🎯 Empty States - Helpful messages when no content is available
  • ⚑ Error Handling - Graceful error messages and retry logic
  • πŸ”„ Real-time Updates - Instant UI updates after actions

πŸ—οΈ Architecture

Togu follows the MVVM (Model-View-ViewModel) architecture pattern for clean separation of concerns:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Views    β”‚  SwiftUI Views (UI Layer)
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  ViewModels β”‚  Business Logic & State Management
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   Services  β”‚  API & Data Layer (Airtable)
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    Models   β”‚  Data Structures
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Components

  • Views: SwiftUI views for UI presentation
  • ViewModels: ObservableObject classes managing view state and business logic
  • Services: Domain-specific services for API interactions
    • QuestionsService - Question operations
    • AnswersService - Answer operations
    • UsersService - User management
    • VotesService - Voting system
    • BadgesService - Badge management
    • LeaderboardService - Leaderboard data
  • Models: Data structures representing entities (Question, Answer, User, etc.)

πŸ› οΈ Tech Stack

  • Language: Swift 5.9+
  • Framework: SwiftUI
  • iOS Version: 17.0+
  • Authentication: OneLogin OIDC
  • Backend: Airtable API
  • Architecture: MVVM
  • Async/Await: Modern Swift concurrency

πŸ“‹ Prerequisites

Before you begin, ensure you have:

  • Xcode 15.0+ installed
  • iOS 17.0+ deployment target
  • Airtable Account with:
    • API Key
    • Base ID
    • Tables: Users, Questions, Answers, Votes, Badges
  • OneLogin Configuration:
    • Client ID
    • Redirect URI: com.shfa.Togu.oidc://
    • OIDC configuration file (OL-Oidc.plist)

πŸš€ Getting Started

1. Clone the Repository

git clone https://github.com/yourusername/togu.git
cd togu

2. Configure Airtable

  1. Create an Airtable base with the following tables:

    • Users (Name, Email, ProfilePicture, Points, Badges)
    • Questions (Title, Body, Tags, Author, Upvotes, Image)
    • Answers (AnswerText, Author, Question, Upvotes, CreatedDate)
    • Votes (User, TargetType, TargetQuestion, TargetAnswer)
    • Badges (Badge Name, Description, Icon, EarnedBy, DateEarned)
  2. Get your Airtable API Key and Base ID from Airtable Account

3. Configure OneLogin

  1. Set up your OneLogin OIDC application
  2. Add the redirect URI: com.shfa.Togu.oidc://
  3. Place your OL-Oidc.plist configuration file in Togu/Resources/

4. Set Environment Variables

Add the following to your Xcode project's build settings or Info.plist:

<key>AIRTABLE_KEY</key>
<string>your_airtable_api_key</string>
<key>AIRTABLE_BASE_ID</key>
<string>your_airtable_base_id</string>

Alternatively, set them as environment variables in your Xcode scheme.

5. Build and Run

  1. Open Togu.xcodeproj in Xcode
  2. Select your target device or simulator
  3. Press Cmd + R to build and run

πŸŽ₯ Demo Video

Watch the demo of Togu in action here:
Watch the video

πŸ’‘ Click the image above to watch the demo on YouTube.


πŸ”‘ Test Account for Login

For quick testing and access, you can use the following test user account to sign in and create a password:

Email: reignite@hackathon.com
Password: Hackathon1@

This account is intended for demo and hackathon testing purposes.
Once logged in, you can, post questions & answers, reciver badges, and explore all platform features.


πŸ“ Project Structure

Togu/
β”œβ”€β”€ App/
β”‚   β”œβ”€β”€ ToguApp.swift          # App entry point
β”‚   β”œβ”€β”€ RootRouter.swift       # Navigation router
β”‚   └── AppDelegate.swift      # App lifecycle
β”‚
β”œβ”€β”€ Model/
β”‚   β”œβ”€β”€ Question.swift         # Question data model
β”‚   β”œβ”€β”€ Answer.swift           # Answer data model
β”‚   β”œβ”€β”€ AuthState.swift        # Authentication state
β”‚   β”œβ”€β”€ LeaderboardEntry.swift # Leaderboard entry
β”‚   β”œβ”€β”€ Activity.swift         # User activity
β”‚   β”œβ”€β”€ Skill.swift            # User skills
β”‚   β”œβ”€β”€ LevelInfo.swift        # Level calculation
β”‚   └── AirtableModels.swift   # Airtable field mappings
β”‚
β”œβ”€β”€ ViewModel/
β”‚   β”œβ”€β”€ AuthViewModel.swift           # Authentication logic
β”‚   β”œβ”€β”€ FeedViewModel.swift           # Question feed logic
β”‚   β”œβ”€β”€ HomeViewModel.swift           # Home screen logic
β”‚   β”œβ”€β”€ QuestionDetailViewModel.swift # Question detail logic
β”‚   β”œβ”€β”€ AnswerFormViewModel.swift     # Answer form logic
β”‚   β”œβ”€β”€ AskQuestionViewModel.swift    # Ask question logic
β”‚   β”œβ”€β”€ ProfileViewModel.swift        # Profile logic
β”‚   β”œβ”€β”€ LeaderboardViewModel.swift    # Leaderboard logic
β”‚   └── LoginViewModel.swift          # Login screen logic
β”‚
β”œβ”€β”€ Views/
β”‚   β”œβ”€β”€ MainTabView.swift          # Tab navigation
β”‚   β”œβ”€β”€ HomeView.swift             # Question feed
β”‚   β”œβ”€β”€ QuestionDetailView.swift   # Question details
β”‚   β”œβ”€β”€ AskQuestionView.swift      # Post question
β”‚   β”œβ”€β”€ AnswerFormView.swift       # Post answer
β”‚   β”œβ”€β”€ ProfileView.swift          # User profile
β”‚   β”œβ”€β”€ LeaderboardView.swift      # Leaderboard
β”‚   β”œβ”€β”€ LoginView.swift            # Login screen
β”‚   β”œβ”€β”€ SplashView.swift           # Splash screen
β”‚   └── Components/                # Reusable UI components
β”‚       β”œβ”€β”€ Profile/
β”‚       β”œβ”€β”€ Leaderboard/
β”‚       β”œβ”€β”€ QuestionDetail/
β”‚       β”œβ”€β”€ EmptyStateView.swift
β”‚       β”œβ”€β”€ LoadingView.swift
β”‚       β”œβ”€β”€ ErrorView.swift
β”‚       └── ErrorToast.swift
β”‚
β”œβ”€β”€ Services/
β”‚   β”œβ”€β”€ AirtableService.swift      # Main Airtable facade
β”‚   β”œβ”€β”€ QuestionsService.swift     # Question operations
β”‚   β”œβ”€β”€ AnswersService.swift       # Answer operations
β”‚   β”œβ”€β”€ UsersService.swift         # User operations
β”‚   β”œβ”€β”€ VotesService.swift         # Voting operations
β”‚   β”œβ”€β”€ BadgesService.swift        # Badge operations
β”‚   β”œβ”€β”€ LeaderboardService.swift  # Leaderboard operations
β”‚   β”œβ”€β”€ AirtableConfig.swift       # Airtable configuration
β”‚   └── AirtableListResponse.swift # API response models
β”‚
β”œβ”€β”€ Utilities/
β”‚   β”œβ”€β”€ FormattingHelpers.swift    # Date/number formatting
β”‚   └── MarkdownHelpers.swift      # Markdown processing
β”‚
└── Resources/
    β”œβ”€β”€ Assets.xcassets           # App assets
    β”œβ”€β”€ Theme.swift                # App theme & colors
    β”œβ”€β”€ Info.plist                 # App configuration
    └── OL-Oidc.plist              # OneLogin config

🎨 Design System

Togu uses a custom design system defined in Theme.swift:

  • Primary Color: toguPrimary - Main brand color
  • Background: toguBackground - App background
  • Text Colors: toguTextPrimary, toguTextSecondary
  • Card Colors: toguCard, toguBorder
  • Error Colors: toguError, toguDisabled

All colors are accessible via SwiftUI's Color extension.


πŸ” Authentication Flow

  1. User taps "Sign in with IDServe" on LoginView
  2. AuthViewModel initiates OneLogin OIDC flow
  3. User authenticates via OneLogin
  4. App receives OIDC callback with tokens
  5. User is redirected to MainTabView (Home)
  6. User data is synced with Airtable Users table

πŸ“Š Data Flow

Question Feed

HomeView β†’ FeedViewModel β†’ QuestionsService β†’ Airtable API

Posting a Question

AskQuestionView β†’ AskQuestionViewModel β†’ QuestionsService β†’ Airtable API
                β†’ BadgesService (check milestones)
                β†’ UsersService (award points)

Voting

QuestionDetailView β†’ QuestionDetailViewModel β†’ VotesService β†’ Airtable API
                  β†’ UsersService (award points to author)

πŸ§ͺ Testing

To test the app:

  1. Login: Use your OneLogin credentials
  2. Ask Questions: Post questions with tags and optional images
  3. Answer Questions: Provide helpful answers
  4. Vote: Upvote quality content
  5. Check Profile: View your badges, points, and activity
  6. Leaderboard: See top contributors

πŸ› Known Issues

  • Mesh gradient background requires iOS 18.0+ (fallback provided for earlier versions)
  • Image uploads are limited by Airtable's attachment size limits
  • Badge awarding may have a slight delay due to Airtable indexing

🚧 Roadmap

  • Push notifications for new answers
  • Markdown editor for questions/answers
  • Image compression before upload
  • Offline mode with local caching
  • Dark mode support
  • Question categories
  • Answer acceptance feature
  • User mentions and notifications

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Style

  • Follow Swift naming conventions
  • Use SwiftUI best practices
  • Maintain MVVM architecture
  • Add comments for complex logic
  • Keep functions focused and small

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Airtable for the backend infrastructure
  • OneLogin for authentication
  • SwiftUI community for inspiration and best practices

πŸ“ž Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Create a new issue with detailed information
  3. Contact the maintainers

Made with ❀️ for learner, by learners


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors