Skip to content

nancy325/SCHOLARSHIP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

51 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Scholarship Management System - Backend API

A comprehensive REST API built with Laravel 11 for managing scholarship applications, submissions, and user profiles.

πŸš€ Features

Authentication & Authorization

  • User registration with strong password validation
  • Secure login with Laravel Sanctum tokens
  • Role-based access control (Student, Institute Admin, University Admin, Admin, Super Admin)
  • Token-based API authentication

Scholarship Management

  • CRUD operations for scholarships
  • Role-based scholarship visibility
  • Advanced filtering (type, university, institute, search)
  • Pagination support
  • Multiple scholarship types (Government, Private, University, Institute)

Application System

  • Submit scholarship applications
  • Track application status (Pending, Under Review, Approved, Rejected)
  • Document upload support
  • GPA and personal statement tracking
  • Admin review and status management

Profile Management

  • Comprehensive user profiles
  • Education details
  • Personal information
  • Career goals

πŸ—οΈ Architecture

Service-Based Pattern

Controller β†’ Service β†’ Model β†’ Database
     ↑          ↑
Form Request   Response
Validation     Resource

Key Components

  • Controllers: Handle HTTP requests/responses
  • Services: Contain business logic and data operations
  • Form Requests: Validate incoming data
  • Resources: Transform models to consistent JSON
  • Middleware: Authentication and authorization

πŸ“‹ Requirements

  • PHP 8.2 or higher
  • Composer
  • MySQL 5.7+ or SQLite
  • Laravel 11.x

βš™οΈ Installation

1. Install Dependencies

cd backend
composer install

2. Environment Setup

cp .env.example .env
php artisan key:generate

3. Database Configuration

Update .env:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=scholarship_db
DB_USERNAME=your_username
DB_PASSWORD=your_password

4. Run Migrations

php artisan migrate

5. Seed Database (Optional)

php artisan db:seed

6. Start Server

php artisan serve

API available at: http://localhost:8000/api

πŸ“š API Documentation

Quick Reference

Authentication Endpoints

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • POST /api/auth/logout - Logout (auth required)
  • GET /api/auth/me - Get current user (auth required)

Scholarship Endpoints

  • GET /api/scholarships - List scholarships (public)
  • GET /api/scholarships/{id} - Get scholarship details (public)
  • POST /api/scholarships - Create scholarship (admin only)
  • PUT /api/scholarships/{id} - Update scholarship (admin only)
  • DELETE /api/scholarships/{id} - Delete scholarship (admin only)

Application Endpoints

  • GET /api/applications - List applications (auth)
  • GET /api/applications/my-applications - My applications (auth)
  • GET /api/applications/{id} - Get application (auth)
  • POST /api/applications - Submit application (auth)
  • PUT /api/applications/{id} - Update application (auth)
  • DELETE /api/applications/{id} - Delete application (auth)

Profile Endpoints

  • GET /api/profile - Get profile (auth)
  • PUT /api/profile - Update profile (auth)

Detailed Documentation

πŸ” Authentication

All protected endpoints require a Bearer token:

Authorization: Bearer {your-token}

Getting a Token

Register:

curl -X POST http://localhost:8000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "john@example.com",
    "password": "SecurePass123!",
    "password_confirmation": "SecurePass123!",
    "category": "undergraduate"
  }'

Login:

curl -X POST http://localhost:8000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "john@example.com",
    "password": "SecurePass123!"
  }'

πŸ‘₯ User Roles

Role Permissions
Student View scholarships, submit applications, manage own profile
Institute Admin Manage institute scholarships, review institute applications
University Admin Manage university scholarships, review university applications
Admin Manage all scholarships and applications
Super Admin Complete system access

πŸ§ͺ Testing

Using Postman

Import the collection from postman/ScholarSnap_API.json

Unit Tests

php artisan test

Feature Tests

php artisan test --filter=AuthenticationTest
php artisan test --filter=ScholarshipTest

πŸ“ Project Structure

backend/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ Http/
β”‚   β”‚   β”œβ”€β”€ Controllers/Api/
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthController.php
β”‚   β”‚   β”‚   β”œβ”€β”€ ScholarshipController.php
β”‚   β”‚   β”‚   β”œβ”€β”€ ApplicationController.php
β”‚   β”‚   β”‚   └── ProfileController.php
β”‚   β”‚   β”œβ”€β”€ Requests/
β”‚   β”‚   β”‚   β”œβ”€β”€ LoginRequest.php
β”‚   β”‚   β”‚   β”œβ”€β”€ RegisterRequest.php
β”‚   β”‚   β”‚   β”œβ”€β”€ StoreScholarshipRequest.php
β”‚   β”‚   β”‚   β”œβ”€β”€ UpdateScholarshipRequest.php
β”‚   β”‚   β”‚   β”œβ”€β”€ StoreApplicationRequest.php
β”‚   β”‚   β”‚   └── UpdateApplicationRequest.php
β”‚   β”‚   └── Resources/
β”‚   β”‚       β”œβ”€β”€ UserResource.php
β”‚   β”‚       β”œβ”€β”€ ScholarshipResource.php
β”‚   β”‚       └── ApplicationResource.php
β”‚   β”œβ”€β”€ Services/
β”‚   β”‚   β”œβ”€β”€ AuthService.php
β”‚   β”‚   β”œβ”€β”€ ScholarshipService.php
β”‚   β”‚   └── ApplicationService.php
β”‚   └── Models/
β”‚       β”œβ”€β”€ User.php
β”‚       β”œβ”€β”€ Scholarship.php
β”‚       β”œβ”€β”€ Application.php
β”‚       β”œβ”€β”€ University.php
β”‚       └── Institute.php
β”œβ”€β”€ routes/
β”‚   └── api.php
β”œβ”€β”€ database/
β”‚   └── migrations/
└── Documentation/
    β”œβ”€β”€ API_DOCUMENTATION.md
    β”œβ”€β”€ QUICK_START.md
    └── REFACTORING_SUMMARY.md

πŸ”’ Security Features

  • βœ… Password hashing with bcrypt
  • βœ… Strong password requirements
  • βœ… Compromised password checking
  • βœ… Token-based authentication (Laravel Sanctum)
  • βœ… Role-based authorization
  • βœ… Input validation with Form Requests
  • βœ… SQL injection protection (Eloquent ORM)
  • βœ… XSS protection
  • βœ… CORS configuration

πŸ› οΈ Development

Clear Cache

php artisan cache:clear
php artisan config:clear
php artisan route:clear

View Routes

php artisan route:list

Generate API Token (Testing)

php artisan tinker
$user = User::find(1);
$token = $user->createToken('test-token')->plainTextToken;
echo $token;

Check Logs

tail -f storage/logs/laravel.log

πŸ“Š Database Schema

Main Tables

  • users - User accounts and authentication
  • scholarships - Scholarship opportunities
  • applications - Student applications
  • universities - University information
  • institutes - Institute/College information

Relationships

University β†’ hasMany β†’ Institutes
University β†’ hasMany β†’ Scholarships
Institute β†’ hasMany β†’ Scholarships
User β†’ hasMany β†’ Applications
Scholarship β†’ hasMany β†’ Applications

🚧 Troubleshooting

Common Issues

401 Unauthorized

  • Check if token is included in Authorization header
  • Verify token is valid and not expired

422 Validation Error

  • Check request body matches validation rules
  • Review error messages for specific field issues

403 Forbidden

  • Verify user role has permission for the action
  • Check role-based middleware configuration

500 Server Error

  • Check storage/logs/laravel.log for details
  • Verify database connection
  • Ensure all required environment variables are set

CORS Issues

Update config/cors.php to allow your frontend origin:

'allowed_origins' => ['http://localhost:5173'],

πŸ“ Contributing

  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

πŸ“„ License

This project is licensed under the MIT License.

πŸ“ž Support

For detailed documentation:

🎯 Roadmap

Completed βœ…

  • Authentication system
  • Scholarship CRUD operations
  • Application submission
  • Role-based access control
  • Profile management

Planned πŸ”„

  • File upload for documents
  • Email notifications
  • Admin dashboard analytics
  • Advanced search filters
  • Export to PDF
  • Real-time notifications
  • Multi-language support

Built with ❀️ using Laravel 11

Version: 1.0.0
Last Updated: October 11, 2025

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •