How guindani-davi/nest-auth works
Project type and purpose
• This is a server-side application built with the NestJS framework (TypeScript, Node.js).
• It provides authentication functionality and database access, using Supabase (PostgreSQL) under the hood.
• It follows a modular, monolithic-service style rather than a microservices architecture.
File structure
• Top-level files
• package.json / package-lock.json: app dependencies and scripts
• nest-cli.json, tsconfig.json / tsconfig.build.json: TypeScript and Nest build configuration
• .husky, commitlint.config.js, .secretlintrc.json: Git hooks and linting
• src/
• main.ts: bootstrap point that creates and starts the Nest application
• app.module.ts / app.controller.ts / app.service.ts: the root module and a sample controller/service
• src/auth/
• auth.module.ts, auth.controller.ts, auth.service.ts: authentication module, exposing REST endpoints and business logic
• auth.guard.ts: route-protection guard
• dtos.ts: request/response definitions (Data Transfer Objects)
• repositories/: data-access repositories (generic interface + Supabase implementation)
• src/database/
• database.service.ts: generic DB connection/provider to be injected across modules
• types.ts: shared database types/interfaces
• supabase/
• config.toml: Supabase local dev configuration
• migrations/: SQL migrations for schema evolution (e.g., users table)
Extract README insights
• Starter app from NestJS, focusing on server-side, efficiency, scalability
• Standard scripts for start, dev, prod, tests, deployment pointers
Main components
a. Clients (e.g., Postman, Browser, Mobile App)
b. HTTP API Gateway (NestJS application entrypoint)
c. Nest Modules
• AppModule
• AuthModule
• DatabaseModule
d. Controllers (AppController, AuthController)
e. Services (AppService, AuthService, DatabaseService)
f. Repository Layer
• Repository interface
• SupabaseRepository implementation
g. External Database Service
• Supabase (PostgreSQL)
h. Development Tooling / CI
• Husky Git hooks
• commitlint
• CircleCI or other CI (implied by badges, though config not shown)
i. Deployment (optional: Mau / AWS)
Relationships and interactions
• Clients → HTTP → Nest’s main.ts / AppModule
• Controller layer handles incoming routes (e.g., /auth/login)
• Controllers invoke Service methods with DTOs
• Services call Repository interfaces for data persistence
• Repository implementation uses DatabaseService to connect to Supabase
• DatabaseService wraps a Supabase client library (Pg) and runs queries/migrations
• Database migrations evolve the schema before or during startup
Architectural patterns and design principles
• Modular architecture (NestJS Modules)
• Dependency Injection (inject Controllers, Services, Repositories)
• Clean separation: Controller → Service → Repository → External DB
• Interface abstraction for Repository (allows swapping DB backends)
• Use of Guards for route protection and authorization
• Be explicit about module boundaries (Auth vs App vs Database)
• DI graph direction (inject DatabaseService into repos, repos into services, services into controllers)
• External dependencies (Supabase engine, migrations, CI/CD)
• Do not over-fragment—capture every layer but keep it readable