Prerequisites
Before you begin, ensure you have the following installed:- Python 3.13 - Required for the Django backend
- uv - Python package manager
- Node.js 20 - Required for the React/Next.js frontend (v20.11.1 is stable)
- Bun - JavaScript runtime and package manager
- PostgreSQL - Required for psycopg2 (Mac only, see below)
Backend Setup
The backend is a Django REST API that handles all data operations, authentication, and business logic.Mac: Install PostgreSQL Dependencies
On Mac, you need to install PostgreSQL and OpenSSL to buildpsycopg2:
Linux: Install Build Dependencies
On Linux, install Python development packages and PostgreSQL libraries:Install Backend Dependencies
Start the development server
Test User Credentials
Thepopulate command creates a test user:
- Username:
bfranklin - Password:
test
Frontend Setup
The frontend is a Next.js application built with React that provides the user interface.Start the development server
Environment Variables
Development Environment Variables
For local development, most variables have sensible defaults. Create a.env file in the backend directory if you need to customize settings.
Optional Development Variables
NGROK_URL- Required for testing CyberSource payment flows (see Payment Testing below)CYBERSOURCE_SA_PROFILE_ID- CyberSource test profile IDCYBERSOURCE_SA_ACCESS_KEY- CyberSource test access keyCYBERSOURCE_SA_SECRET_KEY- CyberSource test secret key
Production Environment Variables
Backend Variables
SECRET_KEY- Django secret key for cryptographic signingDATABASE_URL- PostgreSQL connection stringSENTRY_URL- Sentry DSN for error trackingAWS_ACCESS_KEY_ID- AWS access key for S3 file storageAWS_SECRET_ACCESS_KEY- AWS secret keyAWS_STORAGE_BUCKET_NAME- S3 bucket nameLABS_REDIRECT_URI- OAuth redirect URILABS_CLIENT_ID- Platform OAuth client IDLABS_CLIENT_SECRET- Platform OAuth client secretREDIS_HOST- Redis host for caching and channelsEMAIL_HOST- SMTP server hostnameEMAIL_USERNAME- SMTP usernameEMAIL_PASSWORD- SMTP password
Frontend Variables
NEXT_PUBLIC_GOOGLE_API_KEY- Google Maps API keyNEXT_PUBLIC_SITE_NAME- Site branding (clubsfor Penn Clubs,fyhfor Hub@Penn)
Ticketing/Payment Variables
For CyberSource Secure Acceptance Hosted Checkout:CYBERSOURCE_SA_PROFILE_ID- Secure Acceptance profile IDCYBERSOURCE_SA_ACCESS_KEY- Access key for the profileCYBERSOURCE_SA_SECRET_KEY- Secret key for signing requestsFRONTEND_URL- Base URL for post-payment redirects (defaults tohttps://pennclubs.com)
Payment Testing with ngrok
To test the ticketing/payment flow locally, you need a publicly accessible URL for CyberSource callbacks.Start ngrok tunnel
In a separate terminal:Copy the HTTPS forwarding URL (e.g.,
https://abc123.ngrok-free.app)Configure environment variables
Create
backend/.env with your ngrok URL and CyberSource test credentials:Access the application
Access at http://localhost:3000 (NOT the ngrok URL)
The
NGROK_URL variable configures the CyberSource callback URL and adds the ngrok URL to CSRF_TRUSTED_ORIGINS. Always use http://localhost:3000 in your browser for proper session handling.CyberSource Test Credentials
To obtain CyberSource test credentials:- Log into the CyberSource Business Center
- Navigate to Payment Configuration → Secure Acceptance Settings
- Create or select a Hosted Checkout profile
- Generate security keys and note the Profile ID, Access Key, and Secret Key
Troubleshooting
psycopg2 Build Errors (Mac)
If you encounter errors buildingpsycopg2, ensure you’ve followed the Mac PostgreSQL setup steps and exported the LDFLAGS and CPPFLAGS environment variables.
Node Version Issues
Verify you’re using Node 20:Port Already in Use
If port 8000 or 3000 is already in use:- Backend:
uv run ./manage.py runserver 8001 - Frontend: Update
package.jsonproxy setting to match your backend port
Next Steps
- Read the Architecture Overview to understand the system design
- Learn how to run tests in the Testing Guide
- Check out the Deployment Guide for production deployment