Architecture

Architecture

Clean architecture with clear separation of concerns.

Layer Structure

1

Routes

Define endpoints and attach middleware

2

Controllers

Handle HTTP requests, validate input, send responses

3

Services

Business logic and domain rules

4

Repositories

Data access layer with Prisma

Folder Structure

backend/
├── src/
│   ├── config/         # Configuration files
│   ├── controllers/    # Request handlers
│   ├── services/       # Business logic
│   ├── repositories/   # Data access
│   ├── middlewares/    # Auth, RBAC, validation
│   ├── routes/         # API routes
│   ├── utils/          # Helpers & utilities
│   └── validators/     # Zod schemas
├── prisma/
│   ├── schema.prisma   # Database schema
│   └── seed.ts         # Seed data
└── tests/              # Test suites

Tech Stack

Fastify

Framework

TypeScript

Language

Prisma

ORM

PostgreSQL

Database

JWT

Auth

bcrypt

Hashing

Zod

Validation

Pino

Logging

Database Schema

usersuser_profilesrefresh_tokensemail_verificationspassword_resetspassword_historiesrolesuser_rolestwo_factor_authsessionsaudit_logsnotifications