Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A modern full-stack todo management application built with Next.js 14, TypeScript, and PostgreSQL. Features RESTful API endpoints, Prisma ORM integration, and Docker containerization for seamless development.

Notifications You must be signed in to change notification settings

mddiosc/admin-todos

Repository files navigation

Admin Todos

A modern todo management application built with Next.js 14, TypeScript, and PostgreSQL. This project demonstrates full-stack web development with API routes, database integration, and modern React patterns.

Tech Stack

  • Framework: Next.js 14 with App Router
  • Language: TypeScript
  • Database: PostgreSQL
  • ORM: Prisma
  • Styling: Tailwind CSS
  • Validation: Yup
  • Runtime: Node.js 20.x

Features

  • ✅ Full CRUD operations for todos
  • 📊 RESTful API endpoints
  • 🗃️ Database integration with Prisma ORM
  • 🎨 Modern UI with Tailwind CSS
  • 🔧 TypeScript for type safety
  • 📦 Docker containerized database
  • 🌱 Database seeding functionality

API Endpoints

Method Endpoint Description
GET /api/todos Retrieve todos with pagination
POST /api/todos Create a new todo
PUT /api/todos/[id] Update an existing todo
DELETE /api/todos/[id] Delete a todo
GET /api/seed Seed the database with sample data

Development Setup

Prerequisites

  • Node.js 20.x
  • npm 10.x
  • Docker and Docker Compose

Installation Steps

  1. Start the database
docker compose up -d
  1. Copy environment template
cp .env.template .env
  1. Configure environment variables

⚠️ IMPORTANT: If running the app with npm run dev (outside Docker), ensure DATABASE_URL in .env uses localhost:

DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"

If running the app inside Docker, use the container name:

DATABASE_URL="postgresql://postgres:postgres@todos-db:5432/postgres"
  1. Install dependencies
npm install
  1. Setup database schema
npx prisma db push
npx prisma generate
  1. Start development server
npm run dev
  1. Seed the database (optional)

Visit http://localhost:3000/api/seed or run the endpoint to populate with sample data.

Database Schema

The application uses a simple Todo model:

model Todo {
  id          String   @id @default(uuid())
  description String
  completed   Boolean  @default(false)
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
}

Prisma Commands

npx prisma init          # Initialize Prisma (already done)
npx prisma migrate dev   # Create and apply migrations
npx prisma generate      # Generate Prisma Client
npx prisma db push       # Push schema changes to database
npx prisma studio        # Open Prisma Studio (database GUI)

Project Structure

├── prisma/
│   └── schema.prisma          # Database schema
├── src/
│   ├── app/
│   │   ├── api/
│   │   │   ├── todos/         # Todo CRUD endpoints
│   │   │   └── seed/          # Database seeding
│   │   ├── globals.css        # Global styles
│   │   ├── layout.tsx         # Root layout
│   │   └── page.tsx           # Home page
│   └── lib/
│       └── prisma.ts          # Prisma client configuration
├── docker-compose.yml         # PostgreSQL container setup
└── .env                       # Environment variables

About

A modern full-stack todo management application built with Next.js 14, TypeScript, and PostgreSQL. Features RESTful API endpoints, Prisma ORM integration, and Docker containerization for seamless development.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published