This guide provides step-by-step instructions to set up the Online Ticket Booking System. Follow these steps to install the project and run it locally.
Before you begin, ensure you have the following installed on your system:
- Python (version 3.10)
- pip (Python package installer)
- Virtualenv (optional but recommended)
- Git
- LocalStack
- Node.js and npm (for React)
Start by cloning the project repository from GitHub:
git clone https://github.com/Gangula-Sandaru/Online-Ticket-Booking-System-Django-and-React.git
cd Online-Ticket-Booking-System-Django-and-ReactIt is recommended to use a virtual environment to manage dependencies:
# Create a virtual environment
python -m venv venv
# Activate the virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activateInstall the required Python packages using the requirements.txt file:
pip install -r requirements.txtCreate a .env file in the root directory and add the required configurations. Below is an example:
# Example .env file
DEBUG=True
SECRET_KEY=your_secret_key
DATABASE_URL=sqlite:///db.sqlite3 # Update with your database URL if using other DB
Replace your_secret_key with a unique secret key for the Django project.
Run the following commands to set up the database and prepare the project:
# Apply migrations
python manage.py migrate
# Create a superuser
python manage.py createsuperuser
# Collect static files
python manage.py collectstaticStart the server to test the backend:
python manage.py runserverThe backend will be available at http://127.0.0.1:8000.
OnlineBooking/ # Main project directory
├── booking/ # App for handling booking functionality
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations/ # Contains migration files
│ │ ├── __init__.py
│ ├── models.py # App models
│ ├── tests.py # Unit tests for the app
│ ├── views.py # View logic
│ └── urls.py # URL routing for the app
├── venv/ # Virtual environment directory (excluded in `.gitignore`)
├── .env # Environment variables
├── .gitignore # Ignored files and folders for Git
├── db.sqlite3 # SQLite database
├── manage.py # Django's CLI utility
├── README.md # Project documentation
└── requirements.txt # Python dependencies
# This is the Database information
DATABASE_NAME="BookingDB"
DATABASE_USER="your database username"
DATABASE_PASSWORD="your database password"
DATABASE_HOST="database engine ip address"
DATABASE_PORT="3306"
# Email information
EMAIL_HOST_USER="[email protected]"
# This is the Test Database Information
TEST_DATABASE_NAME="TestBookingDB"
Navigate to the frontend folder and install dependencies:
cd frontend
npm installStart the React development server:
npm startThe frontend will be available at http://localhost:3000.
Open your browser and navigate to the following URLs:
- Frontend: http://localhost:3000
- Backend (API): http://127.0.0.1:8000
You should see the application up and running!
- Make sure to update the
.envfile for production if you are deploying the project. - Use tools like
Gunicornandnginxfor production deployment. - For advanced configurations, refer to the official Django and React documentation.
Author: Gangula Sandaru
Happy coding! 🎉