You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Star3 (3)You must be signed in to star a repository
About
NearBuy – A centralized shopping platform that helps users compare prices across local stores in real-time. Admins can add shops, manage items, and update prices, while consumers can browse stores, find products, and get the best deals nearby.
NearBuyHQ is the Android admin application for shop owners in the NearBuy ecosystem.
It lets shop owners manage their products, handle orders, run promotions, view analytics, and keep their store information up to date — all backed by Firebase Firestore in real time.
Both apps read from and write to the same Firebase Firestore database.
The shop owner's Firebase Auth UID acts as the shop ID — every product, order, and notification is stored under NearBuyHQ/{userId}/….
Features
🔐 Authentication
Register with full name, email, username and password
Email OTP verification — a 6-digit code is sent via Gmail SMTP before the account is activated
Login with email / username and password
Forgot Password flow with OTP-based reset
Session persistence via SharedPreferences (SessionManager)
🏠 Dashboard
Greeting header showing the owner's name and shop name (loaded live from Firestore)
Stats cards: Total Products, Low-Stock count, Orders & Revenue
Business Overview filter: Today / Yesterday / Last 7 Days / This Month / Lifetime
Quick-action tiles: Add Product, Manage Inventory, Discounts, Manage Orders, View Reports, Set Store Location
Activity / Fragment
│ calls
▼
Repository (e.g. ProductRepository)
│ uses
▼
FirebaseFirestore / FirebaseAuth
│ results via
▼
DataCallback<T> / OperationCallback (interface callbacks)
│ back to
▼
Activity (runOnUiThread → update UI)
Package & File Reference
app.startup
File
Purpose
SplashScreen.java
Launcher activity — shows the NearBuyHQ logo for ~1.5 s, then routes to Welcome (first run) or Dashboard (returning user).
Welcome.java
Onboarding screen with Get Started and Log In buttons.
auth
File
Purpose
Login.java
Email/username + password login via Firebase Auth. Checks email-verification status in Firestore before granting access; redirects to OTPVerification if OTP was never completed.
Register.java
New account registration form (full name, email, username, password). Calls AuthRepository.register() and then sends an OTP to the email.
6-digit OTP input screen. Verifies the code stored in Firestore (otp_codes collection). On success, marks the account as email-verified and navigates to Dashboard.
EmailOtpService.java
Generates a random 6-digit OTP, stores it in Firestore with a 10-minute expiry, and sends a styled HTML email via Gmail SMTP (credentials from BuildConfig / .env).
core
File
Purpose
SessionManager.java
Singleton wrapper around SharedPreferences. Stores and retrieves userId, userName, userEmail, userPhone, shopId, shopName across the app lifecycle. Exposes isLoggedIn() and clearSession().
firebase/FirebaseConfig.java
Reads the FIREBASE_ENABLED build config flag. Used to short-circuit repository calls when Firebase is disabled (local dev / testing).
dashboard
File
Purpose
Dashboard.java
Main home screen after login. Displays live stats (total products, low-stock count, orders, revenue) filtered by a selectable time period (Today / Yesterday / 7 Days / Month / Lifetime). Contains a bottom navigation bar and six quick-action tiles.
Analytics.java
Analytics screen with a MPAndroidChart bar chart showing daily revenue for the last 7 days, plus KPI cards: Total Revenue, Total Sales, Completed / Pending / Processing / Cancelled order counts.
data/model
File
Purpose
User.java
POJO for a shop-owner user profile: uid, name, email, username, phone, shopName, shopLocation, openingHours, emailVerified.
data/remote/firebase
File
Purpose
FirebaseCollections.java
Central constants for all Firestore collection/subcollection names (NearBuyHQ, otp_codes, products, deals, promotions, orders, reports, notifications). Prevents hard-coded strings across the codebase.
Full-screen list of in-app notifications for the shop owner. Supports real-time search. Notification types include Low Stock Alert, New Order, Deal Expiring.
NotificationsAdapter.java
RecyclerView.Adapter for notification list items — shows title, body, timestamp, and a type icon.
Displays all orders with tab-style status filters (All / Pending / Processing / Delivered / Cancelled / Rejected) and a real-time search bar.
Order_details.java
Full order detail screen — shows customer name, address, product line items, total, order date, and status. Provides Accept / Reject / Mark as Delivered action buttons.
OrderAdapter.java
RecyclerView.Adapter for order list rows — shows order ID, customer, total, date and colour-coded status badge.
Displays and allows editing of the owner's personal info (name, email, phone) and shop details (shop name, location, opening hours). Triggers LocationPickerActivity for map-based location selection.
LocationPickerActivity.java
Full-screen Google Maps activity. Supports: map tap to drop a pin, drag to reposition, Google Places autocomplete search bar, Geocoder reverse-geocoding for address display. Returns (lat, lng, address) to ProfilePage.
LogoutConfirmation.java
Confirmation dialog activity for logout — clears SessionManager and Firebase Auth session, then returns to Login.
Note:userId == shopId — registering an account simultaneously registers the shop. No separate shops collection is needed.
Environment Setup (.env)
The app reads sensitive keys from a .env file in the project root (ignored by git).
1 — Firebase
Add your Firebase Android app config:
app/google-services.json
2 — Create .env
Create a file named .env in the project root (same level as settings.gradle.kts):
# ── Firebase ───────────────────────────────────────────────FIREBASE_ENABLED=trueFIREBASE_PROJECT_ID=your-firebase-project-id# ── Google Maps / Places ───────────────────────────────────GOOGLE_MAP_APIKEY=your-google-maps-api-key# ── Gmail SMTP (for OTP emails) ────────────────────────────# Use a Gmail App Password, NOT your account passwordSMTP_EMAIL=your-sender@gmail.comSMTP_PASSWORD=your-gmail-app-password
Key
Where it's used
FIREBASE_ENABLED
FirebaseConfig.isFirebaseEnabled() — gates all Firestore calls
FIREBASE_PROJECT_ID
Exposed as BuildConfig.FIREBASE_PROJECT_ID
GOOGLE_MAP_APIKEY
Injected into AndroidManifest via manifestPlaceholders; also used by LocationPickerActivity + Places SDK
SMTP_EMAIL / SMTP_PASSWORD
EmailOtpService — sends OTP emails via JavaMail over Gmail SMTP
If FIREBASE_ENABLED=false, all repository calls are short-circuited and return error callbacks immediately. Use this for UI-only development without a Firebase project.
Build & Run
Prerequisites
Android Studio Hedgehog (2023.1.1) or later
JDK 17
Android device or emulator running API 24+
Steps
# 1. Clone the repository
git clone https://github.com/<your-org>/NearBuyHQ.git
cd NearBuyHQ
# 2. Add google-services.json# Copy your Firebase Android config to: app/google-services.json# 3. Create .env (see Environment Setup above)# 4. Build debug APK
.\gradlew.bat :app:assembleDebug
# 5. Install on connected device
.\gradlew.bat :app:installDebug
# 6. Run unit tests
.\gradlew.bat :app:testDebugUnitTest
The debug APK is output to:
app/build/outputs/apk/debug/app-debug.apk
Firestore Indexes
If Firestore prompts you to create a composite index for queries ordered by updatedAt or createdAt, follow the link in Logcat or create indexes manually in the Firebase Console for:
Collection
Fields
NearBuyHQ/{uid}/products
shopId ASC + updatedAt DESC
NearBuyHQ/{uid}/orders
shopId ASC + createdAt DESC
Permissions
Permission
Reason
INTERNET
Firebase Firestore + Auth, Google Maps, Gmail SMTP
ACCESS_FINE_LOCATION
GPS capture for shop location in LocationPickerActivity
This project is licensed under the GNU General Public License v3.0 — see the LICENSE file for full terms.
This project was developed as coursework for the Higher National Diploma in Software Engineering (HNDSE) at the National Institute of Business Management (NIBM) — Mobile Application Development module.
About
NearBuy – A centralized shopping platform that helps users compare prices across local stores in real-time. Admins can add shops, manage items, and update prices, while consumers can browse stores, find products, and get the best deals nearby.