nerack-backend
Nerack Backend API
Personal Bookshelf Management System - Backend API built with NestJS
#Features
- Authentication & Authorization: JWT-based authentication with bcrypt password hashing
- Clean Architecture: Modular structure with feature-based organization
- API Documentation: Swagger/OpenAPI documentation
- Type Safety: Full TypeScript implementation
- Testing: Jest testing framework with unit and e2e tests
- Validation: Request/response validation with class-validator
- Configuration: Environment-based configuration management
#Quick Start
##Prerequisites
- Node.js 18+ and npm
- PostgreSQL database
##Installation
# Install dependencies
npm install
# Copy environment variables
cp .env.example .env
# Configure your database connection in .env
# DATABASE_URL="postgresql://username:password@localhost:5432/nerack_db"
# Start development server
npm run start:dev
##API Documentation
Once the server is running, visit:
- Swagger UI:
http://localhost:3000/api/docs
- API JSON:
http://localhost:3000/api/docs-json
#Available Scripts
# Development
npm run start:dev # Start with file watching
npm run start:debug # Start in debug mode
# Production
npm run build # Build the application
npm run start:prod # Start production server
# Testing
npm run test # Run unit tests
npm run test:watch # Run tests in watch mode
npm run test:cov # Run tests with coverage
npm run test:e2e # Run end-to-end tests
# Code Quality
npm run lint # Run ESLint
npm run format # Format code with Prettier
#Project Structure
src/
βββ main.ts # Application entry point
βββ app.module.ts # Root application module
βββ modules/
β βββ auth/ # Authentication module
β β βββ auth.controller.ts
β β βββ auth.service.ts
β β βββ auth.module.ts
β βββ users/ # Users module
β β βββ users.controller.ts
β β βββ users.service.ts
β β βββ users.module.ts
β βββ books/ # Books module (coming soon)
βββ common/ # Shared utilities
β βββ guards/ # Authentication guards
β βββ decorators/ # Custom decorators
β βββ filters/ # Exception filters
β βββ pipes/ # Validation pipes
βββ config/ # Configuration modules
βββ database.config.ts
#API Endpoints
##Authentication
POST /api/auth/register
- User registrationPOST /api/auth/login
- User login
##Users
GET /api/users/profile
- Get user profilePUT /api/users/profile
- Update user profile
##Books (Coming Soon)
GET /api/books
- List user's booksPOST /api/books
- Add new bookPUT /api/books/:id
- Update bookDELETE /api/books/:id
- Delete book
#Environment Variables
Variable | Description | Default |
---|---|---|
NODE_ENV | Environment mode | development |
PORT | Server port | 3000 |
DATABASE_URL | PostgreSQL connection string | Required |
JWT_SECRET | JWT secret key | Required |
JWT_EXPIRATION | JWT token expiration | 24h |
#Contributing
- Follow the existing code style and architecture
- Write tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting
#License
MIT License - see LICENSE file for details.