Skip to content

DrobyTech/drobytech-api-core

Repository files navigation

DrobyTech API Core

DrobyTech API Core

Production-ready NestJS backend with Prisma ORM, PostgreSQL, and Docker

PortfolioGitHubAPI Docs

🚀 Tech Stack

  • Backend: NestJS, TypeScript
  • Database: PostgreSQL with Prisma ORM
  • Authentication: JWT + Refresh Tokens (planned)
  • Validation: Zod + Class Validator
  • Documentation: Swagger/OpenAPI
  • Infrastructure: Docker, Azure App Service (planned)
  • Testing: Jest + Supertest

📁 Project Structure

src/
├── common/           # Shared utilities
│   ├── decorators/   # Custom decorators
│   ├── guards/       # Auth guards
│   ├── interceptors/ # Request/response interceptors
│   ├── filters/      # Exception filters
│   └── dtos/         # Shared DTOs
├── auth/             # Authentication module
│   ├── dto/          # Auth DTOs
│   └── strategies/   # Passport strategies
├── users/            # User management
├── projects/         # Project CRUD
├── health/           # Health check endpoint
├── prisma/           # Database service
└── config/           # Environment configuration

🛠️ Local Development

Prerequisites

  • Node.js 18+
  • Docker & Docker Compose
  • npm or yarn

Setup

  1. Clone and install dependencies

    git clone <repository-url>
    cd drobytech-api-core
    npm install
  2. Environment configuration

    cp .env.example .env
    # Edit .env with your configuration
  3. Start PostgreSQL database

    docker-compose up -d
  4. Database setup

    # Generate Prisma client
    npm run prisma:generate
    
    # Run migrations
    npm run prisma:migrate
    
    # Seed database with sample data
    npm run prisma:seed
  5. Start development server

    npm run start:dev

Available Scripts

# Development
npm run start:dev          # Start with hot reload
npm run start:debug        # Start with debugger

# Database
npm run prisma:generate    # Generate Prisma client
npm run prisma:migrate     # Run database migrations
npm run prisma:seed        # Seed database
npm run prisma:studio      # Open Prisma Studio

# Testing
npm run test               # Unit tests
npm run test:e2e           # End-to-end tests
npm run test:cov           # Test coverage

# Production
npm run build              # Build for production
npm run start:prod         # Start production server

🌐 API Endpoints

  • Health Check: GET /api/health
  • API Documentation: GET /docs (Swagger UI)
  • Authentication: POST /api/auth/* (planned)
  • Users: GET|POST|PUT|DELETE /api/users/* (planned)
  • Projects: GET|POST|PUT|DELETE /api/projects/* (planned)

🔧 Environment Variables

Variable Description Default
PORT Server port 3000
DATABASE_URL PostgreSQL connection string Required
JWT_ACCESS_SECRET JWT access token secret Required
JWT_REFRESH_SECRET JWT refresh token secret Required
JWT_ACCESS_TTL Access token TTL 15m
JWT_REFRESH_TTL Refresh token TTL 7d
NODE_ENV Environment development
CORS_ORIGINS Allowed CORS origins https://drobytech.com,https://www.drobytech.com,http://localhost:3000

🗄️ Database Schema

User Model

model User {
  id        String   @id @default(cuid())
  email     String   @unique
  password  String
  name      String?
  role      Role     @default(USER)
  projects  Project[]
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

Project Model

model Project {
  id          String   @id @default(cuid())
  title       String
  description String?
  ownerId     String
  owner       User     @relation(fields: [ownerId], references: [id])
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
}

🧪 Testing

# Run all tests
npm run test

# Run E2E tests
npm run test:e2e

# Run with coverage
npm run test:cov

🚀 Deployment

This project is designed for deployment on Azure App Service with PostgreSQL. See the deployment documentation for detailed instructions.

📚 Documentation

🤝 Contributing

This is a personal portfolio project. For questions or suggestions, please reach out via the contact information on DrobyTech.

📄 License

This project is part of the DrobyTech portfolio and is for demonstration purposes.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published