A comprehensive Laravel-based REST API platform for geospatial services and freelance management, featuring JWT authentication, role-based access control, timesheet management, and modern development tools.
- Quick Start
- Prerequisites
- Installation
- Test Credentials
- Running the Project
- API Testing
- Debugging
- Key Features
- Project Structure
- Authentication
- Available Endpoints
- Database
- Troubleshooting
Get up and running in minutes:
# Clone and navigate to project
cd geospace_laravel
# Install dependencies
composer install && npm install
# Setup environment
cp .env.example .env
php artisan key:generate
php artisan jwt:secret
# Setup database
php artisan migrate --seed
# Start development server
composer run devAccess the API at: http://localhost:8000/api/v1
Use these credentials to test the API immediately after setup:
| Role | Password | Role ID | Description | |
|---|---|---|---|---|
| Admin | admin@geospace.com | password123 | 1 | Full system access | 
| Freelancer | freelancer@geospace.com | password123 | 2 | Contractor/service provider | 
| Company | company@geospace.com | password123 | 3 | Hiring organization | 
| Support | support@geospace.com | password123 | 4 | Customer support agent | 
curl -X POST "http://localhost:8000/api/v1/Login" \
  -H "Content-Type: application/json" \
  -d '{
    "Email": "admin@geospace.com",
    "Password": "password123"
  }'Response:
{
  "Token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
  "UserDetails": {
    "UserId": 1,
    "UserName": "admin@geospace.com",
    "Email": "admin@geospace.com",
    "RoleId": 1,
    "RoleName": "Admin"
  }
}Ensure you have the following installed:
- PHP 8.2+ with extensions:
- OpenSSL
- PDO
- Mbstring
- Tokenizer
- XML
- Ctype
- JSON
- BCMath
- Fileinfo
 
- Composer 2.x+
- Node.js 18+ & NPM
- SQLite (default) or MySQL/PostgreSQL
php -v                    # Should be 8.2 or higher
composer -v               # Should be 2.x
node -v                   # Should be 18.x or higher
npm -v                    # Should be 9.x or highergit clone <repository-url>
cd geospace_laravel# Install PHP dependencies
composer install
# Install Node.js dependencies
npm install# Copy environment file
cp .env.example .env
# Generate application key
php artisan key:generate
# Generate JWT secret
php artisan jwt:secretThe project uses SQLite by default. For MySQL/PostgreSQL, update .env:
SQLite (Default):
DB_CONNECTION=sqlite
DB_DATABASE=/absolute/path/to/database/database.sqliteMySQL:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=geospace_db
DB_USERNAME=your_username
DB_PASSWORD=your_passwordRun Migrations and Seeders:
# Create database tables and seed with test data
php artisan migrate --seed
# Or run separately
php artisan migrate
php artisan db:seed# Linux/Mac
chmod -R 755 storage bootstrap/cache
# Or if needed
sudo chown -R www-data:www-data storage bootstrap/cacheStart all services with one command:
composer run devThis runs:
- Laravel server (http://localhost:8000)
- Queue worker (background jobs)
- Laravel Pail (real-time logs)
- Vite dev server (frontend assets)
Run services separately if needed:
# Laravel API server
php artisan serve
# Access at: http://localhost:8000
# Queue worker (for background jobs)
php artisan queue:work
# Real-time log monitoring
php artisan pail
# Frontend asset compilation
npm run dev
# Build assets for production
npm run build# Optimize for production
composer install --optimize-autoloader --no-dev
php artisan config:cache
php artisan route:cache
php artisan view:cache
npm run build
# Run with queue worker
php artisan queue:work --daemonhttp://localhost:8000/api/v1
Login Request:
curl -X POST "http://localhost:8000/api/v1/Login" \
  -H "Content-Type: application/json" \
  -d '{
    "Email": "admin@geospace.com",
    "Password": "password123"
  }'Save the Token from Response:
{
  "Token": "eyJ0eXAiOiJKV1QiLCJhbGc...",
  "UserDetails": { ... }
}Get Current User Profile:
curl -X GET "http://localhost:8000/api/v1/me" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"Get Notifications:
curl -X GET "http://localhost:8000/api/v1/Notifications" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"Get Dropdown Data:
curl -X GET "http://localhost:8000/api/v1/DropdownDataByCategory?Category=Skills" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"- 
Import Environment: - Base URL: http://localhost:8000/api/v1
- Set variable: tokenwith your JWT token
 
- Base URL: 
- 
Set Headers for Protected Routes: - Authorization: Bearer {{token}}
- Content-Type: application/json
- Accept: application/json
 
- 
Test Login → Save Token → Test Protected Routes 
Laravel Pail provides beautiful real-time log monitoring:
# Monitor all logs
php artisan pail
# Filter by level
php artisan pail --filter="error"
php artisan pail --filter="info"
# Filter by content
php artisan pail --filter="api"
php artisan pail --filter="database"Edit .env file:
APP_DEBUG=true
LOG_LEVEL=debugAPP_DEBUG=true in production!
# Clear all caches
php artisan optimize:clear
# List all routes
php artisan route:list
# List all API routes only
php artisan route:list --path=api
# Show current configuration
php artisan config:show
# Monitor log file directly
tail -f storage/logs/laravel.log
# Clear specific caches
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear# Check migration status
php artisan migrate:status
# Rollback migrations
php artisan migrate:rollback
# Fresh migration with seed
php artisan migrate:fresh --seed
# Interactive shell
php artisan tinkerTinker Examples:
# Test database connection
>>> DB::connection()->getPdo();
# Check users
>>> App\Models\User::count();
# Find user by email
>>> App\Models\User::where('email', 'admin@geospace.com')->first();
# Enable query logging
>>> DB::enableQueryLog();
>>> App\Models\User::all();
>>> DB::getQueryLog();# Regenerate JWT secret
php artisan jwt:secret --force
# Check JWT configuration
php artisan config:show jwt
# Test token in tinker
php artisan tinker
>>> $user = App\Models\User::first();
>>> $token = auth()->login($user);
>>> echo $token;Add to your .env for detailed API logging:
LOG_CHANNEL=stack
LOG_LEVEL=debugCheck logs at: storage/logs/laravel.log
| Issue | Solution | 
|---|---|
| CORS Errors | Check config/cors.phpconfiguration | 
| Token Expired | Login again or implement token refresh | 
| Database Locked | Check SQLite file permissions: chmod 644 database/database.sqlite | 
| Route Not Found | Run php artisan route:cache | 
| 500 Internal Error | Check storage/logs/laravel.log | 
| Unauthorized 401 | Verify token is valid and not expired | 
- ✅ JWT Authentication - Secure token-based authentication
- ✅ Role-Based Access Control - 5 different user roles
- ✅ Real-time Logging - Laravel Pail for beautiful logs
- ✅ Modern Frontend - Vite + TailwindCSS integration
- ✅ Comprehensive API - 25+ RESTful endpoints
- ✅ SQLite Database - Easy development setup
- ✅ Queue System - Background job processing
- ✅ Timesheet Management - Track work hours and approvals
- ✅ Notification System - Real-time user notifications
- ✅ Activity Logging - Audit trail for all actions
- ✅ Payment Tracking - Integrated payment management
geospace_laravel/
├── app/
│   ├── Http/
│   │   ├── Controllers/        # API Controllers
│   │   │   ├── CommonController.php
│   │   │   ├── CompanyController.php
│   │   │   ├── AdminController.php
│   │   │   └── TimesheetController.php
│   │   ├── Middleware/         # Custom middleware
│   │   └── Requests/           # Form requests
│   ├── Models/                 # Eloquent models
│   │   ├── User.php
│   │   ├── Project.php
│   │   ├── Timesheet.php
│   │   └── ...
│   ├── Helpers/                # Helper classes
│   │   ├── MessageHelper.php
│   │   └── AesEncryptionHelper.php
│   └── Providers/              # Service providers
│
├── bootstrap/
│   └── cache/                  # Bootstrap cache
│
├── config/                     # Configuration files
│   ├── auth.php
│   ├── database.php
│   ├── jwt.php
│   └── cors.php
│
├── database/
│   ├── migrations/             # Database migrations
│   ├── seeders/                # Database seeders
│   └── database.sqlite         # SQLite database file
│
├── public/                     # Public assets
│   └── index.php               # Entry point
│
├── resources/
│   ├── views/                  # Blade templates
│   ├── js/                     # JavaScript files
│   └── css/                    # CSS files
│
├── routes/
│   ├── api.php                 # API routes
│   ├── web.php                 # Web routes
│   └── channels.php            # Broadcast channels
│
├── storage/
│   ├── app/                    # Application files
│   ├── framework/              # Framework files
│   └── logs/                   # Log files
│
├── tests/                      # PHPUnit tests
│
├── .env.example                # Environment template
├── composer.json               # PHP dependencies
├── package.json                # Node dependencies
├── README.md                   # This file
└── API_DOCUMENTATION.md        # API documentation
- Token Type: JSON Web Token (JWT)
- Expiry: 60 minutes (configurable)
- Refresh Token: 2 weeks
- Algorithm: HS256
- Login → Receive JWT token
- Include Token in Authorization header for protected routes
- Token Expires → Login again or refresh token
- Logout → Invalidates current token
Header Format:
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGc...
Protected Route Example:
curl -X GET "http://localhost:8000/api/v1/me" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"| Role ID | Role Name | Description | 
|---|---|---|
| 1 | Admin | System administrator - full access | 
| 2 | Freelancer | Independent contractor providing services | 
| 3 | Company | Organization hiring freelancers | 
| 4 | Support | Customer support agent | 
| 5 | Visitor | Unauthenticated user | 
| Method | Endpoint | Description | 
|---|---|---|
| POST | /Login | User authentication | 
| POST | /SignUpFreelancer | Register new freelancer | 
| POST | /SignUpFreelancerDetails | Add freelancer details | 
| POST | /SignUpCompanyDetails | Add company information | 
| POST | /LogVisitor | Log visitor activity | 
| GET | /api/auth/linkedin/callback/signup | LinkedIn OAuth | 
| Method | Endpoint | Description | 
|---|---|---|
| GET | /me | Get current user profile | 
| POST | /logout | Logout and invalidate token | 
| GET | /GetMenusByRoleId?RoleId={id} | Get menu items by role | 
| GET | /Notifications | Get user notifications | 
| POST | /UpdateNotification | Mark notification as read | 
| GET | /DropdownDataByCategory?Category={name} | Get dropdown options | 
| Method | Endpoint | Description | 
|---|---|---|
| GET | /company/CurrentProjectList | List active projects | 
| GET | /company/ActiveFreelancerList | List active freelancers | 
| GET | /company/CompanyPendingTimesheetList | Pending timesheets | 
| GET | /company/NotificationList | Company notifications | 
| GET | /company/DashboardStats | Dashboard statistics | 
| Method | Endpoint | Description | 
|---|---|---|
| GET | /admin/VerifiedUserList | List verified users | 
| GET | /admin/PendingVerificationList | Users pending verification | 
| GET | /admin/SuspendedAccountsList | Suspended accounts | 
| GET | /admin/GetUserDetails?UserId={id} | Get user details | 
| POST | /admin/UpdateUserStatus | Activate/deactivate user | 
| POST | /admin/VerifyUser | Verify user account | 
| Method | Endpoint | Description | 
|---|---|---|
| GET | /admin/timesheets | List all timesheets | 
| GET | /admin/timesheets/{id} | Get timesheet details | 
| POST | /admin/timesheets | Create new timesheet | 
| PUT | /admin/timesheets/{id} | Update timesheet | 
| DELETE | /admin/timesheets/{id} | Delete timesheet | 
| POST | /admin/timesheets/{id}/approve | Approve timesheet | 
| POST | /admin/timesheets/{id}/reject | Reject timesheet | 
| GET | /admin/timesheets/pending | Get pending timesheets | 
See API_DOCUMENTATION.md for detailed endpoint documentation with request/response examples.
The project uses SQLite for easy development:
DB_CONNECTION=sqlite
DB_DATABASE=/full/path/to/database/database.sqliteUpdate .env for production databases:
MySQL:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=geospace_db
DB_USERNAME=root
DB_PASSWORD=your_passwordPostgreSQL:
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=geospace_db
DB_USERNAME=postgres
DB_PASSWORD=your_passwordKey tables include:
- users- User accounts
- user_details- User profile information
- company_details- Company information
- projects- Project listings
- timesheets- Work hour tracking
- contracts- Freelancer contracts
- payments- Payment records
- notifications- User notifications
- activity_logs- Audit trail
After running php artisan db:seed, you'll have:
- 4 test user accounts (Admin, Freelancer, Company, Support)
- Sample projects
- Dropdown categories and values
- User roles and permissions
- Sample notifications
1. Missing Application Key
php artisan key:generate2. Missing JWT Secret
php artisan jwt:secret3. Composer Install Fails
composer install --ignore-platform-reqs
# Or update PHP to 8.2+4. NPM Install Fails
rm -rf node_modules package-lock.json
npm install1. Database Connection Error
# Check database file exists
ls -la database/database.sqlite
# Create if missing
touch database/database.sqlite
# Set permissions
chmod 664 database/database.sqlite2. Permission Denied Errors
chmod -R 755 storage bootstrap/cache
sudo chown -R $USER:$USER storage bootstrap/cache3. Route Not Found (404)
php artisan route:clear
php artisan config:clear
php artisan cache:clear
php artisan optimize:clear4. Token Invalid/Expired (401)
- Login again to get new token
- Check token is included in Authorization header
- Verify JWT secret is set: php artisan config:show jwt
5. Internal Server Error (500)
# Check logs
tail -50 storage/logs/laravel.log
# Enable debug mode temporarily
# Set APP_DEBUG=true in .env6. CORS Issues
- Check config/cors.phpsettings
- Ensure frontend origin is in allowed_origins
- Check headers are properly set
7. Database Migration Fails
# Reset database
php artisan migrate:fresh --seed
# Or rollback and re-run
php artisan migrate:rollback
php artisan migrate1. Slow Response Times
# Cache configuration
php artisan config:cache
php artisan route:cache
php artisan view:cache
# Optimize autoloader
composer dump-autoload --optimize2. Queue Jobs Not Processing
# Check queue configuration
php artisan queue:work --queue=default --tries=3
# Restart queue worker
php artisan queue:restart- Check Logs: storage/logs/laravel.log
- Monitor Real-time: php artisan pail
- Review Docs: See API_DOCUMENTATION.md
- Check Routes: php artisan route:list
- Test in Tinker: php artisan tinker
After successful installation:
- ✅ Test the login endpoint with provided credentials
- ✅ Explore the API documentation in API_DOCUMENTATION.md
- ✅ Review the database structure
- ✅ Set up your frontend to connect to the API
- ✅ Configure environment variables for your needs
- ✅ Set up proper database (MySQL/PostgreSQL) for production
- Laravel Documentation: https://laravel.com/docs
- JWT Auth Package: https://jwt-auth.readthedocs.io
- API Best Practices: RESTful conventions followed
- Postman Collection: (Add your collection URL here)
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
[Your License Here]
Happy Coding! 🚀
For detailed API endpoint documentation with request/response examples, see API_DOCUMENTATION.md