This is a full-stack CRUD application built with TypeScript, Next.js 14 on the frontend, and Node.js on the backend. It uses PostgreSQL as the database, with Sequelize ORM to manage data storage and queries.
- Full CRUD operations (Create, Read, Update, Delete) for managing records.
- Type-safe frontend using TypeScript.
- Fast and scalable backend with Node.js.
- PostgreSQL database with Sequelize ORM for easy data modeling and querying.
- Modern Next.js 14 features for server-side rendering and optimized static site generation.
- Responsive and user-friendly interface.
- Frontend: Next.js 14, TypeScript, React
- Backend: Node.js, Express
- Database: PostgreSQL
- ORM: Sequelize
- Others: Docker (optional), bcrypt (for password hashing), JWT (for authentication)
Make sure you have the following installed on your machine:
- Node.js (v16.x or later)
- TypeScript (v4.x or later)
- PostgreSQL (v12 or later)
- Clone this repository:
git clone https://github.com/yourusername/your-repo-name.git cd your-repo-name
- Install Dependencies:
- For the frontend:
cd client npm install
- For the backend:
cd server npm install
- For the frontend:
- Set up a new PostgreSQL database:
- Create a new PostgreSQL database:
createddb library
- Create a new PostgreSQL database:
- Configure the environment variables:
- In the
backend/
directory, create a.env
file with the following variables:POSTGRES_DB=your_db POSTGRES_HOST=your_host POSTGRES_PASSWORD=your_username POSTGRES_USER=your_username POSTGRES_PORT=8000
- In the
- Run migrations (for Sequelize ORM):
npx sequelize-cli db:migrate npx sequelize-cli db:migrate:undo
- Start the backend:
cd server npm start
- Start the frontend:
cd client npm run dev
- Access the application in your browser:
- Frontend: http://localhost:3000
- Backend API: http:localhost:5000
/client
/src
/app
/components
/schemas
.dockerignore
Dockerfile
next.config.js
tsconfig.json
package.json
/server
/config
/controllers
/migrations
/models
/routes
/seeders
.dockerignore
Dockerfile
index.js
package.json
docker-compose.yaml
- /server: Contains all backend-related files (models, controllers, routes, etc.).
- /client: Contains the Next.js frontend code (pages, components, styles, etc.).
- POST
/api/books
– Get all books available. - GET
/api/books/genres
– Get all genres of the available books. - POST
/api/books
– Add a new book. - PUT
/api/books/:id
– Update a book by id. - DELETE
/api/books/:id
– Delete a book by id. - GET
/api/books/search
– Filter books by author or title. - GET
/api/books/filter
– Filter books by genre.
If you prefer to run the application with Docker, follow these steps:
- Build the Docker images:
docker-compose build
- Start the application with Docker:
docker-compose up
This will spin up both the frontend and backend, along with the PostgreSQL database container.