A comprehensive Django-based university finder application with Google OAuth authentication, interactive mapping, and multi-country university data.
- Google OAuth Authentication - Secure login with Google accounts
- Multi-Country University Data - 1,715+ universities across 9 countries
- Interactive Google Maps - Visual university locations with markers
- Country-Based Filtering - Universities from Philippines, Japan, India, Australia, Canada, Singapore, Thailand, Saudi Arabia, United Kingdom
- Real-time Search - Search universities within selected countries
- Responsive Design - Mobile-friendly interface with Bootstrap
- REST API - Backend API for university data and locations
- Purpose: User authentication and authorization
- Endpoints Used:
https://accounts.google.com/o/oauth2/v2/auth- OAuth authorizationhttps://oauth2.googleapis.com/token- Token exchangehttps://www.googleapis.com/oauth2/v2/userinfo- User profile data
- Authentication: Client ID/Secret from Google Cloud Console
- Data Retrieved: User email, name, profile picture
- Purpose: Interactive map display and university location visualization
- Features Used:
- Map rendering and markers
- Info windows for university details
- Geocoding (coordinates to addresses)
- Authentication: API key from Google Cloud Console
- Purpose: Geocoding service for university coordinates
- Endpoint:
https://nominatim.openstreetmap.org/search - Features:
- University address to latitude/longitude conversion
- Reverse geocoding capabilities
- Authentication: User-Agent header required
- Rate Limiting: 1 request/second
- Purpose: Source of university data
- Endpoint:
http://universities.hipolabs.com/search - Parameters:
country={country_name} - Data Retrieved: University names, countries, domains, websites
- Authentication: None required
1. User visits website
β
2. Redirected to login (if not authenticated)
β
3. Google OAuth authentication
β
4. User lands on home page
β
5. Clicks "Universities" β universities page
β
6. Selects country from dropdown
β
7. Universities load from database
β
8. Interactive map shows university locations
β
9. User can search within selected country
β
10. Click "Locate" to see university on map
Management Command: load_universities
β
For each country in [Philippines, Japan, India, Australia, Canada, Singapore, Thailand, Saudi Arabia, United Kingdom]:
β
Call Hipolabs API: /search?country={country}
β
For each university returned:
β
Call Nominatim API to get coordinates
β
Store in database: University(name, country, lat, lng)
User selects country on frontend
β
Frontend calls: GET /api/universities/?country={selected_country}
β
Django view filters universities from database
β
Returns JSON with university list
β
Frontend renders university cards
β
Frontend calls: GET /api/university-locations/?country={selected_country}
β
Returns coordinates for map markers
β
Google Maps renders with university markers
User clicks "Login with Google"
β
Django redirects to: accounts/google/login/
β
Google OAuth consent screen
β
User grants permission
β
Google redirects to: accounts/google/login/callback/
β
Django exchanges code for access token
β
Fetches user profile from Google
β
Creates/updates user in database
β
Logs user in and redirects to home
User (Django auth)
β
SocialAccount (allauth) β Google OAuth data
β
University (name, country, lat, lng)
GET /api/universities/ β List universities by country
GET /api/university-locations/ β Get coordinates for map
GET /api/search-university/ β Search university by name
GET /api/user/ β Current user info
- Python 3.8+
- Django 5.2+
- PostgreSQL (recommended) or SQLite
git clone <repository-url>
cd university-finder-api
pip install -r requirements.txtCreate a .env file in the project root:
SECRET_KEY=your-django-secret-key
DEBUG=True
DATABASE_URL=postgresql://user:password@localhost:5432/university_finder
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_API_KEY=your-google-maps-api-key- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Google+ API
- Go to "Credentials" in the left sidebar
- Click "Create Credentials" > "OAuth 2.0 Client IDs"
- Configure the OAuth consent screen if prompted
- Set the application type to "Web application"
- Add authorized redirect URIs:
- For development:
http://127.0.0.1:8000/accounts/google/login/callback/ - For production:
https://yourdomain.com/accounts/google/login/callback/(Remember to change ACCOUNT_DEFAULT_HTTP_PROTOCOL back to 'https' in production)
- For development:
- Copy the Client ID and Client Secret
- In Google Cloud Console, enable "Maps JavaScript API"
- Create an API key with restrictions for your domain
- Add the API key to your
.envfile
python manage.py migrate
python manage.py load_universities # Load university datapython manage.py runserverVisit http://127.0.0.1:8000/ to access the application.
The system includes a management command to load universities for all supported countries:
python manage.py load_universitiesThis command:
- Fetches data from Hipolabs Universities API
- Geocodes university locations using OpenStreetMap Nominatim
- Stores data in the local database for fast retrieval
- Philippines (default)
- Japan
- India
- Australia
- Canada
- Singapore
- Thailand
- Saudi Arabia
- United Kingdom
- CSRF protection on forms
- HTTPS enforcement in production
- OAuth 2.0 secure token handling
- Content Security Policy (CSP) headers
- Database indexing on country field
- Coordinate caching in database
- Lazy loading of map components
- CDN for static assets (Bootstrap, Font Awesome)
university-finder-api/
βββ api/ # Main application
β βββ models.py # Database models
β βββ views.py # API views
β βββ views_frontend.py # Frontend views
β βββ serializers.py # API serializers
β βββ urls.py # API URL patterns
βββ config/ # Django settings
β βββ settings.py # Main settings
β βββ urls.py # URL configuration
β βββ adapters.py # Social auth adapters
βββ templates/ # HTML templates
β βββ navbar.html # Navigation component
β βββ home.html # Home page
β βββ universities.html # Universities page
β βββ account/ # Authentication templates
β βββ socialaccount/ # Social auth templates
βββ static/ # Static files
βββ manage.py # Django management script
βββ requirements.txt # Python dependencies
βββ README.md # This file
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Hipolabs Universities API for university data
- OpenStreetMap Nominatim for geocoding
- Google Maps Platform for mapping
- Django Allauth for authentication