Skip to content

iLxgh/Bloxtek

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BloxTek Technical Challenge

This repository contains a full-stack User Authentication System built with Next.js (Frontend) and NestJS (Backend).

🚀 Quick Start (Docker)

The entire system, including the PostgreSQL database, is orchestrated using Docker Compose.

Prerequisites

  • Docker and Docker Compose installed.

Execution

Run the following command in the root directory:

docker-compose up --build

🛠️ Project Architecture

Backend (NestJS 11 + Prisma 6)

  • Framework: NestJS 11 (Modular Architecture).
  • Database: PostgreSQL 15 with Prisma ORM 6 (using @prisma/adapter-pg).
  • User Roles: Supports ADMIN and USER roles.
  • Security:
    • Password hashing with bcrypt.
    • JWT Authentication using Passport & @nestjs/jwt.
    • Global ValidationPipe.

🚀 Recent Updates (feature/auth-roles)

  • Branch renamed: Development moved to feature/auth-roles.
  • Admin registration: Fixed bug where isAdmin field was ignored by the backend.
  • Role assignment: Users can now register as ADMIN using the "Admin Mode" toggle.
  • Dashboard integration: The user's role is now visible in the secure dashboard.

Frontend (Next.js 16 + Tailwind CSS v4)

  • Framework: Next.js 16 (React 19, App Router).
  • Styling: Tailwind CSS v4 (@tailwindcss/postcss).
  • UI Components: Custom components, toast notifications with sonner.
  • State Management: React Hooks & Local Storage.
  • Authentication Flow:
    • JWT storage in localStorage.
    • Client-side route protection using HOC/Hooks (AuthGuard).
    • Automatic redirect to /login for unauthenticated access to protected routes.

💻 Local Development

If you prefer to run the components separately without Docker for the host application:

1. Database

You can start only the database using Docker:

docker-compose up -d postgres

2. Backend Setup

cd backend
npm install
# Configure .env (copy from .env.example)
npx prisma migrate dev
npm run start:dev

3. Frontend Setup

cd frontend
npm install
# Configure .env.local (copy from .env.local.example)
npm run dev

🔑 Key Environment Variables

Create .env files in both backend/ and frontend/ (or .env.local for frontend) with the following keys:

Backend (backend/.env):

DATABASE_URL="postgresql://postgres:postgres@localhost:5433/postgres?schema=public"
JWT_SECRET="super-secret-key"
JWT_EXPIRES_IN="1h"

Frontend (frontend/.env.local):

NEXT_PUBLIC_API_URL="http://localhost:3001"


❓ Troubleshooting

"Cannot find module" errors in Docker

If you see missing dependency errors in the backend logs, the Docker container might be stale. Rebuild it:

docker-compose up -d --build backend

✅ Requirements Checklist

  • Register Page
  • Login Page
  • Protected Dashboard
  • Backend API with JWT
  • Password Hashing (bcrypt)
  • Form Validations
  • Dockerization (Full Stack)
  • Documentation (README)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors