V1 is a RESTful API built with Node.js, Express, Docker, and Prisma ORM for managing todos with user authentication. V2 (if requested) includes Supabase, Stripe, Google Cloud, and OpenAI with Next.js set up for any deployable full stack application.
- User registration and authentication with JWT
- CRUD operations for todos
- User-specific todo management
- PostgreSQL database with Prisma ORM
- Docker containerization
- Password hashing with bcrypt
- Runtime: Node.js
- Framework: Express.js
- Database: PostgreSQL
- ORM: Prisma
- Authentication: JWT (JSON Web Tokens)
- Password Hashing: bcryptjs
- Containerization: Docker & Docker Compose
- Node.js (v18 or higher)
- Docker and Docker Compose
- Git
git clone https://github.com/jeffelin/todo_app_v1.gitCreate a .env file in the root directory:
DATABASE_URL="postgresql://postgres:password@localhost:5432/todoapp"
JWT_SECRET="your-super-secret-jwt-key-here"# Build and start all services
docker compose up --build
# Or run in detached mode
docker compose up -d --build# Install dependencies
npm install
# Generate Prisma client
npx prisma generate
# Start PostgreSQL (ensure it's running on localhost:5432)
# Run database migrations
npx prisma migrate dev
# Start the server
npm run devmodel User {
id Int @id @default(autoincrement())
username String @unique
password String
todos Todo[]
}model Todo {
id Int @id @default(autoincrement())
task String
completed Boolean @default(false)
userId Int
user User @relation(fields: [userId], references: [id])
}POST /api/auth/register- Register a new userPOST /api/auth/login- Login user
GET /api/todos- Get all todos for authenticated userPOST /api/todos- Create a new todoPUT /api/todos/:id- Update a todoDELETE /api/todos/:id- Delete a todo
curl -X POST http://localhost:5000/api/auth/register \
-H "Content-Type: application/json" \
-d '{"username": "john_doe", "password": "securepassword"}'curl -X POST http://localhost:5000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "john_doe", "password": "securepassword"}'curl -X POST http://localhost:5000/api/todos \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{"task": "Complete the project"}'The application uses Docker Compose with two services:
- app: Node.js application
- postgres-db: PostgreSQL database
- App: Runs on port 5000
- Database: PostgreSQL on port 5432
npm start- Start production servernpm run dev- Start development server with nodemonnpx prisma studio- Open Prisma database browsernpx prisma migrate dev- Run database migrationsnpx prisma generate- Generate Prisma client
backend/
├── src/
│ ├── server.js # Main application file
│ ├── prismaClient.js # Prisma client configuration
│ └── routes/ # API routes
├── prisma/
│ └── schema.prisma # Database schema
├── docker-compose.yaml # Docker services configuration
├── Dockerfile # Application container
├── package.json # Dependencies and scripts
└── .env # Environment variables
Credits to and adapted from https://github.com/jamezmca/backend-full-course.