Skip to content

MightySuz/community-library-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

37 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Community Library App

A comprehensive multi-platform application for community book sharing and management.

Features

πŸ” User Registration & Authentication

  • Multi-step Registration: Personal info, family/community details, security setup
  • Multi-persona Support: Users can be Publishers, Borrowers, or Administrators
  • OTP Verification: Email and SMS verification with resend functionality
  • Admin Approval: Manual review and approval process for new users
  • Secure Authentication: JWT-based auth with refresh tokens

πŸ“š Book Management

  • Book Publishing: Scan barcodes to add books to the library
  • Book Discovery: Search and browse available books
  • Rental System: Request and manage book rentals
  • Digital Wallet: Track balances and automated fine calculations

πŸ‘₯ User Personas

  1. Publisher (Lender): Individuals who lend books to the community
  2. Borrower: Users who borrow books from publishers
  3. Administrator: System managers who approve users and oversee operations

πŸ“± Multi-Platform Support

  • Mobile App: React Native for iOS and Android
  • Web Application: Responsive React.js web app
  • Admin Dashboard: Comprehensive user and system management

🎯 Overview

Community Library enables users to lend and borrow books within their community through three main personas:

  • Publishers (Lenders): Add books via barcode scanning, manage lending
  • Borrowers: Discover and borrow books, manage digital wallet
  • Administrators: Approve books, manage users, oversee transactions

πŸ—οΈ Architecture

Community Library Project/
β”œβ”€β”€ mobile/                 # React Native mobile app
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/     # Shared mobile components
β”‚   β”‚   β”œβ”€β”€ screens/        # Mobile screens
β”‚   β”‚   β”‚   β”œβ”€β”€ RegisterScreen.js
β”‚   β”‚   β”‚   β”œβ”€β”€ OTPVerificationScreen.js
β”‚   β”‚   β”‚   └── ApprovalPendingScreen.js
β”‚   β”‚   β”œβ”€β”€ navigation/     # Navigation setup
β”‚   β”‚   └── utils/          # Mobile utilities
β”‚   β”œβ”€β”€ package.json
β”‚   └── README.md
β”œβ”€β”€ web/                    # React.js web application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/     # Shared web components
β”‚   β”‚   β”œβ”€β”€ pages/          # Web pages
β”‚   β”‚   β”‚   β”œβ”€β”€ RegisterPage.js
β”‚   β”‚   β”‚   β”œβ”€β”€ OTPVerificationPage.js
β”‚   β”‚   β”‚   β”œβ”€β”€ ApprovalPendingPage.js
β”‚   β”‚   β”‚   └── AdminDashboard.js
β”‚   β”‚   β”œβ”€β”€ hooks/          # Custom hooks
β”‚   β”‚   └── utils/          # Web utilities
β”‚   β”œβ”€β”€ package.json
β”‚   └── README.md
β”œβ”€β”€ backend/                # Node.js/Express API server
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ models/         # Database models
β”‚   β”‚   β”‚   β”œβ”€β”€ User.js     # User schema with verification & approval
β”‚   β”‚   β”‚   └── OTP.js      # OTP management schema
β”‚   β”‚   β”œβ”€β”€ routes/         # API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.js     # Authentication endpoints
β”‚   β”‚   β”‚   └── admin.js    # Admin management endpoints
β”‚   β”‚   β”œβ”€β”€ middleware/     # Custom middleware
β”‚   β”‚   β”‚   └── auth.js     # JWT & role-based authorization
β”‚   β”‚   β”œβ”€β”€ services/       # Business logic services
β”‚   β”‚   β”‚   β”œβ”€β”€ authService.js    # Registration, OTP, login logic
β”‚   β”‚   β”‚   β”œβ”€β”€ emailService.js   # Email notifications
β”‚   β”‚   β”‚   β”œβ”€β”€ smsService.js     # SMS notifications
β”‚   β”‚   β”‚   └── adminService.js   # User management
β”‚   β”‚   └── utils/          # Backend utilities
β”‚   β”œβ”€β”€ package.json
β”‚   └── README.md
β”œβ”€β”€ shared/                 # Shared code and utilities
β”‚   β”œβ”€β”€ components/         # Cross-platform components
β”‚   β”œβ”€β”€ types/              # TypeScript definitions
β”‚   β”œβ”€β”€ utils/              # Shared utilities
β”‚   └── validations/        # Validation schemas
└── docs/                   # Documentation
    β”œβ”€β”€ api/                # API documentation
    β”œβ”€β”€ deployment/         # Deployment guides
    └── architecture/       # Architecture diagrams

✨ Features

Core Features

  • πŸ“± Cross-Platform: Native mobile apps + responsive web
  • πŸ” Authentication: Email/phone registration with OTP verification and admin approval
  • πŸ“š Book Management: Barcode scanning for easy book publishing
  • πŸ” Discovery: Search and filter books by location, genre, availability
  • πŸ’³ Digital Wallet: Manage balance, payments, and automated fines
  • πŸ‘¨β€πŸ’Ό Admin Dashboard: User management, book approvals, transaction oversight

Registration & Verification Flow

  1. Multi-step Registration: Personal, family/community, and security information
  2. Dual Verification: Email and SMS OTP verification with resend capability
  3. Admin Approval Process: Manual review by administrators before account activation
  4. Status Tracking: Real-time progress indication for users

User Management Features

  • Role-based Access: Publisher, Borrower, Administrator personas
  • Account States: Pending, Approved, Rejected, Blocked status management
  • Admin Dashboard: Comprehensive user approval and management interface
  • Notification System: Email and SMS notifications for status changes

Technical Features

  • πŸ”„ Real-time Updates: Socket.io for live notifications
  • πŸ“Š Analytics: User engagement and book popularity tracking
  • πŸ”’ Security: JWT authentication, data encryption, input validation
  • πŸ’° Payments: Stripe integration for wallet transactions
  • πŸ“§ Notifications: Email and SMS via Nodemailer/Twilio
  • πŸ“± PWA Support: Offline capabilities for web app

πŸ” Authentication Flow

User Registration Process

sequenceDiagram
    participant U as User
    participant App as Mobile/Web App
    participant API as Backend API
    participant DB as Database
    participant Email as Email Service
    participant SMS as SMS Service
    participant Admin as Administrator

    U->>App: Fill registration form
    App->>API: POST /api/auth/register
    API->>DB: Create user (pending verification)
    API->>Email: Send OTP via email
    API->>SMS: Send OTP via SMS
    API->>App: Registration successful
    
    U->>App: Enter OTP
    App->>API: POST /api/auth/verify-otp
    API->>DB: Update user (verified, pending approval)
    API->>App: Verification successful
    
    Admin->>API: Review pending users
    Admin->>API: Approve/Reject user
    API->>DB: Update user status
    API->>Email: Send approval/rejection notification
    API->>SMS: Send approval/rejection notification
Loading

Admin Approval Dashboard

  • Pending Users: List of users awaiting approval with detailed information
  • User Management: Approve, reject, block, or unblock users
  • Dashboard Statistics: Total users, pending approvals, registration trends
  • Batch Operations: Manage multiple users simultaneously

πŸ“± Mobile App Features

Registration Screens

  • Step 1: Personal Information (name, email, phone)
  • Step 2: Family & Community (parent name, community)
  • Step 3: Security & Role (password, persona selection)

OTP Verification

  • Dual Method: Email and SMS verification options
  • Auto-resend: Automatic OTP resend with countdown timer
  • Method Switching: Toggle between email and SMS verification
  • Input Validation: Real-time OTP format validation

Approval Status

  • Progress Tracking: Visual indication of registration progress
  • Timeline: Expected approval timeline with status updates
  • Support Access: Direct contact to support team

🌐 Web Application Features

Admin Dashboard

  • User Overview: Comprehensive user statistics and metrics
  • Pending Approvals: Table view of users awaiting approval
  • User Details: Detailed user information modal
  • Action Management: Approve, reject, block operations with confirmation
  • Search & Filter: Find users by status, role, registration date

Registration Flow

  • Responsive Design: Mobile-first design for all screen sizes
  • Form Validation: Real-time validation with clear error messages
  • Multi-step Process: Clean step-by-step registration flow
  • Accessibility: WCAG compliant with keyboard navigation

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • MongoDB (local or cloud)
  • Expo CLI for mobile development
  • Git

Installation

  1. Clone the repository

    git clone <repository-url>
    cd community-library
  2. Install dependencies

    npm run install:all
  3. Set up environment variables

    # Backend
    cp backend/.env.example backend/.env
    # Edit backend/.env with your configuration
    
    # Web
    cp web/.env.example web/.env
    # Edit web/.env with your configuration
  4. Start development servers

    # Terminal 1 - Backend API
    npm run dev:backend
    
    # Terminal 2 - Web App
    npm run dev:web
    
    # Terminal 3 - Mobile App
    npm run dev:mobile

Development URLs

πŸ“± Mobile Development

The mobile app uses Expo for cross-platform development:

cd mobile
npx expo start

# Run on specific platforms
npx expo start --android
npx expo start --ios

🌐 Web Development

The web app is a React.js application with Material-UI:

cd web
npm start

πŸ”§ Backend Development

The backend is a Node.js/Express API with MongoDB:

cd backend
npm run dev

πŸ“ Project Structure

Backend (/backend)

backend/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ controllers/     # Request handlers
β”‚   β”œβ”€β”€ models/         # Database models
β”‚   β”œβ”€β”€ routes/         # API routes
β”‚   β”œβ”€β”€ middleware/     # Custom middleware
β”‚   β”œβ”€β”€ services/       # Business logic
β”‚   β”œβ”€β”€ utils/          # Helper functions
β”‚   └── server.js       # App entry point
β”œβ”€β”€ tests/              # Test files
└── uploads/            # File uploads

Web App (/web)

web/
β”œβ”€β”€ public/             # Static assets
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/     # Reusable components
β”‚   β”œβ”€β”€ pages/          # Page components
β”‚   β”œβ”€β”€ hooks/          # Custom React hooks
β”‚   β”œβ”€β”€ services/       # API services
β”‚   β”œβ”€β”€ contexts/       # React contexts
β”‚   β”œβ”€β”€ utils/          # Helper functions
β”‚   └── App.js          # App entry point
└── build/              # Production build

Mobile App (/mobile)

mobile/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/     # Reusable components
β”‚   β”œβ”€β”€ screens/        # Screen components
β”‚   β”œβ”€β”€ navigation/     # Navigation config
β”‚   β”œβ”€β”€ services/       # API services
β”‚   β”œβ”€β”€ hooks/          # Custom hooks
β”‚   β”œβ”€β”€ contexts/       # React contexts
β”‚   └── utils/          # Helper functions
β”œβ”€β”€ assets/             # Images, fonts, etc.
└── App.js              # App entry point

Shared (/shared)

shared/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ validation/     # Validation schemas
β”‚   β”œβ”€β”€ utils/          # Common utilities
β”‚   β”œβ”€β”€ constants/      # App constants
β”‚   └── types/          # TypeScript types
└── index.js            # Exports

πŸ” Environment Variables

Backend (.env)

MONGODB_URI=mongodb://localhost:27017/community-library
JWT_SECRET=your-jwt-secret
STRIPE_SECRET_KEY=sk_test_...
TWILIO_AUTH_TOKEN=your-twilio-token
EMAIL_PASS=your-email-password

Web (.env)

REACT_APP_API_URL=http://localhost:5000/api
REACT_APP_STRIPE_PUBLISHABLE_KEY=pk_test_...

πŸ§ͺ Testing

# Run all tests
npm test

# Run tests for specific workspace
npm run test --workspace=backend
npm run test --workspace=web
npm run test --workspace=mobile

πŸš€ Deployment

Backend (Node.js)

  • Deploy to Heroku, Railway, or similar
  • Set environment variables
  • Configure MongoDB Atlas

Web App

  • Build: npm run build:web
  • Deploy to Vercel, Netlify, or similar
  • Configure environment variables

Mobile App

  • Build: npx expo build:android / npx expo build:ios
  • Deploy to Google Play Store / Apple App Store

πŸ“š API Documentation

Authentication Endpoints

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • POST /api/auth/verify-otp - OTP verification
  • POST /api/auth/refresh - Refresh token

Book Endpoints

  • GET /api/books - List books
  • POST /api/books - Create book
  • PUT /api/books/:id - Update book
  • DELETE /api/books/:id - Delete book

User Endpoints

  • GET /api/users/profile - Get user profile
  • PUT /api/users/profile - Update profile
  • GET /api/users/wallet - Get wallet balance

Transaction Endpoints

  • POST /api/transactions/borrow - Borrow book
  • POST /api/transactions/return - Return book
  • GET /api/transactions/history - Transaction history

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Support

For questions or support, please open an issue on GitHub or contact the development team.


Community Library Team πŸ“š

About

Community Library App - React web app for research participants

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published