Skip to content

R-Sruthi/Parking_Management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parking Management System

A comprehensive parking management system built with Flask backend and VueJS frontend, featuring multi-user support, real-time parking spot management, and automated notifications.

Features

Core Functionality

  • Multi-user System: Admin and regular user roles with different permissions
  • Parking Lot Management: Create, edit, and manage parking lots with configurable spots
  • Real-time Booking: Book and release parking spots with automatic allocation
  • Cost Calculation: Automatic pricing based on parking duration
  • Dashboard Analytics: Comprehensive statistics and reporting

Advanced Features

  • API Documentation: Interactive Swagger UI for complete API exploration
  • JWT Authentication: Secure token-based authentication system
  • SQLite Database: Lightweight, file-based database with auto-creation
  • Modular Architecture: Clean separation of concerns with Flask application factory pattern

Disabled Features (For Simplified Setup)

  • Daily reminder emails
  • Monthly activity reports
  • CSV export functionality
  • Background job processing (Celery/Redis)

Technology Stack

Backend

  • Flask: Web framework for API development
  • SQLAlchemy: ORM for database operations
  • SQLite: Database for data persistence
  • JWT: Token-based authentication
  • Flask-RESTX: API documentation and validation

Frontend

  • VueJS 3: Progressive JavaScript framework
  • Vue Router: Client-side routing
  • Vuex: State management
  • Bootstrap 5: UI framework and styling
  • Axios: HTTP client for API communication

Installation and Setup

Prerequisites

Before starting, ensure you have:

  • Python 3.8+ installed
  • Node.js 14+ installed
  • Git (to clone the repository)

Check Prerequisites

# Check Python version
python3 --version
# Should show Python 3.8 or higher

# Check Node.js version
node --version
# Should show Node.js 14 or higher

# Check npm version
npm --version

Step-by-Step Setup

Step 1: Navigate to Project Directory

cd /path/to/your/Parking_Mad2

Replace /path/to/your/Parking_Mad2 with the actual path to your project directory.

Step 2: Backend Setup

2.1 Create Python Virtual Environment

cd backend
python3 -m venv venv

2.2 Activate Virtual Environment

# On macOS/Linux
source venv/bin/activate

# On Windows
# venv\Scripts\activate

You should see (venv) in your terminal prompt.

2.3 Install Python Dependencies

pip install --upgrade pip
pip install -r requirements.txt

Expected output: All Flask dependencies will be installed (Celery/Redis dependencies are commented out).

2.4 Create Environment Variables File

# Create .env file with default values
cat > .env << 'EOF'
# ===========================================
# PARKING MANAGEMENT SYSTEM - ENVIRONMENT VARIABLES
# ===========================================

# Flask Environment (development, production, testing)
FLASK_ENV=development

# ===========================================
# SECURITY CONFIGURATION (REQUIRED)
# ===========================================
# Change these to secure random strings in production!
SECRET_KEY=2a53d4c08552f639aa232dfaaf09aec805c0dc2a2b520a780e2acec5c3f1b16f
JWT_SECRET_KEY=eda2e2f03960eeb4b115f56ca58eeac7e6616e9b1cab8aa6d6689dc4a069c051

# ===========================================
# DATABASE CONFIGURATION (REQUIRED)
# ===========================================
# SQLite database file path (will be created automatically)
DATABASE_URL=sqlite:///parking_management.db

# ===========================================
# REDIS CONFIGURATION (DISABLED)
# ===========================================
# Redis server for caching and background jobs - DISABLED FOR NOW
# REDIS_URL=redis://localhost:6379/0
# CELERY_BROKER_URL=redis://localhost:6379/0
# CELERY_RESULT_BACKEND=redis://localhost:6379/0

# ===========================================
# ADMIN CREDENTIALS (REQUIRED)
# ===========================================
# Default admin user credentials
ADMIN_USERNAME=admin
[email protected]
ADMIN_PASSWORD=admin123

# ===========================================
# EMAIL CONFIGURATION (DISABLED)
# ===========================================
# For sending notifications and reports - DISABLED FOR NOW
# MAIL_SERVER=smtp.gmail.com
# MAIL_PORT=587
# MAIL_USE_TLS=True
# [email protected]
# MAIL_PASSWORD=your-app-password


EOF

2.5 Test Backend Setup

# Test if the application can be created
python3 -c "from application import create_app; app = create_app('development'); print('✅ Backend setup successful!')"

Expected output: ✅ Backend setup successful!

Step 3: Frontend Setup

3.1 Navigate to Frontend Directory

cd ../frontend

3.2 Install Node.js Dependencies

npm install

Expected output: All Vue.js dependencies will be installed.

3.3 Test Frontend Setup

# Test if Vue CLI is working
npm run serve --help

Running the Application

Start Backend (Terminal 1)

cd backend
source venv/bin/activate
python3 main.py

Expected output:

 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:5001
 * Running on http://[::1]:5001
 * Debug mode: on
Admin user created with username: admin, password: admin123

Start Frontend (Terminal 2)

cd frontend
npm run serve

Expected output:

  App running at:
  - Local:   http://localhost:8080/
  - Network: http://192.168.x.x:8080/

Access the Application

Frontend (User Interface)

Backend API

Default Credentials

Admin Account

User Account

  • Create a new user account through the registration form on the frontend

Application Features

✅ Working Features

  1. Authentication System

    • User registration and login
    • Admin login
    • JWT token-based authentication
  2. Admin Dashboard

    • Create parking lots
    • Edit/delete parking lots
    • View all users
    • View parking statistics
  3. User Dashboard

    • View available parking lots
    • Book parking spots
    • Release parking spots
    • View booking history
  4. Parking Management

    • Real-time spot availability
    • Automatic spot allocation
    • Cost calculation
    • Booking history
  5. API Documentation

    • Interactive Swagger UI
    • Complete endpoint documentation
    • Request/response examples
    • Try-it-out functionality

Database Information

  • Type: SQLite
  • File: backend/parking_management.db
  • Auto-created: Yes, on first run
  • Admin user: Auto-created with default credentials

Troubleshooting

Backend Issues

"ModuleNotFoundError: No module named 'flask'"

cd backend
source venv/bin/activate
pip install -r requirements.txt

"Port 5001 already in use"

# Find and kill the process using port 5001
lsof -ti:5001 | xargs kill -9

Database errors

cd backend
rm parking_management.db
python main.py

Frontend Issues

"Port 8080 already in use"

# Find and kill the process using port 8080
lsof -ti:8080 | xargs kill -9

"npm install" fails

# Clear npm cache and try again
npm cache clean --force
npm install

General Issues

Virtual environment not activating

# Make sure you're in the backend directory
cd backend
source venv/bin/activate
# You should see (venv) in your prompt

Project Structure

Parking_Mad2/
├── backend/
│   ├── application/           # Main Flask application
│   │   ├── __init__.py       # App factory
│   │   ├── config.py         # Configuration
│   │   ├── models.py         # Database models
│   │   ├── database.py       # Database setup
│   │   ├── swagger_setup.py  # API documentation
│   │   └── routes/           # API routes
│   ├── main.py              # Entry point
│   ├── tasks.py             # Background tasks (disabled)
│   ├── requirements.txt     # Python dependencies
│   ├── .env                 # Environment variables
│   └── venv/                # Virtual environment
├── frontend/
│   ├── src/                 # Vue.js source code
│   ├── public/              # Static files
│   ├── package.json         # Node.js dependencies
│   └── node_modules/        # Installed packages
└── README.md                # Project documentation

Success!

If everything is working correctly, you should see:

  1. Backend running on http://localhost:5001
  2. Frontend running on http://localhost:8080
  3. Database created with admin user
  4. No error messages in the terminal

Next Steps

  1. Start the backend in Terminal 1: cd backend && source venv/bin/activate && python3 main.py
  2. Start the frontend in Terminal 2: cd frontend && npm run serve
  3. Start Redis server in Terminal 3: brew services start redis
  4. Start Celery Worker in Terminal 4: cd backend && source venv/bin/activate && celery -A application.workers.celery worker --loglevel=info
  5. Start Celery Beat (scheduler) in Terminal 5: cd backend && source venv/bin/activate && celery -A application.workers.celery beat --loglevel=info
  6. Test the application by logging in as admin
  7. Create a parking lot through the admin dashboard
  8. Register a new user and test booking functionality
  9. Explore the features available in both admin and user dashboards

Additional Resources

Need Help?

If you encounter any issues:

  1. Check the troubleshooting section above
  2. Verify all prerequisites are installed
  3. Ensure ports 5001 and 8080 are available
  4. Check that virtual environment is activated
  5. Review the terminal output for error messages

The application is now ready to use! 🚀

API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • GET /api/auth/profile - Get user profile
  • PUT /api/auth/profile - Update user profile
  • POST /api/auth/logout - User logout

Admin

  • GET /api/admin/dashboard - Admin dashboard data
  • GET /api/admin/users - Get all users
  • GET /api/admin/parking-lots - Get all parking lots
  • POST /api/admin/parking-lots - Create parking lot
  • PUT /api/admin/parking-lots/{id} - Update parking lot
  • DELETE /api/admin/parking-lots/{id} - Delete parking lot

User

  • GET /api/user/dashboard - User dashboard data
  • GET /api/user/parking-lots - Get available parking lots
  • GET /api/user/reservations - Get user reservations
  • POST /api/user/reservations - Create reservation
  • POST /api/user/reservations/{id}/release - Release reservation
  • POST /api/user/export-csv - Export user data as CSV (disabled)

Parking

  • GET /api/parking/lots - Get all parking lots (public)
  • GET /api/parking/lots/{id} - Get parking lot details
  • GET /api/parking/search - Search parking lots
  • GET /api/parking/stats - Get parking statistics

Database Schema

Users Table

  • id: Primary key
  • username: Unique username
  • email: Unique email address
  • password_hash: Hashed password
  • role: 'admin' or 'user'
  • is_active: Account status
  • created_at, updated_at: Timestamps

Parking Lots Table

  • id: Primary key
  • prime_location_name: Location name
  • address: Full address
  • pin_code: Postal code
  • price_per_hour: Hourly rate
  • number_of_spots: Total spots
  • is_active: Status
  • created_at, updated_at: Timestamps

Parking Spots Table

  • id: Primary key
  • lot_id: Foreign key to parking lots
  • spot_number: Spot identifier (e.g., A1, B2)
  • status: 'A' (Available) or 'O' (Occupied)
  • is_active: Status
  • created_at, updated_at: Timestamps

Reservations Table

  • id: Primary key
  • spot_id: Foreign key to parking spots
  • user_id: Foreign key to users
  • parking_timestamp: Start time
  • leaving_timestamp: End time
  • parking_cost: Calculated cost
  • status: 'active', 'completed', 'cancelled'
  • vehicle_number: Vehicle identifier
  • remarks: Additional notes
  • created_at, updated_at: Timestamps

Contributing

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

License

This project is licensed under the MIT License.

Support

For support and questions, please contact the development team or create an issue in the repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published