Skip to content

AnsilKM/smart_attendance_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Smart Attendance System

A comprehensive attendance management system featuring a Flutter mobile application and a Node.js backend. This project handles user authentication, live face verification via ML Kit, precise geofence checking, and offline queue synchronization.


🏗 Project Structure

  • attendance_management_system/: The Flutter frontend application.
  • backend/: The Node.js and Express backend server, with PostgreSQL & Prisma.

🛠 Phase 1: Booting the Backend (Node.js + PostgreSQL)

Your Node.js backend handles all authentication, business logic, and geofence verification.

1. Database Setup

Ensure that your PostgreSQL server (like Postgres.app or Docker) is running on your Mac. Open the backend/.env file and verify your credentials are correct. It should look like this:

DATABASE_URL="postgresql://USERNAME:PASSWORD@localhost:5432/attendance_db?schema=public"
JWT_SECRET="your_super_secret_key"
PORT=3000

2. Install & Migrate Database

Open a terminal in the backend/ folder and run the following commands:

# 1. Install all backend dependencies
npm install

# 2. Push the Prisma Schema to your database (creates tables)
npx prisma migrate dev --name init

# 3. Seed initial data (Creates 1 Admin, 1 Employee, and 1 Geofence)
npx prisma db seed

3. Start the Server

npm run dev

(Leave this terminal open. You should see "Server running on port 3000")

4. View the Database (Prisma Studio)

If you want to look at the raw database tables, users, and attendances via a clean web GUI, open a new terminal in the backend/ folder and run:

npx prisma studio

This will automatically open your web browser to http://localhost:5555 where you can manually view and edit your data!


🌐 Phase 2: Configuring for Physical Device Testing

Because you are using a real phone, your phone cannot use localhost or 10.0.2.2 to connect to the computer's backend. They are two different physical devices. Your phone must connect to your Mac's external Wi-Fi IP address.

1. Find Your Mac's Wi-Fi IP Address

Open a new terminal tab and run this command to find your Mac's IP address:

ipconfig getifaddr en0

(Example output: 192.168.1.45)

2. Ensure Both Devices Share Wi-Fi

Ensure your physical phone and your Mac are connected to the exact same Wi-Fi network.

3. Update the Flutter App Configuration

Open attendance_management_system/lib/core/constants/api_constants.dart. Change the baseUrl string to use the IP address you found in Step 1.

// Change this:
static const String baseUrl = 'http://10.0.2.2:3000/api';

// To this (Use YOUR specific IP address):
static const String baseUrl = 'http://192.168.1.45:3000/api'; 

📱 Phase 3: Launching the Flutter App

  1. Plug your physical Android or iPhone into your Mac via USB.
  2. Ensure Developer Mode & USB Debugging are enabled on your phone.
  3. Open a terminal inside the attendance_management_system/ folder.
  4. Run:
# Get Flutter dependencies
flutter pub get

# Launch the app on your physical device
flutter run

🧪 Phase 4: The 4-Step Hardware Testing Checklist

Once the app opens on your phone, test the core system flows to ensure hardware configurations are properly tuned:

Test 1: Authentication API

  • Goal: Ensure the app can successfully reach your Node.js server.
  • Action: Try logging in with the default seeded credentials. Check your backend terminal—you should see a [POST] /auth/login network log hit the server!

Test 2: Face Verification & Camera

  • Goal: Verify OS permissions and ML Kit capabilities.
  • Action: Tap "Record Check-In". The app will prompt you for Camera Permissions. Allow it. Verify the camera stream starts smoothly and doesn't crash the app.

Test 3: Geofence Verification (GPS Accuracy)

  • Goal: Check if the device's native GPS hooks are working.
  • Action: When you attempt to check in, look at the VS Code debug console. The AppLogger will print: 🔵 [INFO] GPS retrieved: [12.9716, 77.5946].
  • Note: If it says you are out of bounds, you will need to log into the Admin Account, go to Locations, and create a Geofence explicitly covering the real-world GPS coordinates of your current house/office!

Test 4: Offline Queue & Background Sync

  • Goal: Verify resilience against total network failure.
    1. Pull down your phone's status bar and turn Airplane Mode ON.
    1. Attempt a Check-Out. You will see a warning that the network is dead, but it has been queued locally.
    1. Turn Airplane Mode OFF.
    1. Pull-to-refresh the screen or navigate away and back.
    1. Look at your VSCode Terminal; AppLogger should trace an event verifying the background queue successfully purged the data to the backend!

About

A full-stack Smart Attendance System featuring a Flutter mobile app and Node.js backend, built with live ML Kit face verification, precise geofencing, and offline sync.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors