A full-stack web application for managing products with ๐ User Authentication and Authorization. โจ Built with Django | Django REST Framework for the backend and Vite | React | Tailwind CSS for the frontend. โก fully Optimized Code with Fully Responsive Desing for all devices! ๐ฅ๏ธ๐ฑ
git clone https://github.com/kevinThulnith/django-vite-react-tailwind-project.git
python -m venv venv
source venv/bin/activate # On Windows: .\venv\Scripts\activate
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver
http://localhost:8000/
cd ../frontend
npm install
VITE_API_BASE_URL=http://localhost:8000
npm run dev
http://localhost:5173/
To access the application from other devices on your local network:
Get device Ip address
Start bachend
py .\manage.py runserver <Device Ip address>:8000
Start frontend
npx vite --host {Device Ip Address}
backend/
โโโ manage.py
โโโ products/
โ โโโ models.py # Product model
โ โโโ serializers.py # Product serializer
โ โโโ views.py # Product views
โ โโโ urls.py # Product URLs
โโโ users/
โ โโโ models.py # User model
โ โโโ serializers.py # User serializer
โ โโโ views.py # User views
โ โโโ urls.py # User URLs
โโโ settings.py # Django settings
frontend/
โโโ src/
โ โโโ components/ # Reusable components
โ โโโ pages/ # Pages (Login, Register, Product List, etc.)
โ โโโ api/ # Axios API calls
โ โโโ App.jsx # Main application component
โ โโโ main.jsx # Entry point
โโโ public/ # Static assets
โโโ tailwind.config.js # Tailwind CSS configuration
Register: A new user provides credentials (e.g., username, email, password) via the frontend form.
API Call: Frontend sends a POST request to /api/user/register/
.
Backend: Creates the new user in the database.
Login: User provides login credentials.
API Call: Frontend sends a POST request to /api/token/
(Simple JWT endpoint).
Backend: Verifies credentials, generates access and refresh JWT tokens, and returns them.
Frontend: Stores the tokens (e.g., in local storage or memory) and uses the access
token in the Authorization: Bearer <token>
header for subsequent protected requests.
Protected Routes: Frontend routes/components check for a valid token before rendering. API requests to protected endpoints are validated by the backend using the token.
Logout: User clicks logout.
API Call: Frontend sends a POST request to /api/token/blacklist/
with the refresh token (optional but good practice).
Frontend: Removes tokens from storage, redirecting the user (e.g., to the login page).
python manage.py test
npm test
POST /api/user/register/
- Register a new user.POST /api/token/
- Log in and get an authentication token.POST /api/token/blacklist/
- Log out and invalidate the token.GET /api/products/all/
- Get a list of all products.POST /api/products/
- Add a new product (authenticated users only).GET /api/products/<id>/
- Get details of a specific product.PUT /api/products/update/<id>/
- Update a product (author only).DELETE /api/products/delete/<id>/
- Delete a product (author only).Contributions are welcome! Please follow these steps:
This project is licensed under the MIT License. See the LICENSE file for details. ๐ Acknowledgments
Made with โค๏ธ by Kevin Thulnith ๐ Happy coding! ๐