Skip to content

🧠 DevHub API β€” A modern, open-source developer community built with Django & DRF. Share projects, star favorites, track trends, and connect with other developers β€” all via a clean RESTful API.

Notifications You must be signed in to change notification settings

MortezaHashemabadi/devhub-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tests

πŸš€ DevHub API β€” Open Source Developer Community (Django + DRF)

DevHub API is an open-source platform for developers to share projects, get feedback, and explore trending projects weekly.
Built with Django REST Framework, it features JWT authentication, automated tests, Docker, and CI/CD via GitHub Actions.


βš™οΈ Tech Stack

Component Technology
Backend Django 5, Django REST Framework
Auth JWT (SimpleJWT)
Database SQLite (Dev & CI)
Testing pytest + pytest-django
CI/CD GitHub Actions (Dockerized)
Containerization Docker & Docker Compose

✨ Features

βœ… Register / Login (JWT Authentication)
βœ… Developer Profiles (auto-created on registration)
βœ… CRUD Projects (Create, Read, Update, Delete)
βœ… Like (Star) + View Count
βœ… Comments System
βœ… Trending Projects (based on stars & views in the last 7 days)
βœ… Unit Tests with pytest βœ… CI/CD with GitHub Actions
βœ… Dockerized Setup


🧠 Project Description

DevHub is a modern, community-driven API for developers.
It aims to provide an experience similar to GitHub Explore or ProductHunt for developer projects.
Users can publish their projects, star others’ projects, leave comments, and view trending projects weekly.

🧩 Designed with clean architecture, testability, and fast Docker deployment in mind.



🧩 Installation & Setup

git clone https://github.com/MortezaHashemabadi/devhub-api.git
cd devhub-api

πŸ”Ή Local (manual) python -m venv .venv source .venv/bin/activate # (Windows: .venv\Scripts\activate) pip install -r requirements.txt python manage.py migrate python manage.py runserver


πŸ”Ή With Docker

docker-compose up --build

Access the API at http://localhost:8000.

πŸ” Authentication

Endpoint Description
POST /api/auth/register/ Register a new user
POST /api/token/ Login (JWT Access & Refresh Tokens)
POST /api/token/refresh/ Refresh JWT Access Token

Example Login Response:

{ "access": "<JWT_ACCESS>", "refresh": "<JWT_REFRESH>" }

🧱 Core API Endpoints

Method Endpoint Description
GET /api/projects/ List all projects
POST /api/projects/ Create a new project
GET /api/projects/{id}/ Retrieve project details
POST /api/projects/{id}/toggle_star/ Star or unstar a project
POST /api/projects/{id}/add_view/ Increment view count
GET /api/projects/trending/ List trending projects
GET/POST /api/comments/ List or create comments

πŸ§ͺ Run Tests

  • Locally : pytest -v
  • Inside Docker : docker run --rm devhub-api pytest -v

Example output:

========================== 3 passed in 2.10s


🐳 Docker Compose Configuration

This project is fully Dockerized using SQLite. Directory structure:

devhub-api/ β”‚ β”œβ”€β”€ core/ β”œβ”€β”€ developers/ β”œβ”€β”€ users/ β”œβ”€β”€ db_data/ β”‚ └── db.sqlite3 β”œβ”€β”€ Dockerfile β”œβ”€β”€ docker-compose.yml β”œβ”€β”€ pytest.ini β”œβ”€β”€ .github/workflows/ci.yml β”œβ”€β”€ requirements.txt └── README.md

  • Run with:

docker-compose up --build


βš™οΈ CI/CD via GitHub Actions

On each push to main, GitHub Actions:

Builds the Docker image

Runs automated tests

Displays test results as a badge


πŸ“ˆ Example: Trending Endpoint

GET /api/projects/trending/

Response:

[ { "title": "AI Portfolio Builder", "stars_count": 30, "views": 120 }, { "title": "FastAPI Scraper", "stars_count": 18, "views": 80 } ]


🧩 Contributing

Pull Requests and Issues are welcome πŸ’¬ If you have ideas for new features (e.g., notifications, tagging system), feel free to submit a PR.


🧾 License

MIT License Β© 2025 Morteza Hashemabadi

About

🧠 DevHub API β€” A modern, open-source developer community built with Django & DRF. Share projects, star favorites, track trends, and connect with other developers β€” all via a clean RESTful API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published