Developed by: Idarbandi - [email protected] - GitHub Profile
A simple e-commerce website developed using Django and Next.js, focused on HttpOnly authentication.
Dokoon-NextDRF is a full-stack e-commerce application demonstrating the integration of Django REST Framework (DRF) for the backend API and Next.js for the frontend. A key focus is on secure user authentication using HttpOnly cookies, enhancing protection against Cross-Site Scripting (XSS) attacks.
- ✅ User registration and authentication (login/logout) with HttpOnly cookies.
 - 🛒 Product browsing and management.
 - [Add other key features as you develop them, e.g., shopping cart, order management, etc.]
 
- 🐍 Python 3.11
 - ⚙️ Django 4.2+
 - 🌐 Django REST Framework (DRF)
 - ⚛️ Next.js 13+
 - 💾 SQLite (Development) / PostgreSQL (Production)
 - 🍪 HttpOnly cookies
 
Dokoon-NextDRF/ ├── account/ # Django app for user accounts │ ├── apps.py │ ├── init.py │ ├── models.py │ ├── tests.py │ ├── urls.py │ └── views.py ├── base/ # Django project settings and core URLs │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── frontend/ # Next.js frontend application │ ├── components/ │ │ └── header.js │ ├── next.config.mjs │ ├── pages/ │ │ ├── api/ │ │ │ └── hello.js │ │ ├── _app.js │ │ ├── category/ │ │ │ └── [slug].js │ │ ├── index.js │ │ ├── login.js │ │ ├── product/ │ │ │ └── [slug].js │ ├── README.md │ ├── src/ │ │ └── theme.js │ └── styles/ │ └── globals.css ├── requirements.txt # Backend dependencies └── store/ # Django app for store functionality ├── admin.py ├── apps.py ├── init.py ├── models.py ├── serializers.py ├── tests.py ├── urls.py └── views.py
- 
Prerequisites:
- Python 3.11
 - pip
 - Node.js (LTS recommended)
 - npm or yarn
 
 - 
Clone the repository:
git clone [invalid URL removed] cd Dokoon-NextDRF - 
Create a virtual environment (Backend):
python3 -m venv venv source venv/bin/activate # On Linux/macOS venv\Scripts\activate # On Windows
 - 
Install backend dependencies:
pip install -r requirements.txt
 - 
Install frontend dependencies:
cd frontend npm install # or yarn install
 
- Backend: Configure database settings in 
base/settings.py. SetDEBUG = Falsefor production. - Frontend: Configure environment variables if needed in the Next.js project (e.g., API URLs).
 
- 
Run the backend development server:
python manage.py runserver
The API will be available at [invalid URL removed].
 - 
Run the frontend development server:
cd frontend npm run dev # or yarn dev
The frontend will be accessible at http://localhost:3000 by default.
 
- POST /account/login/: Logs in a user.
- Request body (JSON): 
{ "username": "your_username", "password": "your_password" } - Response (JSON - Success): 
{ "اطلاعات": "کاربر با موفقیت وارد سیستم شد" }(HttpOnly cookie set) - Response (JSON - Failure - Invalid Credentials): 
{ "اطلاعات": "کاربر وجود ندارد" }(Status 400) - Response (JSON - Failure - Missing Credentials): 
{ "اطلاعات": "نام کاربری و رمز عبور الزامی هستند" }(Status 200) 
 - Request body (JSON): 
 - POST /account/logout/: Logs out a user.
- Response (JSON): 
{ "detail": "Successfully logged out" }(HttpOnly cookie cleared) 
 - Response (JSON): 
 - GET /account/whoami/: Gets the currently logged-in user's information (requires authentication).
- Response (JSON): 
{ "username": "current_username" }(Status 200 if authenticated, 403 otherwise) 
 - Response (JSON): 
 - GET /store/products/: Retrieves a list of products.
- Response (JSON): Array of product objects.
 
 
- 
Run backend tests:
python manage.py test account python manage.py test store
 - 
Run frontend tests (refer to Next.js testing documentation).
 
Contributions are welcome! Please open an issue or submit a pull request.
👤 Idarbandi - 📧 [email protected] - 🐙 GitHub Profile
