A REST API built with Django and Django REST Framework for monitoring road traffic on local road segments.
- Full CRUD for road segments (
RoadSegment) - Full CRUD for average speed readings (
TrafficReading) - Dynamic traffic intensity calculation based on speed
- Total readings count per segment
- User-based permissions:
- Admin: can create, edit, and delete
- Anonymous: read-only access
- Admin interface via Django Admin
- Interactive API documentation at
/api/docs
- Python 3.12 or higher
- pip
-
Clone the repository:
git clone https://github.com/pedro-alvesjr/traffic_monitor cd traffic_monitor -
(Optional) Create and activate a virtual environment:
python -m venv venv venv\Scripts\activate # On Windows
or
source venv/bin/activate # On Linux/macOS
-
Install the dependencies:
pip install -r requirements.txt
-
Apply the migrations:
python manage.py migrate
-
Create a superuser:
python manage.py createsuperuser
-
Start the development server:
python manage.py runserver
- API (road segments): [
/api/roadsegments/] - API (readings): [
/api/readings/] - Swagger Documentation: [
/api/docs/] - Django Admin: [
/admin/]