Created a Django Rest Framework API with PostgreSQL for seamless user registration and secure authentication. Allows task creation with Docker deployment, enabling users to mark tasks as complete.
GPL-3.0 License
Developed a robust TODO API leveraging Django Rest Framework and PostgreSQL, enabling users to seamlessly register with a unique username and password. Implemented secure authentication through security token features, facilitating secure login processes. The API further supports the creation of tasks with an initial false status, allowing users to mark them as complete upon task completion and then Deploy using Docker .
Install Docker here
Install Git here
Create a working directory:
mkdir ~/TODO && cd ~/TODO
Clone the repository
git clone https://github.com/ak4m410x01/TODO_API/ .
Start the application
docker-compose up -d
Access API: http://127.0.0.1:8000/api/
Access DB: 127.0.0.1:5432
Don't forget .env file with variables
Variable | Value |
---|---|
SECRET_KEY | "django-insecure-%2dmqnqj9v2e&8yk*t=#b+2-=i!45+153*@-g0*=&%1od16z^m" |
DEBUG | False |
DATABASE_ENGINE | "django.db.backends.postgresql" |
DATABASE_HOST | "db" |
DATABASE_PORT | "5432" |
DATABASE_NAME | "todo" |
DATABASE_USER | "todo" |
DATABASE_PASSWORD | "todo" |
POSTGRES_DB | "todo" |
POSTGRES_USER | "todo" |
POSTGRES_PASSWORD | "todo" |
you can use this .env file here
note: these variables are for the lab environment only... don't use these in xxx production environments xxx
+------------+---------+----------------------+
| Field | Type | Use |
| ---------- | ------- | -------------------- |
| id | INTEGER | To Store primary key |
| username | VARCHAR | To store username |
| password | VARCHAR | To store password |
| first_name | VARCHAR | To store first name |
| last_name | VARCHAR | To store last name |
| email | VARCHAR | To store email |
+------------+---------+----------------------+
+-------------+-------------+-----------------------+
| Field | Type | Use |
| ----------- | ----------- | --------------------- |
| id | INTEGER | To Store primary key |
| title | VARCHAR | To Store title |
| description | VARCHAR | To Store description |
| start_time | TIMESTAMP | to store start time |
| end_time | TIMESTAMP | to store end time |
| done | BOOL | to store state |
| created_at | TIMESTAMP | to store created time |
| updated_at | TIMESTAMP | to store created time |
| user | Foreign key | to store user |
+-------------+-------------+-----------------------+
base_url: http://127.0.0.1:8000/api/
Users:
+--------------------------------------------+---------------------+
| Endpoints | Use |
| ------------------------------------------ | ------------------- |
| POST `{{base_url}}/api/users/` | Rgister New User |
| GET `{{base_url}}/api/users/<int:id>/` | Get User Details |
| PUT `{{base_url}}/api/users/<int:id>/` | Update User Details |
| DELETE `{{base_url}}/api/users/<int:id>/` | Delete Task |
+--------------------------------------------+---------------------+
Tasks
+--------------------------------------------+---------------------+
| Endpoints | Use |
| ------------------------------------------ | ------------------- |
| GET `{{base_url}}/api/tasks/` | List All Tasks |
| POST `{{base_url}}/api/tasks/` | Create New Task |
| GET `{{base_url}}/api/tasks/<int:id>/` | Get Task Details |
| PUT `{{base_url}}/api/tasks/<int:id>/` | Update Task Details |
| DELETE `{{base_url}}/api/tasks/<int:id>/` | Delete Task |
+--------------------------------------------+---------------------+
Token
+--------------------------------------------+----------------------+
| Endpoints | Use |
| ------------------------------------------ | -------------------- |
| GET `{{base_url}}/users/token/` | Get Token |
| POST `{{base_url}}/users/token/` | Regenerate New Token |
+--------------------------------------------+----------------------+
+---------------------+---------+-------------------+
| Name | Version | Use |
| ------------------- | ------- | ----------------- |
| Python | 3.11.6 | Programming Lang |
| Django | 5.0.0 | Django Framework |
| djangorestframework | 3.14.0 | Restful Framework |
| psycopg2-binary | 2.9.9 | PostgreSQL DB lib |
| python-dotenv | 1.0.0 | To use .env file |
+---------------------+---------+-------------------+