Skip to content

hakimmudzaki/virtual-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

43 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Virtual Physics Lab - Projectile Motion Simulator

Aplikasi pembelajaran fisika interaktif untuk simulasi gerak parabola, dikembangkan dengan React Native (Expo) untuk platform Web dan Mobile (Android/iOS), dilengkapi dengan AI chatbot tutor.

πŸš€ Demo

✨ Fitur Utama

  • πŸ” Sistem Autentikasi - Login/Register dengan JWT + Google OAuth (Firebase)
  • 🎯 Simulasi Gerak Parabola - Visualisasi interaktif dengan animasi
  • πŸ“Š Sistem Kuis - Quiz interaktif dengan tracking skor terbaik
  • πŸ€– AI Chatbot Tutor - Powered by Google Gemini AI (khusus topik gerak parabola)
  • πŸ“š Materi Pembelajaran - Konten edukatif tentang gerak parabola
  • πŸ’Ύ Database Integration - MongoDB untuk user data dan history
  • πŸ“± Cross-Platform - Satu codebase untuk Web, Android, dan iOS

πŸ› οΈ Tech Stack

Frontend (Mobile & Web)

  • Framework: React Native + Expo SDK 54
  • Navigation: Expo Router (file-based routing)
  • State Management: React Context API
  • Authentication: Firebase Auth + Google Sign-In
  • UI Components: React Native core components
  • Styling: StyleSheet (React Native)

Backend

  • Runtime: Node.js + Express.js
  • Database: MongoDB Atlas
  • AI: Google Gemini Pro API
  • Authentication: JWT (JSON Web Tokens)
  • Deployment: Vercel Serverless Functions

πŸ“ Struktur Project

virtual-lab/
β”œβ”€β”€ api/                    # Backend API (Vercel Serverless)
β”‚   β”œβ”€β”€ index.js           # Main API routes
β”‚   └── ask.js             # AI Chatbot endpoint
β”œβ”€β”€ models/                 # MongoDB Models
β”‚   β”œβ”€β”€ User.js
β”‚   β”œβ”€β”€ Simulation.js
β”‚   └── Score.js
β”œβ”€β”€ mobile/                 # React Native App (Expo)
β”‚   β”œβ”€β”€ app/               # Expo Router pages
β”‚   β”‚   β”œβ”€β”€ _layout.tsx    # Root layout
β”‚   β”‚   β”œβ”€β”€ index.tsx      # Landing page
β”‚   β”‚   β”œβ”€β”€ login.tsx      # Login screen
β”‚   β”‚   β”œβ”€β”€ register.tsx   # Register screen
β”‚   β”‚   └── (tabs)/        # Tab navigation
β”‚   β”‚       β”œβ”€β”€ simulation.tsx
β”‚   β”‚       β”œβ”€β”€ materi.tsx
β”‚   β”‚       β”œβ”€β”€ quiz.tsx
β”‚   β”‚       β”œβ”€β”€ chatbot.tsx
β”‚   β”‚       └── profile.tsx
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/        # Firebase config
β”‚   β”‚   β”œβ”€β”€ context/       # React Context (Auth)
β”‚   β”‚   β”œβ”€β”€ services/      # API & Auth services
β”‚   β”‚   └── constants/     # App constants & colors
β”‚   β”œβ”€β”€ assets/            # Images & icons
β”‚   β”œβ”€β”€ app.json           # Expo config
β”‚   β”œβ”€β”€ eas.json           # EAS Build config
β”‚   └── package.json
β”œβ”€β”€ public/                 # Legacy web frontend (vanilla JS)
β”œβ”€β”€ vercel.json            # Vercel deployment config
β”œβ”€β”€ package.json           # Backend dependencies
└── README.md

πŸ”§ Environment Variables

Backend (.env)

GEMINI_API_KEY=your_gemini_api_key
MONGODB_URI=mongodb+srv://...
JWT_SECRET=your_jwt_secret
NODE_ENV=production

Mobile (mobile/.env)

EXPO_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
EXPO_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
EXPO_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
EXPO_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project.appspot.com
EXPO_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
EXPO_PUBLIC_FIREBASE_APP_ID=your_app_id
EXPO_PUBLIC_API_URL=https://your-backend.vercel.app

πŸ’» Local Development

Backend

# Install dependencies
npm install

# Run development server
npm run dev

# Server berjalan di http://localhost:3000

Mobile/Web App

# Masuk ke folder mobile
cd mobile

# Install dependencies
npm install

# Run untuk Web
npx expo start --web

# Run untuk Android (memerlukan emulator/device)
npx expo start --android

# Run untuk iOS (memerlukan Mac + Xcode)
npx expo start --ios

πŸš€ Deployment

Deploy Backend ke Vercel

# Dari root folder
vercel --prod

Deploy Web App ke Vercel

# Dari folder mobile
cd mobile
vercel --prod

Build APK Android

cd mobile

# Build APK (untuk distribusi langsung)
npx eas-cli build --profile production-apk --platform android

# Build AAB (untuk Google Play Store)
npx eas-cli build --profile production --platform android

Build iOS

cd mobile

# Build untuk App Store
npx eas-cli build --profile production --platform ios

πŸ“‘ API Endpoints

Endpoint Method Deskripsi Auth
/api/auth/register POST Registrasi user baru ❌
/api/auth/login POST Login user ❌
/api/auth/google POST Login dengan Google ❌
/api/auth/change-password POST Ubah password βœ…
/api/history GET Ambil riwayat simulasi βœ…
/api/history/:id DELETE Hapus satu riwayat βœ…
/api/history DELETE Hapus semua riwayat βœ…
/api/simulation POST Simpan hasil simulasi βœ…
/api/score GET Ambil skor terbaik βœ…
/api/score POST Update skor βœ…
/api/leaderboard GET Leaderboard ❌
/api/ask POST AI Chatbot βœ…

πŸ” Autentikasi

Aplikasi mendukung 2 metode login:

  1. Local Authentication

    • Username & password
    • Password di-hash dengan bcrypt
  2. Google OAuth

    • Firebase Authentication
    • Popup sign-in untuk web
    • Native Google Sign-In untuk mobile

πŸ“± Screenshots

Mobile App

  • Simulasi gerak parabola interaktif
  • Quiz dengan timer dan scoring
  • AI Chatbot untuk tanya jawab
  • Profile dengan riwayat simulasi

Web App

  • Responsive design (mobile-first)
  • PWA support
  • Same features as mobile

πŸ› Troubleshooting

Common Issues

  1. Firebase Auth Error (Web)

    • Pastikan domain sudah ditambahkan di Firebase Console β†’ Authentication β†’ Authorized domains
  2. API Connection Error

    • Cek API_URL di src/constants/index.ts
    • Pastikan backend sudah running
  3. Google Sign-In tidak berfungsi di APK

    • Pastikan SHA-1 fingerprint sudah ditambahkan di Firebase Console
    • Cek eas.json untuk keystore configuration
  4. Build APK gagal

    • Jalankan npx eas-cli build --profile production-apk --platform android --clear-cache

πŸ“„ License

ISC

πŸ‘¨β€πŸ’» Author

18223024 & 18223086

πŸ‘₯ Pembagian Tugas

NIM Tugas
18223024 Frontend (React Native), UI/UX Design, Simulasi Gerak Parabola, Integrasi Firebase Auth, Laporan Tugas
18223086 Backend API, Database MongoDB, AI Chatbot (Gemini), Deployment Vercel & Expo, Laporan Tugas

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published