The app follows a layered architecture comprising the following key components:
- User Interface:
- The UI is built with Flutter widgets and follows Material Design principles.
- Major pages include:
HomePage: Dashboard showing tasks, events, and user-specific details.TasksPage: Manages task overviews and interactions.ChatsPage: Handles chat-based communication within chapters.SettingsPage: Placeholder for customizable settings like dark mode.ProfilePage: Displays user account options and logout functionality.
- Widget Structure:
- Stateless Widgets:
LoginPage: Static UI for login.CreateAccountWidget: Static UI for account creation.
- Stateful Widgets:
ShowTasks: Dynamically updates tasks using Firestore streams.TaskLandingPageWidget: Handles task-specific actions and displays task details.
- Stateless Widgets:
- Navigation:
- Navigation is implemented via
PageViewand a Bottom Navigation Bar. - Key methods:
onPageChanged: Updates the UI when the user switches between tabs.navigateToPage(index): Programmatically navigates to specific pages.
- Navigation is implemented via
- Theming:
- Managed centrally with
FlutterFlowTheme, supporting:- Light mode.
- Dark mode.
- Key methods:
loadTheme(): Loads the current theme from shared preferences.saveTheme(): Saves user-selected themes.
- Managed centrally with
- Data Storage:
- Firebase Firestore:
- Collections:
users: User profiles and preferences.chapters: Details of chapters, including members and announcements.tasks: Task-related data like submissions and due dates.events: Event schedules and attendees.
- Documents follow well-defined schemas for consistency.
- Key queries:
getDocumentById(collection, id): Retrieves a document from Firestore.queryCollection(collection, filters): Queries Firestore with specific conditions.
- Collections:
- Firebase Storage:
- Handles file uploads and downloads for attachments in tasks and announcements.
- Key methods:
uploadFile(path, file): Uploads a file to a specified path.downloadFile(path): Downloads a file from Firebase Storage.
- Firebase Firestore:
- Authentication:
- Firebase Authentication supports:
- Email and password.
- OAuth (Google, Apple).
- Key methods:
signInWithEmailAndPassword(email, password): Logs in a user.createUserWithEmailAndPassword(email, password): Creates a new user account.signOut(): Logs out the user.
- Firebase Authentication supports:
- Cloud Functions:
- Used for:
- Sending push notifications.
- Validating join codes during chapter onboarding.
- Key triggers:
onAnnouncementCreate: Sends notifications when a new announcement is created.
- Used for:
- Managed through
AppInfo, a singleton class.- Holds global state variables like:
currentUser: Stores the currently logged-in user.currentChapter: Tracks the chapter selected by the user.isExec: Boolean flag indicating if the user has executive privileges.
- Key methods:
loadUserData(uid): Loads user data from Firestore.updateChapter(chapterId): Updates the current chapter and fetches related data.
- Holds global state variables like:
- Advantages:
- Simplifies data flow and sharing across widgets.
- Minimizes redundancy in accessing backend services.
Below is an updated detailed diagram of the app’s structure:
Root Widget (MyApp)
├── Navigation (Bottom Navigation Bar)
| ├── Home Page
| | └── Widgets:
| | ├── ShowTasks
| | └── ShowEvents
| ├── Tasks Page
| | └── Widgets:
| | ├── ShowAllTasksWidget
| | └── TaskLandingPageWidget
| ├── Chats Page
| | └── Widgets:
| | ├── ChatroomPage
| | └── JoinChats
| ├── Settings Page
| └── Profile Page
├── Auth Widgets
| ├── Login Page
| ├── Create Account Page
| └── Forgot Password Page
├── Feature Widgets
| ├── Task Management:
| | └── TaskLandingPageWidget
| ├── Event Management:
| | └── EventLandingPage
| ├── Chapter Management:
| | └── ChapterSelectWidget
└── Backend Models
├── UserModel
├── TaskModel
├── EventModel
├── AnnouncementModel
└── ChapterModel
The app interacts with Firebase services at multiple integration points:
- Google Sign-In:
- Method:
signInWithGoogleinAuthService. - Description: Initiates OAuth flow, retrieves user credentials, and creates or updates Firestore user documents.
- Method:
- Apple Sign-In:
- Method:
signInWithAppleinAuthService. - Description: Similar to Google Sign-In but uses Apple’s OAuth services.
- Method:
- Email/Password:
- Method:
signInWithEmailAndPasswordinAuthService. - Description: Authenticates users with email and password credentials.
- Method:
- Firestore:
- Users:
- Path:
/users/{userId}. - Description: Fetch user profile, current chapter, and task progress.
- Methods:
getUserById(userId): Fetches user data.writeUser(data): Creates or updates user data.
- Path:
- Chapters:
- Path:
/chapters/{chapterId}. - Description: Manage chapter data, including members, announcements, and events.
- Methods:
getChapterById(chapterId): Fetches chapter details.joinChapter(chapterId): Adds the current user to a chapter.
- Path:
- Tasks:
- Path:
/chapters/{chapterId}/tasks/{taskId}. - Description: CRUD operations for task details, user submissions, and statuses.
- Methods:
createTask(data): Creates a new task.getTaskById(taskId): Fetches details of a specific task.completeTask(taskId): Marks a task as completed.
- Path:
- Events:
- Path:
/chapters/{chapterId}/events/{eventId}. - Description: Store and retrieve event schedules and attendee data.
- Methods:
createEvent(data): Creates a new event.getEventById(eventId): Retrieves event details.
- Path:
- Users:
- Firebase Cloud Messaging:
- Used by
AnnouncementModelto broadcast announcements to subscribed users. - Notifications are triggered via Firebase Cloud Functions when new announcements are created.
- Key Methods:
sendNotification(title, body, tokens): Dispatches notifications to specified users.
- Used by
- StreamBuilder Widgets:
- Used in
ShowTasksandShowAllTasksWidgetto render real-time updates from Firestore. - Methods:
snapshots(): Listens to Firestore changes.onDataChange(): Updates the UI dynamically based on new data.
- Used in
- Toasts (
toast.dart) are used to provide immediate feedback for backend errors or successful operations. - Key Method:
Toasts.toast(message, isError): Displays a toast notification with appropriate styling.
This enhanced detail ensures that developers understand the app’s architecture, backend integration, and data flow comprehensively.