A full-stack web application for creating, reading, and deleting personal notes. Users register, log in with JWT authentication, and manage their notes securely.
- User Authentication: Register new accounts and log in with secure JWT (JSON Web Token) authentication.
- Create Notes: Add notes with a title and content after logging in.
- View Notes: See all your personal notes displayed on the home page.
- Delete Notes: Remove notes you no longer need.
- Protected Routes: Unauthenticated users are automatically redirected to the login page.
- Framework: React with Vite build tool
- Routing: React Router for page navigation
- API Client: Axios with JWT token management
- Pages: Login, Register, Home (notes list), 404 Not Found
- Components: Protected Route, Loading Indicator, Form, Note Card
- Framework: Django with Django REST Framework (DRF)
- Authentication: JWT via
djangorestframework-simplejwt - Database: SQLite (development)
- API Endpoints:
POST /api/user/register/– Create new userPOST /api/token/– Login (get access & refresh tokens)POST /api/token/refresh/– Refresh access tokenGET /api/notes/– List user's notesPOST /api/notes/– Create a new noteDELETE /api/notes/delete/<id>/– Delete a note
- Python 3.8+ (for backend)
- Node.js 16+ (for frontend)
- Git
git clone https://github.com/worlldboy/notes.git
cd notesNavigate to the backend folder:
cd backendCreate and activate a virtual environment:
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activateInstall dependencies:
pip install -r requirements.txtApply database migrations:
python manage.py migrateStart the Django development server:
python manage.py runserverThe backend will run on http://127.0.0.1:8000
In a new terminal, navigate to the frontend folder:
cd frontendInstall dependencies:
npm installStart the development server:
npm run devThe frontend will run on http://localhost:5173 (or another port if 5173 is busy).
Open your browser and go to the frontend URL (e.g., http://localhost:5173).
- Register: Click "Register" to create a new account with a username and password.
- Login: Use your credentials to log in.
- Create a Note: On the home page, fill in the title and content, then click "Submit".
- View Notes: Your notes appear on the home page after creation.
- Delete a Note: Click the delete button on a note to remove it.
- Logout: Click "Logout" to return to the login page.
React_django/
├── backend/
│ ├── api/
│ │ ├── models.py # Note model
│ │ ├── serializers.py # API serializers
│ │ ├── views.py # API views (CRUD)
│ │ ├── urls.py # API endpoints
│ │ └── migrations/ # Database migrations
│ ├── backend/
│ │ ├── settings.py # Django settings
│ │ ├── urls.py # Root URL config
│ │ └── wsgi.py # WSGI app
│ ├── manage.py # Django CLI
│ └── requirements.txt # Python dependencies
│
├── frontend/
│ ├── src/
│ │ ├── pages/ # Page components (Login, Register, Home, NotFound)
│ │ ├── components/ # Reusable components (Form, ProtectedRoute, etc.)
│ │ ├── styles/ # CSS files
│ │ ├── api.js # Axios API client
│ │ ├── constants.js # Token key constants
│ │ └── App.jsx # Main app component
│ ├── index.html
│ ├── package.json # Node dependencies
│ └── vite.config.js # Vite configuration
- User registers with username and password → Backend creates user
- User logs in → Backend returns
accesstoken andrefreshtoken (stored in localStorage) - Frontend adds
Authorization: Bearer <access_token>header to all API requests - If token expires, the app automatically refreshes it using the refresh token
- If refresh fails, user is redirected to login
Add a new note field (e.g., tags):
- Update
backend/api/models.py– add field toNotemodel - Run
python manage.py makemigrations api && python manage.py migrate - Update
backend/api/serializers.py– add field toNoteSerializer.Meta.fields - Update
frontend/src/pages/home.jsx– add input for the new field - Update
frontend/src/components/Note.jsx– display the new field
Change API URL:
- Update
frontend/.env– changeVITE_API_URLto your backend URL
- Django
- djangorestframework
- djangorestframework-simplejwt
- django-cors-headers
- python-dotenv
- React
- React Router
- Axios
- Vite
"Forbidden (403)" on API requests:
- Ensure you're logged in and have a valid access token in localStorage
- Check that the
Authorizationheader is being sent (DevTools → Network)
CORS errors:
- Verify
CORS_ALLOW_ALL_ORIGINS = Trueinbackend/backend/settings.py(for development only)
Blank home page:
- Check browser console for errors
- Verify the backend is running and accessible
Port already in use:
- Backend:
python manage.py runserver 8001(use different port) - Frontend:
npm run dev -- --port 5174(use different port)
This project is open source and available under the MIT License.
- Fork the repository
- Create a feature branch (
git checkout -b feature/YourFeature) - Commit your changes (
git commit -m 'Add YourFeature') - Push to the branch (
git push origin feature/YourFeature) - Open a Pull Request
Happy coding! 🎉