Team Roles
Dev Shakya @devxoshakya
Frontend (Next.js, MagicUI, AceternityUI, Javascript)
Akshita Srivastava @akshitasrivastava20
Frontend (React.js, Javascript)
Ayush Bisht @WebDev-Ayush
Backend (express, Node.js)
Suryansh Patwal @StrugglerSuryansh
Database (MongoDB, Passport.js)
Yagyansh Singh Deshwal @yaggggy
Database (MongoDB)
Comprehensive Guide to Developing a Geolocation-Based Attendance Tracking App
This guide provides a detailed approach to building the attendance tracking app using Next.js, MongoDB, Express, Node.js, Google Maps API, Tailwind CSS, Magic UI, Aceternity UI, and Passport.js for authentication. The app will be developed as a PWA and later converted into a TWA for Android.
1. Project Structure
Here's an overview of the Next.js project structure:
attendance-app/
│
├── public/
│ ├── icons/
│ ├── manifest.json
│ └── service-worker.js
│
├── src/
│ ├── components/
│ │ ├── Auth/
│ │ ├── Dashboard/
│ │ ├── Layout/
│ │ └── Map/
│ │
│ ├── pages/
│ │ ├── api/
│ │ │ ├── auth/
│ │ │ ├── employees/
│ │ │ ├── geolocation/
│ │ │ ├── admin/
│ │ │ └── moderator/
│ │ ├── _app.jsx
│ │ ├── _document.jsx
│ │ └── index.jsx
│ │
│ ├── styles/
│ │ └── globals.css
│ │
│ ├── utils/
│ │ ├── apiHelper.js
│ │ └── geolocationHelper.js
│ │
│ ├── middleware/
│ │ ├── passport.js
│ │ └── authMiddleware.js
│ │
│ ├── config/
│ │ └── db.js
│ │
│ └── models/
│ ├── User.js
│ ├── Admin.js
│ ├── Moderator.js
│ └── Attendance.js
│
├── .babelrc
├── .eslintrc.json
├── package.json
└── tailwind.config.js
2. Tailwind CSS Integration
Global Styles:
-
Update your global CSS in
globals.css
:
Using Tailwind in Components:
-
Example of using Tailwind in a button component:
3. Database Design and Models
We will use MongoDB with Mongoose as our ODM.
Database Models:
-
User Model:
-
Attendance Model:
-
Admin Model:
-
Moderator Model:
4. Backend Structure with Passport.js Authentication
Passport.js Configuration
-
Passport Middleware (
passport.js
): -
Authentication Middleware (
authMiddleware.js
):
API Structure
Authentication Routes:
-
POST /api/auth/login
: Authenticates a user using Passport.js. -
POST /api/auth/logout
: Logs out a user.
Geolocation Routes:
-
POST /api/geolocation/check-in
: Records a user's check-in with location data. -
POST /api/geolocation/check-out
: Records a user's check-out with location data.
Admin Routes:
-
POST /api/admin/add-employee
: Adds a new employee.
5. Google Maps API Integration
Display Office Location and Geofencing:
-
Load Google Maps API:
-
Determine User Location:
6. PWA Conversion and TWA Implementation
PWA Setup:
-
Manifest File (
manifest.json
): -
Service Worker (
service-worker.js
):
TWA Conversion:
-
Generate Android Project:
Use tools like
bubblewrap
to create a TWA from your PWA: -
Configure
twa-manifest.json
:Ensure the file correctly points to your web app and set necessary settings.
-
Build and Deploy:
Build the project using Android Studio and deploy it to the Play Store.
Conclusion
This comprehensive guide outlines the full-stack development approach for the geolocation-based attendance tracking app. It includes setting up the environment, designing the backend and database, integrating Google Maps, implementing authentication with Passport.js, and converting the PWA to a TWA. The structure and code snippets provided should help in building a robust, scalable, and user-friendly application.