This is a NestJS + TypeScript backend project using TypeORM and PostgreSQL.
I built this API for an admin/user panel with JWT authentication, refresh token rotation, role-based authorization, and a ticketing system.
The project includes Swagger documentation for testing and exploring all API endpoints.
Users can authenticate, refresh expired access tokens, manage their profile, create tickets, and interact with related entities such as city and state.
The authentication system stores refresh tokens in the database and automatically removes expired tokens.
I also implemented custom guards, decorators, audit logging, and reusable query utilities for pagination, ordering, and searching.
- JWT Authentication
- Refresh Token Rotation
- Automatic Expired Token Cleanup
- User CRUD
- Ticket & Message System
- Role-Based Authorization
- Custom Guards & Decorators
- Audit Interceptor
- Pagination / Search / Ordering
- Swagger API Documentation
- User
- RefreshToken
- Ticket
- Message
- City
- State
The project uses access token + refresh token authentication.
After login:
- Access token is generated
- Refresh token is stored in database
- Tokens are returned to client
When access token expires:
- Client sends refresh token
- Token is validated
- New access token is issued
Expired refresh tokens are automatically deleted.
src
├── audit
├── common
│ └── query
├── decorator
├── entity
├── guard
├── interceptors
└── modules
├── auth
├── users
├── ticket
└── address
- NestJS
- TypeScript
- TypeORM
- PostgreSQL
- Passport JWT
- Swagger
- Class Validator
Create a .env file:
PORT=3000
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=your_password
DB_NAME=shadcn_panel
JWT_SECRET=your_jwt_secretCreate the PostgreSQL database:
CREATE DATABASE shadcn_panel;After running the project:
http://localhost:3000/api- Clone the repository:
git clone https://github.com/mandanaD/shadcn-panel-api.git- Install dependencies:
npm install- Run development server:
npm run start:dev- Open:
http://localhost:3000