115+
Source Files
10,000+
Lines of Code
17
Services
5
Zustand Stores

Directory Structure

Complete project organization

MR_BunkManager/
├── app/                              # Expo Router navigation
│   ├── (auth)/                       # Authentication screens
│   │   ├── login.tsx                 # Email/password + Google login
│   │   ├── signup.tsx                # User registration
│   │   ├── email-verification.tsx    # Email verification flow
│   │   ├── forgot-password.tsx       # Password reset
│   │   └── _layout.tsx               # Auth group layout
│   ├── (onboarding)/                 # Onboarding flow
│   │   └── index.tsx                 # Profile setup wizard
│   ├── (tabs)/                       # Main app tabs
│   │   ├── index.tsx                 # Dashboard/home
│   │   ├── timetable.tsx             # Class schedule
│   │   ├── attendance.tsx            # Attendance tracking
│   │   ├── groups.tsx                # Study groups
│   │   ├── profile.tsx               # User profile
│   │   └── _layout.tsx               # Tab navigator
│   ├── note/[id].tsx                 # Dynamic: Note detail
│   ├── user/[id].tsx                 # Dynamic: User profile
│   ├── create-note.tsx               # Note creation
│   └── _layout.tsx                   # Root layout
│
├── src/                              # Source code
│   ├── hooks/                        # Custom React hooks (2 files)
│   │   ├── useResponsive.ts          # Responsive design utilities
│   │   └── index.ts                  # Hook exports
│   ├── components/                   # React components (15+ files)
│   ├── screens/                      # Screen implementations (13 files)
│   ├── services/                     # Business logic (17 files)
│   │   ├── ocrService.ts             # OCR.space API integration
│   │   ├── timetableParserService.ts # AI timetable parsing
│   ├── store/                        # Zustand stores (5 files)
│   ├── types/                        # TypeScript definitions (3 files)
│   └── config/                       # Configuration (2 files)
│
├── backend/                          # Node.js server
│   ├── src/
│   │   ├── index.js                  # Express server (1106 lines)
│   │   ├── sendNotification.js       # Notification logic
│   │   └── driveUpload.js            # Google Drive API
│   ├── config/
│   │   └── firebase.js               # Admin SDK
│   └── cron-service/                 # Scheduled tasks
│
└── docs/                             # Documentation

Backend Server Analysis

Line-by-line breakdown of the Express server

backend/src/index.js Express.js 1106 lines

Main Express server handling push notifications, file uploads, and deep links. All times in IST (Asia/Kolkata).

LinesPurpose
1-30Module imports (express, cors, helmet, multer, firebase)
31-46Environment config (PORT, APP_ENV, TIMEZONE)
47-70Multer file upload config (50MB limit, image/PDF filter)
71-106Middleware stack (Helmet, CORS, JSON parser, rate limiting)
107-135Firebase init and IST time utilities
136-206POST /save-token - Push token registration
207-263DELETE /delete-token - Token removal
264-320POST /send-notification - User notifications
321-476POST /notify-group-members - Group activity alerts
477-526POST /notify-followers - New note alerts
527-575POST /send-notification-all - Broadcast
576-646Daily and class reminder endpoints
647-710Token retrieval endpoints
711-862File upload routes (Google Drive, Catbox.moe)
863-1035GET /note/:noteId - Deep link HTML handler
1036-1106Error handlers, 404, server startup

Services Layer Analysis

Business logic and Firebase operations

groupsService.ts TypeScript 719 lines

Handles all group operations including CRUD, member management, real-time messaging, and notifications.

LinesMethodPurpose
35-79createGroup()Create group with creator as admin
84-104getGroup()Fetch single group by ID
109-139getPublicGroups()List public groups (client-side sort)
144-173getUserGroups()Get user's joined groups
178-205subscribeToMyGroups()Real-time group subscription
288-320addMember()Add user to group + increment count
325-345removeMember()Remove user + decrement count
410-451sendMessage()Send chat message + update activity
488-516subscribeToMessages()Real-time message listener
680-715notifyGroupMembers()Push notifications to members

authService.ts TypeScript

Firebase authentication operations including email/password and Google Sign-In.

MethodDescription
signUp(email, password, displayName)Create account + send verification email
signIn(email, password)Email/password authentication
signInWithGoogle()OAuth via Google Sign-In
sendVerificationEmail()Resend email verification
resetPassword(email)Password reset email
signOut()Log out current user

chatService.ts TypeScript

Groq API integration for BunkBot AI assistant with context injection.

FeatureDescription
ModelLlama 4 Maverick (meta-llama/llama-4-maverick-17b-128e-instruct)
Temperature0.7
Max Tokens2048
ContextAttendance data, timetable, user preferences
Image SupportBase64 image analysis
Quick PromptsPre-defined attendance-related questions

Component Analysis

Key React Native components

ChatBot.tsx React Native 793 lines

AI chat interface with multi-conversation support, voice input, and image attachments.

LinesFeature
7-49Imports (React, RN Paper, Expo modules)
65-82State declarations (chats, messages, input, etc.)
84-97Speech recognition event handlers
99-122toggleRecording() - Voice input control
134-146useEffect hooks (load, save, scroll)
152-196Chat management (switch, create, delete)
197-214Drawer animation functions
216-254Image picker (camera/gallery)
255-319handleSend() - Main message handler
348-625JSX render (header, messages, input, drawer)
626-793StyleSheet definitions

Custom Hooks

Reusable React hooks for common functionality

useResponsive.ts TypeScript

Provides responsive design utilities with breakpoints for mobile, tablet, desktop, and large desktop screens.

ExportTypeDescription
BREAKPOINTSObjectScreen width breakpoints (xs: 0, sm: 375, md: 768, lg: 1024, xl: 1280, xxl: 1536)
useResponsive()HookReturns responsive values and utility functions
Return ValueTypeDescription
isMobilebooleanScreen width < 768px
isTabletbooleanScreen width 768-1023px
isDesktopbooleanScreen width 1024-1279px
isLargeDesktopbooleanScreen width >= 1280px
isWebbooleanPlatform.OS === 'web'
responsive()FunctionReturns value based on screen size
spacing()FunctionResponsive spacing multiplier
fontSize()FunctionResponsive font size multiplier
containerPaddingnumberResponsive container padding
contentMaxWidthnumberResponsive max content width

State Management

Zustand stores for reactive state

authStore.ts Zustand 77 lines

Authentication state with Firebase observer and push notification registration.

StateTypePurpose
userUser | nullFirebase User object
loadingbooleanAuth loading state
initializedbooleanHas auth been checked
pushTokenstring | nullDevice push token
ActionDescription
setUser(user)Set current user
initializeAuth()Start Firebase auth listener
refreshUser()Force refresh from Firebase

Other Stores

StoreStatePurpose
networkStoreisOnline, lastOnlineTimeConnectivity monitoring
themeStoreisDarkMode, modeTheme preference (light/dark/system)
notesStorelikedNotes, savedNotesNote interaction cache
groupsStoregroups, messages, unreadCountsGroups and chat state

Type Definitions

TypeScript interfaces

Core Types

// types/user.ts
interface UserProfile {
  uid: string;
  displayName: string;
  email: string;
  photoURL?: string;
  college: string;
  course: string;
  department: string;
  semester: string;
  rollNumber: string;
  section?: string;
  minimumAttendance: number;
  onboardingCompleted: boolean;
}

// types/notes.ts
type NoteContentType = 'text' | 'pdf' | 'image' | 'link';

interface Note {
  id: string;
  authorId: string;
  authorName: string;
  title: string;
  description?: string;
  contentType: NoteContentType;
  content: string;
  fileUrl?: string;
  tags: string[];
  isPublic: boolean;
  likesCount: number;
  commentsCount: number;
  savesCount: number;
  createdAt: Date;
  updatedAt: Date;
}

// types/groups.ts
interface Group {
  id: string;
  name: string;
  description: string;
  category: 'study' | 'project' | 'social' | 'general';
  isPrivate: boolean;
  members: string[];
  memberCount: number;
  lastActivity?: Date;
}

interface GroupMessage {
  id: string;
  groupId: string;
  userId: string;
  userName: string;
  message: string;
  fileUrl?: string;
  createdAt: Date;
}

OCR & Timetable Extraction

Image text extraction and AI parsing services

ocrService.ts TypeScript 141 lines

OCR (Optical Character Recognition) service using OCR.space API. Extracts text from images supporting multiple formats and both web and native platforms.

LinesFunctionPurpose
1-11Imports & ConfigPlatform, expo-file-system/next, API URL/Key
16-37getImageMimeType()Detect MIME type from URI or base64 prefix
44-140extractTextFromImage()Main OCR extraction function
64-66Base64 handlingDirect base64 data URI support
67-90File URI handlingNative file:// and content:// URIs using File class
91-93URL handlingHTTP/HTTPS image URLs
102-126API ResponseParse OCR.space JSON response
// Key features:
- OCR Engine 2 (advanced recognition)
- Table detection enabled
- Auto-scale for better accuracy
- Supports: JPG, PNG, GIF, WebP, BMP, TIFF

timetableParserService.ts TypeScript

AI-powered service that parses OCR-extracted text into structured TimetableEntry objects using Groq API (Llama 4 Maverick model).

FeatureDescription
ModelLlama 4 Maverick (meta-llama/llama-4-maverick-17b-128e-instruct)
Temperature0.1 (low for structured output)
Max Tokens4096
Output FormatJSON array of TimetableEntry objects
Day NormalizationConverts Mon/Tue/etc. to full day names
Time NormalizationConverts to HH:MM 24-hour format
// Extracts from OCR text:
- Subject name and code
- Day of week
- Start and end times
- Class type (lecture/lab/tutorial)
- Faculty name (if present)
- Room/Location (if present)

Service Summary

All 17 services and their responsibilities

ServiceFilePurpose
AuthauthService.tsFirebase auth operations
FirestorefirestoreService.tsUser profile, timetable, subjects
ChatchatService.tsGroq AI integration
Chat StoragechatStorageService.tsChat history persistence
OCRocrService.tsOCR.space image text extraction
Timetable ParsertimetableParserService.tsAI parsing of OCR text to timetable
NotesnotesService.tsNotes CRUD, feed, search
GroupsgroupsService.tsGroups, members, real-time chat
SocialsocialService.tsLikes, comments, saves
FollowfollowService.tsFollow/unfollow, suggestions
NotificationnotificationService.tsPush token registration
CachecacheService.tsAsyncStorage caching
Offline QueueofflineQueueService.tsOffline operation queue
Image UploadimageUploadService.tsCatbox.moe uploads
File UploadfileUploadService.tsUpload coordination
Google DrivegoogleDriveService.tsGoogle Drive API
GeminigeminiService.tsAlternative AI service