Skip to content

Latest commit

Β 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VastuWise AI - React Native Mobile App with Authentication

A mobile application for Vastu Shastra analysis built with React Native, TypeScript, Express, Prisma, and PostgreSQL. Features complete user authentication with email/password and Google OAuth, persistent login state, and a custom drawer navigation menu.

πŸš€ Quick Start

# Install backend dependencies
cd backend
npm install

# Install mobile app dependencies
cd ..
npm install

# Setup environment variables
cp backend/.env.example backend/.env
# Update DATABASE_URL and Google OAuth credentials in backend/.env

# Start backend
cd backend
npm run dev

# In a new terminal, start mobile app
npm run android  # or npm run ios

🎯 Features Implemented

βœ… Authentication System

  • Email/Password Authentication - Secure signup and login with validation
  • Google OAuth Integration - Configured with OAuth 2.0 credentials (in progress)
  • JWT Token Management - Secure token-based session handling
  • Password Security - bcrypt hashing with salt rounds (10)
  • Token Storage - AsyncStorage for persistent sessions across app restarts
  • Persistent Login - User data and token automatically restored on app launch

βœ… Screens

  1. LoginScreen - Email/password authentication with validation, API integration, links to SignUp
  2. SignUpScreen - User registration with email, password, name fields, real-time validation
  3. WelcomeScreen - Onboarding page with feature grid, menu button (☰), and smooth animations
  4. CustomDrawer - Side menu with user profile (avatar, name, email), menu items (Home, Dashboard, Profile, Learn Vastu, Settings), and logout button
  5. DashboardScreen - Protected screen template for post-authentication content
  6. ProfileFormScreen - User profile management form template

βœ… Backend API (Node.js + Express + Prisma)

  • RESTful API - Complete authentication endpoints (signup, login, profile management)
  • PostgreSQL Database - Prisma ORM with type safety, automatically migrated
  • Google OAuth - Passport.js integration configured and ready for testing
  • JWT Authentication - Secure token-based auth with JWT signing and verification
  • Input Validation - express-validator middleware for email, password, and name fields
  • Error Handling - Comprehensive error responses with proper HTTP status codes
  • Database Models - User (with email, password, name, googleId, profile fields) and VastuAnalysis tables

βœ… Reusable Components

  • CustomButton - Primary, secondary, and outline variants with loading/disabled states
  • CustomTextInput - Labeled input with validation, password toggle, and error display
  • CustomCard - Glass morphism and solid card variants with icon support
  • CustomDrawer - Custom Modal-based drawer with animated slide transitions and user profile display

βœ… Theme System

  • Colors - Centralized color palette with primary (#db7706)
  • Typography - Font families, sizes, weights, and line heights
  • Spacing - Consistent spacing scale and border radius system

βœ… Services & Utilities

  • AuthService - API call management
  • StorageService - Token and user data persistence
  • Google Auth Util - OAuth flow handling
  • API Config - Centralized endpoint configuration

πŸ“‚ Project Structure

Vastu-Analyzer-mad/
β”œβ”€β”€ backend/                    # Backend API Server
β”‚   β”œβ”€β”€ prisma/
β”‚   β”‚   └── schema.prisma      # Database schema
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/            # Database & OAuth config
β”‚   β”‚   β”œβ”€β”€ middleware/        # Auth & error middleware
β”‚   β”‚   β”œβ”€β”€ routes/            # API routes
β”‚   β”‚   β”œβ”€β”€ utils/             # JWT & password utilities
β”‚   β”‚   └── index.ts           # Server entry
β”‚   β”œβ”€β”€ .env.example           # Environment template
β”‚   └── package.json
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ screens/               # All screens
β”‚   β”‚   β”œβ”€β”€ LoginScreen.tsx    # βœ… Email/password auth, API integrated
β”‚   β”‚   β”œβ”€β”€ SignUpScreen.tsx   # βœ… User registration with validation
β”‚   β”‚   β”œβ”€β”€ WelcomeScreen.tsx  # βœ… Onboarding with feature grid and menu button
β”‚   β”‚   β”œβ”€β”€ DashboardScreen.tsx # βœ… Protected dashboard template
β”‚   β”‚   └── ProfileFormScreen.tsx # βœ… Profile management template
β”‚   β”œβ”€β”€ components/            # Reusable components
β”‚   β”‚   β”œβ”€β”€ CustomButton.tsx
β”‚   β”‚   β”œβ”€β”€ CustomTextInput.tsx
β”‚   β”‚   β”œβ”€β”€ CustomCard.tsx
β”‚   β”‚   └── CustomDrawer.tsx   # βœ… NEW - Modal-based side menu
β”‚   β”œβ”€β”€ services/              # βœ… API services and storage
β”‚   β”‚   β”œβ”€β”€ storage.service.ts # βœ… AsyncStorage for token/user data
β”‚   β”‚   └── auth.service.ts
β”‚   β”œβ”€β”€ config/                # βœ… API configuration
β”‚   β”œβ”€β”€ utils/                 # βœ… Helper functions
β”‚   └── theme/                 # Design system
β”‚
β”œβ”€β”€ QUICK_START.md             # πŸš€ Start here!
β”œβ”€β”€ AUTHENTICATION_GUIDE.md    # Auth implementation details
β”œβ”€β”€ MOBILE_SETUP.md            # Mobile app setup
β”œβ”€β”€ backend/README.md          # Backend setup guide
β”œβ”€β”€ setup.bat / setup.sh       # Automated setup scripts
└── package.json

πŸ“š Documentation

πŸ” Authentication Flow

  1. Sign Up: User creates account with email/password β†’ validation β†’ API call to /api/auth/signup β†’ token received β†’ stored in AsyncStorage
  2. Login: User enters credentials β†’ validation β†’ API call to /api/auth/login β†’ JWT token received β†’ user data stored β†’ navigates to Welcome screen
  3. Persistent Login: App checks AsyncStorage on launch β†’ if token exists, user automatically logged in β†’ skips authentication screens
  4. Token Storage: JWT token and user data (name, email) saved in AsyncStorage using storage.service.ts
  5. Drawer Menu: After successful login, hamburger menu (☰) displays on Welcome screen β†’ opens custom drawer β†’ shows user profile and menu items β†’ logout clears AsyncStorage
  6. Session Management: Token sent with protected API requests, logout clears stored credentials

πŸ› οΈ Tech Stack

Frontend (Mobile)

  • React Native 0.83.1
  • TypeScript
  • AsyncStorage (token persistence)
  • Expo Web Browser & Auth Session (OAuth)

Backend (API)

  • Node.js + Express
  • Prisma ORM
  • PostgreSQL
  • Passport.js (Google OAuth)
  • JWT (jsonwebtoken)
  • bcryptjs (password hashing)

πŸ“‹ API Endpoints

Authentication

POST /api/auth/signup - Create account (email, password, name) POST /api/auth/login - Email/password login (returns JWT token) GET /api/auth/google - Initiate Google OAuth flow GET /api/auth/google/callback - OAuth callback handler GET /api/auth/verify - Verify JWT token validity (protected)

User Profile

GET /api/user/profile - Get user profile data (protected) PUT /api/user/profile - Update profile info (protected)

Vastu Analysis (Future)

POST /api/analysis/upload - Upload floor plan/image GET /api/analysis/list - Get user's analyses GET /api/analysis/:id - Get analysis detailsd) PUT /api/user/profile - Update profile (protected)


# Getting Started

> **Note**: Make sure you have completed the [Set Up Your Environment](https://reactnative.dev/docs/set-up-your-environment) guide before proceeding.

## Quick Setup

### 1. Install Dependencies

```bash
# Backend
cd backend
npm install

# Mobile App
cd ..
npm install

2. Set Up Database

Use Supabase (free) or local PostgreSQL:

# Create backend/.env file
cp backend/.env.example backend/.env

# Update DATABASE_URL in backend/.env
DATABASE_URL="postgresql://user:password@localhost:5432/vastu_analyzer"

3. Initialize Database

cd backend
npm run prisma:generate
npm run prisma:migrate

4. Start Backend

cd backend
npm run dev
# Server running on http://localhost:3000

5. Start Mobile App

# In a new terminal
npm run android  # or npm run ios

Step 1: Start Metro

First, you will need to run Metro, the JavaScript build tool for React Native.

To start the Metro dev server, run the following command from the root of your React Native project:

# Using npm
npm start

# OR using Yarn
yarn start

Step 2: Build and run your app

With Metro running, open a new terminal window/pane from the root of your React Native project, and use one of the following commands to build and run your Android or iOS app:

Android

# Using npm
npm run android

# OR using Yarn
yarn android

iOS

For iOS, remember to install CocoaPods dependencies (this only needs to be run on first clone or after updating native deps).

The first time you create a new project, run the Ruby bundler to install CocoaPods itself:

bundle install

Then, and every time you update your native dependencies, run:

bundle exec pod install

For more information, please visit CocoaPods Getting Started guide.

# Using npm
npm run ios

# OR using Yarn
yarn ios

If everything is set up correctly, you should see your new app running in the Android Emulator, iOS Simulator, or your connected device.

This is one way to run your app β€” you can also build it directly from Android Studio or Xcode.

Step 3: Modify your app

Now that you have successfully run the app, let's make changes!

Open App.tsx in your text editor of choice and make some changes. When you save, your app will automatically update and reflect these changes β€”Β this is powered by Fast Refresh.

When you want to forcefully reload, for example to reset the state of your app, you can perform a full reload:

  • Android: Press the R key twice or select "Reload" from the Dev Menu, accessed via Ctrl + M (Windows/Linux) or Cmd ⌘ + M (macOS).
  • iOS: Press R in iOS Simulator.

Congratulations! πŸŽ‰

You've successfully run and modified your React Native App. πŸ₯³

Now what?

  • If you want to add this new React Native code to an existing application, check out the Integration guide.
  • If you're curious to learn more about React Native, check out the docs.

Troubleshooting

If you're having issues getting the above steps to work, see the Troubleshooting page.

Learn More

To learn more about React Native, take a look at the following resources:

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages