Django REST API powering the EntreHive social platform for students, professors, and investors.
- Live Site: https://entrehive.ca
- Frontend Repository: EntreHive Frontend
- Backend Repository: EntreHive Backend
- Overview
- Features
- Tech Stack
- Getting Started
- Project Structure
- Django Apps
- Environment Variables
- Database Models
- API Endpoints
- Authentication
- Deployment
- Contributing
EntreHive Backend is a comprehensive Django REST API that powers the EntreHive platform. It provides a robust, scalable backend with role-based access control, real-time notifications, messaging system, and social networking features tailored for the entrepreneurial ecosystem.
- JWT-based authentication with refresh tokens
- Email verification system
- Password reset functionality
- Role-based access control (Student, Professor, Investor)
- Permission-based API endpoints
- User profiles with customizable information
- Profile pictures and banners
- University affiliation
- Bio and social links
- Follow/unfollow system
- Public/private profile settings
- Post creation with rich content
- Image uploads for posts and projects
- Comment and reply system
- Like functionality
- Post sharing
- Hashtag support
- Visibility controls (public/university-only)
- Create and manage entrepreneurial projects
- Project types: Startup, Research, Social Impact, Tech Innovation
- Team management and invitations
- Project status tracking
- Rich project profiles with banners
- Project discovery and search
- Categories and tagging system
- Direct Conversations: 1-on-1 messaging
- Group Conversations: Team-based messaging for projects
- Project View Requests: Permission-based access system
- Message read receipts
- Unread message tracking
- Permission management for messaging
- Real-time notification system
- Notification types:
- Likes and comments
- New followers
- Project invitations
- Messages
- Project view requests
- Read/unread status
- Bulk operations
- Global search across users, posts, and projects
- Advanced filtering
- Hashtag search
- Category-based project search
- University-based filtering
- Django 5.2.6 - Web framework
- Django REST Framework 3.16.1 - API framework
- Python 3.10+ - Programming language
- djangorestframework-simplejwt 5.5.1 - JWT authentication
- dj-rest-auth 7.0.1 - REST auth endpoints
- django-allauth 65.11.2 - Authentication system
- PostgreSQL - Production database (via psycopg 3.2.10)
- SQLite - Development database
- django-cors-headers 4.8.0 - CORS handling
- django-filter 25.1 - Advanced filtering
- Pillow 11.3.0 - Image processing
- python-dotenv 1.1.1 - Environment variable management
- Python 3.10 or higher
- PostgreSQL (for production) or SQLite (for development)
- pip package manager
- Virtual environment (recommended)
-
Clone the repository
git clone https://github.com/Aadit-Chadda/EntreHive_backend.git cd EntreHive_backend -
Create a virtual environment
python -m venv venv # Activate virtual environment # On macOS/Linux: source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
Create a
.envfile in the root directory:# Django Settings SECRET_KEY=your-secret-key-here DEBUG=True ALLOWED_HOSTS=localhost,127.0.0.1 # CORS Settings CORS_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000 # Database (PostgreSQL for production) # DATABASE_URL=postgresql://user:password@localhost:5432/entrehive # Email Configuration EMAIL_HOST=smtp.gmail.com EMAIL_PORT=587 EMAIL_USE_TLS=True EMAIL_HOST_USER=[email protected] EMAIL_HOST_PASSWORD=your-app-password DEFAULT_FROM_EMAIL=[email protected] # Frontend URL FRONTEND_URL=http://localhost:3000
-
Run database migrations
python manage.py makemigrations python manage.py migrate
-
Create a superuser (optional)
python manage.py createsuperuser
-
Run the development server
python manage.py runserver
-
Access the API
Navigate to http://localhost:8000/api/
# Run all tests
python manage.py test
# Run specific app tests
python manage.py test accounts
python manage.py test posts
python manage.py test projectsentrehive_backend/
├── accounts/ # User management app
│ ├── models.py # UserProfile, Follow models
│ ├── views.py # User endpoints
│ ├── serializers.py # User serializers
│ └── urls.py # User routes
├── posts/ # Social posts app
│ ├── models.py # Post, Comment, Like models
│ ├── views.py # Post endpoints
│ ├── serializers.py # Post serializers
│ └── urls.py # Post routes
├── projects/ # Project management app
│ ├── models.py # Project, ProjectInvitation models
│ ├── views.py # Project endpoints
│ ├── serializers.py # Project serializers
│ └── urls.py # Project routes
├── messaging/ # Messaging system app
│ ├── models.py # Conversation, Message, GroupConversation models
│ ├── views.py # Messaging endpoints
│ ├── serializers.py # Messaging serializers
│ └── urls.py # Messaging routes
├── notifications/ # Notification system app
│ ├── models.py # Notification model
│ ├── views.py # Notification endpoints
│ ├── serializers.py # Notification serializers
│ └── urls.py # Notification routes
├── feed/ # Feed algorithm app
│ ├── views.py # Feed endpoints
│ └── utils.py # Feed scoring logic
├── universities/ # University data app
│ ├── models.py # University model
│ └── admin.py # Admin interface
├── contact/ # Contact form app
│ ├── models.py # ContactSubmission model
│ └── views.py # Contact endpoints
├── entrehive_backend/ # Project settings
│ ├── settings.py # Django settings
│ ├── urls.py # Main URL configuration
│ └── wsgi.py # WSGI configuration
├── media/ # User-uploaded files
├── static/ # Static files
├── manage.py # Django management script
├── requirements.txt # Python dependencies
├── .env # Environment variables (create this)
└── README.md # This file
User authentication, profiles, and social features
- User profile management
- Email verification
- Follow/unfollow system
- Profile customization
- User search
Social networking features
- Post creation and management
- Comments and replies
- Like system
- Post sharing
- Hashtag support
- Feed integration
Entrepreneurial project management
- Project CRUD operations
- Team management
- Project invitations
- Project search and discovery
- Categories and tags
- Status tracking
Communication system
- Direct messaging (1-on-1)
- Group conversations (team chats)
- Project view requests
- Message permissions
- Read receipts
- Unread counts
Real-time notification system
- Multiple notification types
- Read/unread tracking
- Bulk operations
- User preferences
Curated content feed
- Engagement-based scoring
- User preferences
- University-based filtering
- Personalized recommendations
University data management
- University information
- Student affiliation
- University-based filtering
Contact form handling
- Contact submissions
- Admin management
Create a .env file with the following variables:
# Django Core
SECRET_KEY=your-django-secret-key
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
# Database (PostgreSQL for production)
DATABASE_URL=postgresql://username:password@localhost:5432/entrehive
# Or use SQLite for development (default)
# CORS Configuration
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000
# Email Configuration
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_HOST_USER=[email protected]
EMAIL_HOST_PASSWORD=your-app-password
DEFAULT_FROM_EMAIL=[email protected]
# Frontend URL
FRONTEND_URL=http://localhost:3000
# Optional: AWS S3 Configuration for media files
# AWS_ACCESS_KEY_ID=your-access-key
# AWS_SECRET_ACCESS_KEY=your-secret-key
# AWS_STORAGE_BUCKET_NAME=your-bucket-name
# AWS_S3_REGION_NAME=us-east-1Extended user profile with additional information
- user (OneToOne -> User)
- profile_picture (ImageField)
- banner_image (ImageField)
- bio (TextField)
- university (ForeignKey -> University)
- user_role (CharField: student/professor/investor)
- linkedin_url, github_url, website_url
- is_profile_public (Boolean)
- email_verified (Boolean)Social media posts
- author (ForeignKey -> User)
- content (TextField)
- image_url (URLField)
- visibility (CharField: public/university)
- tagged_projects (ManyToMany -> Project)
- created_at, updated_atEntrepreneurial projects
- owner (ForeignKey -> User)
- title, summary (CharField, TextField)
- project_type (CharField: startup/research/social_impact/tech_innovation)
- status (CharField: planning/active/completed/on_hold)
- team_members (ManyToMany -> User)
- banner_image, preview_image (ImageField)
- categories, tags, needs (JSONField)
- visibility (CharField)
- university (ForeignKey -> University)Direct 1-on-1 conversations
- participant_1, participant_2 (ForeignKey -> User)
- initiated_by (ForeignKey -> User)
- related_project (ForeignKey -> Project, optional)
- status (CharField: active/archived)
- created_at, updated_at, last_message_atTeam-based group messaging
- project (ForeignKey -> Project)
- created_by (ForeignKey -> User)
- participants (ManyToMany -> User)
- created_at, updated_at, last_message_atUser notifications
- recipient (ForeignKey -> User)
- sender (ForeignKey -> User)
- notification_type (CharField)
- post, project, comment (ForeignKey, optional)
- message (TextField)
- is_read (Boolean)
- created_atPOST /api/auth/registration/ # Register new user
POST /api/auth/login/ # Login
POST /api/auth/logout/ # Logout
POST /api/auth/password/reset/ # Request password reset
POST /api/auth/password/reset/confirm/ # Confirm password reset
POST /api/auth/token/refresh/ # Refresh JWT token
GET /api/accounts/verify-email/<key>/ # Verify email
GET /api/accounts/profile/ # Get current user profile
PUT /api/accounts/profile/ # Update profile
GET /api/accounts/profile/<username>/ # Get user by username
POST /api/accounts/follow/<username>/ # Follow user
DELETE /api/accounts/unfollow/<username>/ # Unfollow user
GET /api/accounts/followers/ # Get followers
GET /api/accounts/following/ # Get following
GET /api/accounts/search/ # Search users, posts, projects
GET /api/posts/ # List posts
POST /api/posts/ # Create post
GET /api/posts/<id>/ # Get post detail
PUT /api/posts/<id>/ # Update post
DELETE /api/posts/<id>/ # Delete post
POST /api/posts/<id>/like/ # Toggle like
GET /api/posts/<id>/likes/ # Get likes
POST /api/posts/<id>/share/ # Share post
GET /api/posts/feed/ # Get curated feed
GET /api/posts/my_posts/ # Get user's posts
GET /api/search/ # Search posts
GET /api/posts/<post_id>/comments/ # List comments
POST /api/posts/<post_id>/comments/ # Create comment
PUT /api/posts/<post_id>/comments/<id>/ # Update comment
DELETE /api/posts/<post_id>/comments/<id>/ # Delete comment
GET /api/projects/ # List projects
POST /api/projects/ # Create project
GET /api/projects/<id>/ # Get project detail
PUT /api/projects/<id>/ # Update project
DELETE /api/projects/<id>/ # Delete project
GET /api/projects/my_projects/ # Get user's projects
POST /api/projects/<id>/add_team_member/ # Add team member
DELETE /api/projects/<id>/remove_team_member/ # Remove team member
GET /api/projects/search/ # Search projects
GET /api/messaging/conversations/ # List conversations
POST /api/messaging/conversations/create/ # Create conversation
GET /api/messaging/conversations/<id>/ # Get conversation detail
POST /api/messaging/conversations/<id>/messages/create/ # Send message
GET /api/messaging/group-conversations/ # List group conversations
POST /api/messaging/group-conversations/create/ # Create group
GET /api/messaging/group-conversations/<id>/ # Get group detail
POST /api/messaging/group-conversations/<id>/messages/create/ # Send group message
GET /api/messaging/project-view-requests/ # List view requests
POST /api/messaging/project-view-requests/create/ # Create request
POST /api/messaging/project-view-requests/<id>/respond/ # Respond to request
GET /api/notifications/ # List notifications
GET /api/notifications/<id>/ # Get notification detail
POST /api/notifications/<id>/mark_as_read/ # Mark as read
POST /api/notifications/mark_all_as_read/ # Mark all as read
GET /api/notifications/unread_count/ # Get unread count
GET /api/feed/ # Get curated feed
GET /api/feed/trending/ # Get trending topics
The API uses JWT (JSON Web Tokens) for authentication:
- Register:
POST /api/auth/registration/ - Login:
POST /api/auth/login/- Returns access and refresh tokens - Use Token: Include in headers:
Authorization: Bearer <access_token> - Refresh:
POST /api/auth/token/refresh/- Get new access token
# Register
POST /api/auth/registration/
{
"username": "johndoe",
"email": "[email protected]",
"password1": "securepassword123",
"password2": "securepassword123"
}
# Login
POST /api/auth/login/
{
"username": "johndoe",
"password": "securepassword123"
}
# Response
{
"access": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"user": {...}
}
# Use token in subsequent requests
GET /api/accounts/profile/
Headers: Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGc...-
Environment Variables
- Set
DEBUG=False - Configure
ALLOWED_HOSTS - Set strong
SECRET_KEY - Configure production database
- Set up email service
- Configure AWS S3 for media files
- Set
-
Database
- Run migrations:
python manage.py migrate - Create superuser:
python manage.py createsuperuser
- Run migrations:
-
Static Files
python manage.py collectstatic
-
Security
- Enable HTTPS
- Configure CORS properly
- Set secure cookie settings
- Enable CSRF protection
-
Server
- Use gunicorn or uwsgi
- Set up nginx reverse proxy
- Configure SSL certificates
gunicorn entrehive_backend.wsgi:application \
--bind 0.0.0.0:8000 \
--workers 4 \
--timeout 120We welcome contributions to EntreHive Backend!
- Fork the repository
- Create a feature branch
git checkout -b feature/your-feature-name
- Make your changes
- Run tests
python manage.py test - Commit with clear messages
git commit -m "Add feature: your feature description" - Push to your fork
git push origin feature/your-feature-name
- Create a Pull Request
- Follow PEP 8 guidelines
- Use meaningful variable and function names
- Add docstrings to classes and methods
- Write unit tests for new features
- Keep functions focused and modular
Always create migrations when modifying models:
python manage.py makemigrations
python manage.py migrateAccess the Django admin panel at /admin/:
# Create superuser
python manage.py createsuperuser
# Access admin panel
http://localhost:8000/admin/Manage:
- Users and profiles
- Posts and comments
- Projects and teams
- Messages and conversations
- Notifications
- Contact submissions
This project is part of EntreHive platform.
- Built with Django and Django REST Framework
- Authentication powered by SimpleJWT
- Image handling with Pillow
- Database powered by PostgreSQL
Questions or Issues? Please open an issue in the GitHub repository.
Frontend Repository: EntreHive Frontend