Skip to content

optimus-prime-01/IAF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

113 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VayuReader πŸ“š

A comprehensive multi-platform solution for PDF management, document search, and content discovery with advanced authentication and admin management

React Native Expo Node.js Express.js MongoDB JWT

VayuReader is a powerful, multi-module platform designed for seamless PDF document management, intelligent search capabilities, and comprehensive content organization. The platform combines a mobile-first approach with robust backend services and an intuitive admin dashboard.


✨ Key Features

  • πŸ“± Android Mobile App – Built with React Native (Expo) for Android platform
  • πŸ” Intelligent PDF Search - Advanced search engine with full-text indexing
  • πŸ“– Dictionary Integration - Built-in dictionary with synonyms and antonyms
  • πŸ”€ Abbreviation Management - Comprehensive abbreviation lookup system
  • πŸ” Secure Authentication - OTP-based user authentication and JWT-based admin authentication
  • πŸ‘¨β€πŸ’Ό Admin Dashboard - Web-based content management interface with role-based access
  • πŸ‘₯ Sub-Admin Management - Super admin can create and manage sub-admins
  • πŸ“Š Audit Logging - Complete activity tracking for all admin actions
  • πŸ”’ Role-Based Access Control - Users (read-only), Admins (full access)
  • ☁️ Cloud-Ready - Scalable microservices architecture

πŸ—οΈ Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Mobile App        β”‚    β”‚   Backend APIs      β”‚    β”‚   Admin Dashboard   β”‚
β”‚   (React Native)    │◄──►│   (Node.js/Express) │◄──►│   (React/Tailwind)  β”‚
β”‚                     β”‚    β”‚                     β”‚    β”‚                     β”‚
β”‚ β€’ PDF Viewer        β”‚    β”‚ β€’ PDF Search        β”‚    β”‚ β€’ Content Managementβ”‚
β”‚ β€’ Search Interface  β”‚    β”‚ β€’ Authentication    β”‚    β”‚ β€’ User Management   β”‚
β”‚ β€’ Dictionary        β”‚    β”‚ β€’ Abbreviations     β”‚    β”‚ β€’ Sub-Admin Mgmt    β”‚
β”‚ β€’ Abbreviations     β”‚    β”‚ β€’ Dictionary API    β”‚    β”‚ β€’ Audit Logs        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                                      β–Ό
                           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                           β”‚   MongoDB Atlas     β”‚
                           β”‚   (Database)        β”‚
                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‚ Project Structure

VayuReader/
β”œβ”€β”€ πŸ“± VayuReader_Frontend/          # Mobile Application
β”‚   β”œβ”€β”€ app/                         # File-based routing
β”‚   β”œβ”€β”€ components/                  # Reusable UI components
β”‚   β”œβ”€β”€ services/                    # API integration
β”‚   └── assets/                      # Images, fonts, etc.
β”‚
β”œβ”€β”€ πŸ–₯️ VayuReader_Backend/           # Backend Services
β”‚   β”œβ”€β”€ pdf-search-engine/           # PDF management & search (Port 3005)
β”‚   β”œβ”€β”€ abrebiations/                # Abbreviation API (Port 3001)
β”‚   β”œβ”€β”€ dictionary-api/              # Dictionary service (Port 3000)
β”‚   β”œβ”€β”€ auth/                        # User OTP authentication (Port 3010)
β”‚   β”œβ”€β”€ admin_auth/                  # Admin authentication & management (Port 3012)
β”‚   β”‚   β”œβ”€β”€ middleware/              # Unified authentication middleware
β”‚   β”‚   β”œβ”€β”€ controllers/             # Sub-admin management
β”‚   β”‚   β”œβ”€β”€ models/                  # Audit logs, Sub-admins
β”‚   β”‚   └── routes/                  # Audit routes, Sub-admin routes
β”‚   └── shared/                      # Common utilities
β”‚
└── 🌐 VayuReader_AdminDashboard/    # Web Admin Interface
    β”œβ”€β”€ frontend/                    # React dashboard
    β”‚   β”œβ”€β”€ components/              # Dashboard components
    β”‚   β”‚   β”œβ”€β”€ ManageAbbreviations.jsx
    β”‚   β”‚   β”œβ”€β”€ ManagePDFs.jsx
    β”‚   β”‚   β”œβ”€β”€ ManageDictionaryWords.jsx
    β”‚   β”‚   └── ManageSubAdmins.jsx
    β”‚   └── services/                # Admin API calls

πŸš€ Quick Start

Prerequisites

  • Node.js 18.x or higher
  • MongoDB 6.0+ (or MongoDB Atlas)
  • Expo CLI
  • Git
  • Docker & Docker Compose (optional, for containerized deployment)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/VayuReader.git
    cd VayuReader
  2. Backend Setup

    Each service needs to be set up individually:

    # 1. Auth Service (User OTP Authentication)
    cd VayuReader_Backend/auth
    npm install
    cp env.sample .env
    # Edit .env with your MongoDB URI and JWT_SECRET
    npm run dev  # Runs on port 3010
    
    # 2. Admin Auth Service
    cd ../admin_auth
    npm install
    # Create .env file (see Configuration section)
    npm run dev  # Runs on port 3012
    
    # 3. Abbreviations Service
    cd ../abrebiations
    npm install
    # Create .env with MONGODB_URI
    npm run dev  # Runs on port 3001
    
    # 4. PDF Search Engine
    cd ../pdf-search-engine
    npm install
    # Create .env with MONGODB_URI
    npm run dev  # Runs on port 3005
    
    # 5. Dictionary API
    cd ../dictionary-api
    npm install
    # Create .env with MONGODB_URI
    npm run dev  # Runs on port 3000
  3. Admin Dashboard Setup

    cd VayuReader_AdminDashboard/frontend
    npm install
    npm start
  4. Mobile App Setup See detailed instructions in Mobile App Setup section below.


πŸ”§ Configuration

Environment Variables

Auth Service (VayuReader_Backend/auth/.env)

PORT=3010
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/dbname
JWT_SECRET=your-secret-key-change-this
JWT_EXPIRY_DAYS=1
OTP_EXPIRY_MINUTES=5
OTP_GATEWAY_URL=http://msg.com:8080/smsc/sends msg
SKIP_OTP_SEND=true  # Set to true for development

Admin Auth Service (VayuReader_Backend/admin_auth/.env)

ADMIN_NAME=Himanshu Bhatt
ADMIN_CONTACT=89200 67341
JWT_SECRET=admin-secret-key-change-this
JWT_EXPIRY_DAYS=1
ADMIN_AUTH_PORT=3012
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/dbname
USER_JWT_SECRET=change_me  # Should match JWT_SECRET from auth service

Other Services

Each service needs:

MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/dbname
PORT=<service_port>

πŸ” Authentication & Authorization

User Authentication (OTP-Based)

Users authenticate using OTP sent to their phone number:

  1. Request OTP

    POST http://localhost:3010/api/auth/login/request-otp
    Body: { "name": "User Name", "phone_number": "9876543210" }
  2. Verify OTP

    POST http://localhost:3010/api/auth/login/verify-otp
    Body: { "phone_number": "9876543210", "otp": "123456" }
    Response: { "token": "jwt_token", "user": {...} }

User Permissions: Read-only access (GET requests only)

Admin Authentication

Admins authenticate with name and contact:

POST http://localhost:3012/api/auth/login
Body: { "name": "Himanshu Bhatt", "contact": "89200 67341" }
Response: { "token": "jwt_token", "admin": {...} }

Admin Permissions: Full access (GET, POST, PUT, DELETE)

Sub-Admin Management

Super admin can create and manage sub-admins:

# Get all sub-admins (Super admin only)
GET http://localhost:3012/api/sub-admins
Headers: Authorization: Bearer <super_admin_token>

# Create sub-admin (Super admin only)
POST http://localhost:3012/api/sub-admins
Body: { "name": "Sub Admin", "contact": "1234567890" }

# Delete sub-admin (Super admin only)
DELETE http://localhost:3012/api/sub-admins/<id>

Sub-Admin Permissions: Same as super admin (full access to content, but cannot manage other admins)


πŸ“Š Audit Logging

All admin actions are automatically logged:

# Get audit logs
GET http://localhost:3012/api/audit/logs?page=1&limit=50
Headers: Authorization: Bearer <admin_token>

# Get audit statistics
GET http://localhost:3012/api/audit/stats
Headers: Authorization: Bearer <admin_token>

Audit logs track:

  • Action type (CREATE, UPDATE, DELETE)
  • Resource type (ABBREVIATION, PDF, DICTIONARY_WORD)
  • Admin information (name, contact)
  • Timestamp
  • Resource details

πŸ”Œ API Documentation

Service Ports

Service Port Base URL
Auth Service 3010 http://localhost:3010
Admin Auth Service 3012 http://localhost:3012
Abbreviations Service 3001 http://localhost:3001
PDF Service 3005 http://localhost:3005
Dictionary Service 3000 http://localhost:3000

API Endpoints

Authentication

Endpoint Method Auth Description
/api/auth/login/request-otp POST None Request OTP for user login
/api/auth/login/verify-otp POST None Verify OTP and get user token
/api/auth/login POST None Admin login

Abbreviations

Endpoint Method Auth Description
/api/abbreviations/:abbr GET User/Admin Get abbreviation by name
/api/abbreviations/all GET User/Admin Get all abbreviations
/api/abbreviations POST Admin Create abbreviation
/api/abbreviations/:id PUT Admin Update abbreviation
/api/abbreviations/:id DELETE Admin Delete abbreviation

PDFs

Endpoint Method Auth Description
/api/pdfs GET User/Admin Search PDFs
/api/pdfs/all GET User/Admin Get all PDFs
/api/pdfs/:id GET User/Admin Get PDF by ID
/api/pdfs/upload POST Admin Upload PDF
/api/pdfs/:id PUT Admin Update PDF
/api/pdfs/:id DELETE Admin Delete PDF

Dictionary

Endpoint Method Auth Description
/api/dictionary/word/:word GET User/Admin Get word definition
/api/dictionary/words GET User/Admin Get word list
/api/dictionary/words/all GET User/Admin Get all words
/api/dictionary/search/:term GET User/Admin Search words
/api/dictionary POST Admin Add word
/api/dictionary/:id PUT Admin Update word
/api/dictionary/:id DELETE Admin Delete word

Sub-Admin Management (Super Admin Only)

Endpoint Method Auth Description
/api/sub-admins GET Super Admin Get all sub-admins
/api/sub-admins POST Super Admin Create sub-admin
/api/sub-admins/:id DELETE Super Admin Delete sub-admin

Audit Logs (Admin Only)

Endpoint Method Auth Description
/api/audit/logs GET Admin Get audit logs (with filters)
/api/audit/stats GET Admin Get audit statistics

πŸ“± Mobile App Setup

Prerequisites

  1. An Android phone
  2. A laptop/PC with the project set up
  3. Both devices on the same Wi-Fi or hotspot

Step-by-Step Instructions

  1. Install the App on Your Phone

    • Download the APK from the provided link
    • Allow installation from unknown sources
    • Install the app
  2. Start the Development Server

    cd VayuReader_Frontend
    npx expo start --dev-client
  3. Connect Your Phone

    • The app should auto-connect
    • If not, manually enter the connection URL from the terminal
  4. Update Code

    • No need to reinstall
    • Just restart the dev server and reopen the app
  5. Rebuild App (only when needed)

    eas build --platform android --profile development

πŸ§ͺ Testing

See POSTMAN_TESTING_GUIDE.md for comprehensive API testing instructions.

Quick Test Checklist

  • User can request and verify OTP
  • User can read data (GET requests)
  • User cannot write data (POST/PUT/DELETE - should get 403)
  • Admin can login
  • Admin can perform all operations
  • Super admin can manage sub-admins
  • Sub-admins cannot manage other admins
  • Audit logs are being recorded

πŸ› οΈ Technology Stack

Frontend

  • React Native - Cross-platform mobile development
  • Expo - Development platform and tools
  • NativeWind - Tailwind CSS for React Native
  • React Navigation - Navigation library
  • Axios - HTTP client

Backend

  • Node.js - Runtime environment
  • Express.js - Web framework
  • MongoDB - NoSQL database
  • Mongoose - MongoDB object modeling
  • JWT - Authentication tokens
  • Multer - File upload handling
  • bcrypt - Password hashing (for legacy)
  • Docker - Containerization

Admin Dashboard

  • React - UI library
  • Tailwind CSS - Utility-first CSS framework
  • React Router - Client-side routing
  • Axios - HTTP client

🐳 Docker Deployment

Build and Run All Services

cd VayuReader_Backend
docker-compose up --build

Individual Service Dockerfiles

Each service has its own Dockerfile for independent deployment.


🚒 Deployment

Backend Services

Deploy to cloud providers (AWS, GCP, Azure, Render, etc.)

Frontend

Build and deploy using Expo EAS

Admin Dashboard

Deploy to Vercel, Netlify, or similar platform


πŸ“ Features Breakdown

πŸ” Search Engine

  • Full-text search across PDF content
  • Advanced query syntax support
  • Search result ranking and relevance

πŸ“š Content Management

  • Bulk PDF upload and processing
  • Metadata management
  • File organization and categorization

πŸ‘₯ User Management

  • OTP-based user authentication
  • Admin and sub-admin management
  • Role-based access control

πŸ“Š Audit & Monitoring

  • Complete activity logging
  • Admin action tracking
  • Statistics and reporting

🀝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ž Support

For issues, questions, or contributions, please open an issue on GitHub.


🎯 Roadmap

  • AI-powered content recommendations
  • Multi-language support
  • Advanced analytics dashboard
  • Integration with cloud storage providers
  • Voice search capabilities
  • Collaborative annotation features
  • Real-time notifications
  • Advanced search filters

πŸ“„ License

This project is licensed under the ISC License.


πŸ™ Acknowledgments

Built with ❀️ for the Indian Air Force community


πŸ“š Additional Documentation


Built with ❀️ for the Indian Air Force community

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors