Skip to content

πŸ’» An simple API for user management and authentication, built with NestJS, Docker, Prisma, and PostgreSQL .

Notifications You must be signed in to change notification settings

arthurlbo/user-management-api

Repository files navigation

Hi there! πŸ‘‹

The User Management API is designed to provide robust user authentication and management functionalities. This API enables users to perform essential operations such as registration, login, password recovery, etc. Additionally, it includes an admin-only CRUD for managing user accounts.

The primary goal of this project was to enhance backend development skills by implementing a comprehensive user management system. This includes sophisticated authentication mechanisms and administrative capabilities to manage users effectively. The combination of NestJS, Docker, Prisma and PostgreSQL ensures a modern, scalable, and maintainable solution.

Also there is a branch using TypeORM and MySQL instead Prisma and PostgreSQL, just for learning purposes. you can check it out here.

Tech Stack

Key Features

User Authentication

  • Registration
  • Login
  • Avatar Upload
  • Update Completely
  • Update Partially
  • Password Recovery

Admin CRUD

  • Register User
  • Read All Users
  • Read User
  • Update User Completely
  • Update User Partially
  • Delete User

Getting Started

Make sure you have Docker installed on your machine.

# Run database container
docker compose -f docker-compose.dev.yml up -d

# Install dependencies
pnpm install

# Apply migration and generate prisma client
pnpm p-mg

# Start the development server
pnpm dev

API will be running on http://localhost:3000

Structure

β”œβ”€β”€ .husky
└── .vscode
└── prisma
└── src
    β”œβ”€β”€ auth
    β”œβ”€β”€ common
    β”œβ”€β”€ decorators
    β”œβ”€β”€ env
    β”œβ”€β”€ file
    β”œβ”€β”€ guards
    β”œβ”€β”€ interceptors
    β”œβ”€β”€ prisma
    β”œβ”€β”€ system
    β”œβ”€β”€ templates
    β”œβ”€β”€ test
    β”œβ”€β”€ user
Folder Description
.husky Git hooks managed by Husky.
.vscode VSCode settings .
prisma Prisma config such as schema, migrations and seed.
auth Auth related files to manage user authentication.
common Reusable utilities and constants.
decorators Custom decorators.
env Env related files to manage environment variables.
file File related files to manage file operations.
guards Custom guards.
interceptors Custom interceptors.
prisma Prisma service to interact with the database.
system System related files to manage system operations.
templates Email templates.
test Test related files.
user User related files to manage user operations.

Custom Commands

# Run all tests
pnpm test:all

# Run prisma generate
pnpm p-gen

# Run prisma migrate
pnpm p-mg

# Run prisma migrate reset
pnpm p-mg-reset

# Run prisma seed
pnpm p-seed

# Set environment to production
pnpm env:prod

# Set environment to development
pnpm env:dev

# Set environment to test
pnpm env:test

# Run prisma migrate in production environment
pnpm p-mg:prod

# Run prisma migrate in development environment
pnpm p-mg:dev

# Run prisma migrate in test environment
pnpm p-mg:test

# Run prisma migrate reset in development environment
pnpm p-mg-reset:dev

# Run prisma migrate reset in test environment
pnpm p-mg-reset:test

# Run prisma seed in production environment
pnpm p-seed:prod

# Run prisma seed in development environment
pnpm p-seed:dev

# Run prisma seed in test environment
pnpm p-seed:test

# Commit staged changes
pnpm commit

Made with 🀍 by Arthur