Skip to content

javierlinked/fastify-prisma-monorepo

Repository files navigation

Fastify-Prisma-Monorepo

Technical Test: Node.js Developer with TypeScript, Fastify, Prisma, and Yarn Monorepo

Architecture

This monorepo contains multiple packages working together to create a complete API solution:

packages/
├── types/          # Shared TypeScript types and interfaces
├── utilities/      # Shared utility functions
├── services/       # Business logic services
└── api/           # Main Fastify API server

Tech Stack

Backend Framework

  • Fastify - Fast and efficient web framework for Node.js
  • TypeScript - Static typing for better safety and productivity
  • Zod - Schema validation and type-safe serialization

Database

  • PostgreSQL - Robust relational database
  • Prisma - Modern ORM with type-safety and migrations

Architecture & Patterns

  • TSyringe - Dependency injection with decorators
  • Monorepo - Multi-package management with Yarn Workspaces
  • Dependency Inversion - Interfaces for decoupling

Storage & Files

  • AWS S3 - Cloud file storage
  • Multipart Upload - File handling with validation

Real-time & Communication

  • WebSockets - Real-time notifications
  • JWT - Secure stateless authentication

Testing & Quality

  • Jest - Testing framework with mocks
  • Biome - Fast linting and formatting
  • Docker - Containerization for development and production

Getting Started

Prerequisites

  • Node.js >= 20.0.0
  • Yarn (for workspace management)
  • PostgreSQL database

Installation

  1. Clone the repository:
git clone https://github.com/javierlinked/fastify-prisma-monorepo
cd fastify-prisma-monorepo
  1. Install dependencies:
yarn install
  1. Set up environment variables:
cp .env.example .env
# Edit .env file with your database and AWS credentials
  1. Generate Prisma client:
yarn db:generate
  1. Run database migrations:
yarn db:migrate

Development

Start Development Server

yarn dev

This starts the API server with hot reload using tsx watch.

Build All Packages

The build process follows the correct dependency order:

yarn build

This executes:

  1. yarn build:types - Build shared types
  2. yarn build:utilities - Build utility functions
  3. yarn build:services - Build business logic services
  4. yarn build:api - Build main API server

Testing

# Run all tests
yarn test

# Run tests for specific package
yarn workspace @asafe/api test
yarn workspace @asafe/services test
yarn workspace @asafe/utilities test

Code Quality

# Check linting and format issues
yarn check

# Fix all issues
yarn fix

Database Management

# Generate Prisma client
yarn db:generate

# Run migrations
yarn db:migrate

# Open Prisma Studio
yarn db:studio

Documentation

📖 Detailed Documentation:

TODO

  • Dependency injection with TSyringe
  • Centralized environment variables
  • Singleton services with decorators
  • Interfaces for abstractions
  • File uploads to S3
  • WebSocket with JWT authentication
  • Rate limiting for APIs
  • Improve file handling in users PUT
  • Implement caching with Redis
  • Structured logging with context
  • Metrics and monitoring
  • Complete integration tests
  • Automated CI/CD pipeline

License

MIT License

About

Docker-ready with PostgreSQL database and configurable AWS S3 integration for production environments.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published