A Django REST Framework backend for a freelance marketplace platform connecting business users with customers. This API provides comprehensive functionality for user authentication, profile management, service offers, order processing, and review systems.
You can find the corresponding frontend here: https://github.com/RobbyRunge/coderr-frontend
- Prerequisites
- Installation
- Features
- Technology Stack
- Project Structure
- API Endpoints
- Testing
- Authentication
- Models
- Development
- License
- Contributing
- Support
- Python 3.8+
- pip
- Virtual environment (recommended)
-
Clone the repository:
git clone <repository-url> cd modul-9.2-coderr-backend
-
Create and activate a virtual environment:
python -m venv .venv # On Windows .venv\Scripts\activate # On macOS/Linux source .venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.envfile in the project root:SECRET_KEY=your-secret-key-here DEBUG=True ALLOWED_HOSTS=localhost,127.0.0.1
Generate a SECRET_KEY:
You can generate a secure SECRET_KEY using Python:
python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"Or use this one-liner in PowerShell:
python -c "import secrets; print(secrets.token_urlsafe(50))"
Copy the generated key and paste it into your
.envfile. -
Run migrations:
python manage.py migrate
-
Create a superuser (optional):
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
The API will be available at http://localhost:8000/
-
User Authentication & Authorization
- Token-based authentication
- Custom user model with customer/business user types
- Registration and login endpoints
-
Profile Management
- Separate profiles for business and customer users
- Profile creation, retrieval, and updates
- File upload support for profile images
-
Offers System
- Create, read, update, and delete service offers
- Multiple offer details with different pricing tiers (basic, standard, premium)
- Image upload for offers
- Filtering, searching, and ordering capabilities
- Dynamic pagination
-
Orders Management
- Order creation from offer details
- Order status tracking (in_progress, completed, cancelled)
- Order history for customers and business users
- Order count statistics
-
Reviews & Ratings
- Customer reviews for business users
- 1-5 star rating system
- Review filtering by business user or reviewer
- Update and delete review functionality
-
Platform Statistics
- Base information endpoint with platform-wide metrics
- Review count and average ratings
- Business profile and offer counts
- Framework: Django 5.2.7
- API: Django REST Framework 3.16.1
- Authentication: Token-based authentication
- Database: SQLite (development)
coderr-backend/
βββ auth_app/ # User authentication & authorization
β βββ api/
β β βββ serializers.py
β β βββ views.py
β β βββ urls.py
β βββ models.py # CustomUser model
β βββ tests/
βββ profiles_app/ # User profile management
β βββ api/
β βββ models.py # Profile model
β βββ tests/
βββ offers_app/ # Service offers
β βββ api/
β βββ models.py # Offer & OfferDetail models
β βββ tests/
βββ orders_app/ # Order processing
β βββ api/
β βββ models.py # Order model
β βββ tests/
βββ reviews_app/ # Reviews & ratings
β βββ api/
β βββ models.py # Review model
β βββ tests/
βββ base_info_app/ # Platform statistics
β βββ api/
β βββ tests/
βββ core/ # Project configuration
β βββ settings.py
β βββ urls.py
β βββ wsgi.py
βββ media/ # User uploaded files
βββ manage.py
βββ requirements.txt
βββ README.md
POST /api/registration/- Register new user (customer or business)POST /api/login/- User login
GET /api/profile/{id}/- Get profile detailsPATCH /api/profile/{id}/- Update profileGET /api/profiles/business/- List all business profilesGET /api/profiles/customer/- List all customer profiles
GET /api/offers/- List all offers (with filtering & pagination)POST /api/offers/- Create new offer (business users only)GET /api/offers/{id}/- Get offer detailsPATCH /api/offers/{id}/- Update offerDELETE /api/offers/{id}/- Delete offerGET /api/offerdetails/{id}/- Get offer detail full information
GET /api/orders/- List user's ordersPOST /api/orders/- Create new orderGET /api/orders/{id}/- Get order detailsPATCH /api/orders/{id}/- Update order statusDELETE /api/orders/{id}/- Delete orderGET /api/order-count/{user_id}/- Get user's total order countGET /api/completed-order-count/{user_id}/- Get completed order count
GET /api/reviews/- List reviews (with filtering)POST /api/reviews/- Create review (customers only)PATCH /api/reviews/{id}/- Update review (owner only)DELETE /api/reviews/{id}/- Delete review (owner only)
GET /api/base-info/- Get platform statistics (no auth required)
The project includes comprehensive test coverage for all apps.
Run all tests:
python manage.py testRun tests for specific app:
python manage.py test auth_app.tests
python manage.py test profiles_app.tests
python manage.py test offers_app.tests
python manage.py test orders_app.tests
python manage.py test reviews_app.tests
python manage.py test base_info_app.testsUsing VS Code tasks:
The project includes pre-configured VS Code tasks for running tests. Use Ctrl+Shift+P β Tasks: Run Task and select the desired test suite.
This API uses token-based authentication. After successful registration or login, include the token in the Authorization header:
Authorization: Token <your-token-here>
- Extends Django's AbstractUser
- Fields:
username,email,password,user_type(customer/business)
- One-to-one relationship with User
- Fields:
username,first_name,last_name,file,location,tel,description,working_hours,type,email
- Created by business users
- Fields:
user,title,image,description,created_at,updated_at
- Multiple pricing tiers per offer
- Fields:
offer,title,revisions,delivery_time_in_days,price,features,offer_type
- Links customers with business users
- Fields:
customer_user,business_user,title,revisions,delivery_time_in_days,price,features,offer_type,status,created_at,updated_at
- Customer feedback for business users
- Fields:
business_user,reviewer,rating(1-5),description,created_at,updated_at
- Follow PEP 8 guidelines
- Use meaningful variable and function names
- Include docstrings for classes and methods
- Create models in
models.py - Create serializers in
api/serializers.py - Create views in
api/views.py - Add URL patterns in
api/urls.py - Write tests in
tests/ - Run migrations:
python manage.py makemigrationsandpython manage.py migrate
This project is part of a developer academy module.
This is an educational project. For contributions or questions, please contact the repository owner.
For issues or questions, please create an issue in the repository.
Note: This is a development version. For production deployment, ensure to:
- Set
DEBUG=False - Use a production-grade database (PostgreSQL, MySQL)
- Configure proper
ALLOWED_HOSTS - Set up secure
SECRET_KEY - Configure HTTPS
- Set up proper media and static file serving
- Implement rate limiting
- Add comprehensive logging