A backend API built with Django and gRPC. The server exposes a UserService that can fetch and list users. Clients must use a gRPC client to communicate with it — not REST or a browser. gRPC runs on port 50051. Django runs on port 8000. Data is structured using Protocol Buffers (.proto files) instead of JSON. This project is the foundation for learning how backend services communicate with each other using gRPC — faster, typed, and more structured than REST.
- Python 3.13
- Django 6.0
- gRPC / Protocol Buffers
- Pipenv (dependency management)
- SQLite (development database)
The UserService exposes two RPC methods:
GetUser— fetch a single user by IDListUsers— fetch all users
git clone https://github.com/YOUR_USERNAME/django-grpc.git cd django-grpc
pipenv install
pipenv shell
python manage.py migrate
python manage.py createsuperuser
python -m grpc_tools.protoc -I protos --python_out=. --grpc_python_out=. protos/users.proto
python manage.py grpcserver
Server runs on port 50051.
List available services: grpcurl -plaintext localhost:50051 list
Get a user by ID: grpcurl -plaintext -d '{"id": 1}' localhost:50051 users.UserService/GetUser
List all users: grpcurl -plaintext localhost:50051 users.UserService/ListUsers
core/ Django project config (settings, urls, wsgi) users/ Users app (models, servicer, management commands) protos/ Protocol Buffer definitions users_pb2.py Auto-generated protobuf messages users_pb2_grpc.py Auto-generated gRPC servicer base