A todo management application built with Node.js, Express, Prisma, PostgreSQL and Supabase. The project combines a RESTful backend with server-rendered views and a polished frontend experience for creating, editing, viewing, and managing todos.
This application allows users to:
- register and log in securely
- manage personal todo items
- create, edit, delete, and view tasks
- use a protected dashboard backed by authentication middleware
- interact with the app through HTML views and API endpoints
The project is structured as a backend-focused web application with clear separation between routes, controllers, views, and database access.
- User authentication and session handling
- JWT-based access control
- Refresh-token awareness through cookies and server-side session records
- CRUD operations for todos
- Protected dashboard and create/edit flows
- Prisma ORM integration with PostgreSQL
- Responsive UI with shared styling and status-based badges
- Node.js
- Express.js
- JavaScript (ES Modules)
- JWT (jsonwebtoken)
- Cookie parsing for browser cookie handling
- Prisma ORM
- PostgreSQL
- Supabase for PostgreSQL database integration
- HTML5
- CSS3
- Vanilla JavaScript
- EJS templates for edit view rendering
src/
|____ app.js
|
|____ config/
| |_____ config.js
|
|____ controllers/
| |
| |_____ controller.auth.js
| |_____ controller.todo.js
|
|____ routes/
| |_____ route.auth.js
| |_____ route.todo.js
| |_____ route.view.js
|
views/
|____ create.html
|____ dashboard.html
|____ edit.ejs
|____ login.html
|____ register.html
|
public/
|____ css/
| |_____ style.css
|____ js/
| |_____ dashboard.js
|
prisma/
|____ schema.prisma
|____ migrations/
|
database/
|____ db.config.js
The application uses Prisma with a PostgreSQL datasource and the following main models:
- User
- stores account data such as username, email, password hash, and with built-in id assigned by supabase
- Session
- tracks user sessions and state (by revoking access: true/false)
- Todo
- stores task information such as title, description, status, and timestamps (created_At/ updated_At)
Userhas unique username and email fieldsSessionstores session metadata and revocation stateTodouses an enumTaskStatuswith values:TODOIN_PROGRESSDONE
This project demonstrates several core backend development concepts:
- RESTful API design
- Route-based architecture
- Middleware-driven authentication and authorization
- JWT-based stateless authentication
- Cookie-based session persistence
- CRUD operations with a relational database
- ORM-based data access using Prisma
- Server-side rendering with EJS
- Environment-based configuration
- Error handling for invalid credentials, missing sessions, and unauthorized access
POST /api/auth/register– creates a new user accountPOST /api/auth/login– authenticates a user and creates a sessionGET /api/auth/refresh– refreshes the authentication contextGET /api/auth/logout– logs the user out and invalidates the session
POST /api/todo/create– creates a new todo itemGET /api/todo/dashboard– fetches todos for the authenticated userGET /api/todo/delete/:id– deletes a todo itemGET /api/todo/edit/:id– renders the edit page for a todo itemPOST /api/todo/edit-todo/:id– updates a todo item
GET /register– registration pageGET /login– login pageGET /create– protected create pageGET /dashboard– protected dashboard page
The authentication system uses a combination of:
- user credentials validation
- password hashing before storage
- JWT tokens for identity verification
- cookies for token transport
- session records in the database for traceability and invalidation
This provides a practical foundation for secure user access and protected resource handling.
- Node.js (recommended latest LTS)
- PostgreSQL local database ( using pgAdmin 4 or Supabase )
- npm or pnpm
- Clone the repository
- Install dependencies:
npm install- Create a
.envfile in the project root with the following variables:
PORT=3000
JWT_SECRET=your_super_secret_key
DATABASE_URL=postgresql://username:password@localhost:5432/todo_db (or supabase DB link)- Run Prisma migrations:
npx prisma migrate dev- Start the development server:
npm run devThe application will be available at:
http://localhost:3000/register
- The app uses Express middleware for request parsing, cookie handling, and static file serving.
- The frontend is intentionally lightweight and uses vanilla JavaScript for interactions.
- Used AI for styling and it may be very simple or too familier due to that reason, the core focus was over backend development
- The codebase follows a simple controller-based structure for maintainability.
Possible enhancements for the project include:
- role-based access control
- email verification
- password reset functionality
- better frontend state management
- API response standardization
The refresh token route is still under development so you may face direct json responses instead of any UI, if the Access Token has expired because it stays valid for just 15 minutes due to security reasons. Please do not mind pressing back button of your browser 🙏
This project is currently licensed under ISC. Project Link: Click here