Overview
ARCA is built as a modern full-stack application using a monorepo architecture managed by Turborepo. The system consists of a NestJS backend API and a Next.js frontend application, both written in TypeScript.Monorepo Structure
The project uses npm workspaces and Turborepo for efficient monorepo management:Turborepo Configuration
Theturbo.json defines pipeline tasks for building, linting, and development:
The
dev task runs with cache: false and persistent: true to ensure live-reload functionality during development.Workspace Scripts
Root-level scripts orchestrate both applications:Backend Architecture
The backend is built with NestJS, a progressive Node.js framework that provides a robust architecture for building scalable server-side applications.Technology Stack
NestJS
Framework for building efficient, scalable Node.js server-side applications
Prisma ORM
Next-generation ORM for type-safe database access
PostgreSQL
Robust relational database for data persistence
JWT Authentication
Secure token-based authentication with Passport.js
Directory Structure
Module Architecture
NestJS follows a modular architecture pattern. The main modules are:App Module
The root module that imports all feature modules:Authentication Flow
- Local Strategy: Validates username/password credentials
- JWT Strategy: Validates JWT tokens for protected routes
- Guards:
JwtAuthGuardprotects routes requiring authentication - Password Hashing: Uses bcrypt for secure password storage
Prisma Integration
ThePrismaService extends PrismaClient and is used as a global module:
- Handles database connections
- Provides type-safe database queries
- Manages transactions and migrations
API Configuration
Themain.ts file configures:
The backend runs on port 3333 by default and accepts requests from the frontend on port 3000.
Frontend Architecture
The frontend is built with Next.js 15 using the App Router and React Server Components.Technology Stack
Next.js 15
React framework with App Router and Server Components
React 19
Latest React with improved performance
TailwindCSS 4
Utility-first CSS framework for styling
NextAuth.js
Authentication for Next.js applications
Directory Structure
UI Component Library
ARCA uses shadcn/ui for component primitives:- Built on Radix UI primitives
- Fully customizable with TailwindCSS
- Includes: Avatar, Dialog, Dropdown, Select, Tooltip, and more
- Form handling with React Hook Form and Zod validation
State Management
- Server Components: For data fetching on the server
- Client Components: For interactive UI with
"use client" - React Hook Form: Form state management
- Axios: HTTP client for API requests
Authentication Flow
- NextAuth.js handles authentication on the frontend
- Credentials provider connects to the backend
/auth/loginendpoint - JWT tokens stored in secure HTTP-only cookies
- Middleware protects routes requiring authentication
- Session data available via
useSession()hook
Backend-Frontend Communication
API Integration
The frontend communicates with the backend via REST API:Authentication
NextAuth sends credentials to backend
/auth/loginBackend validates and returns JWT tokenAPI Endpoints
Example endpoint structure:| Endpoint | Method | Description |
|---|---|---|
/auth/login | POST | User authentication |
/users | GET | List all users |
/users/:id | GET | Get user by ID |
/waitlist | GET | Get waitlist entries |
/waitlist | POST | Create waitlist entry |
CORS Configuration
The backend CORS is configured to accept requests from:- Development:
http://localhost:3000 - Production: Configured via
CORS_ORIGINenvironment variable
Development Workflow
Running the Application
Database Management
Code Quality
Deployment Architecture
Frontend Deployment
Deploy to Vercel for automatic CI/CD and edge optimization
Backend Deployment
Deploy to Railway, Heroku, or containerize with Docker
Database
PostgreSQL on Supabase, Neon, or Railway
Environment Variables
Manage secrets per environment (dev, staging, production)
Environment Variables
- Backend
- Frontend
.env
Key Design Decisions
Why Monorepo?
Why Monorepo?
- Code Sharing: Easy to share types between frontend and backend
- Atomic Commits: Changes across apps can be committed together
- Simplified Dependency Management: One
node_modulesfor shared deps - Consistent Tooling: Shared ESLint, Prettier, TypeScript configs
Why NestJS?
Why NestJS?
- TypeScript-First: Strong typing and modern JavaScript features
- Modular Architecture: Clean separation of concerns
- Dependency Injection: Testable and maintainable code
- Extensive Ecosystem: Built-in support for Swagger, GraphQL, WebSockets
Why Next.js App Router?
Why Next.js App Router?
- Server Components: Reduced client-side JavaScript
- Streaming: Better performance with progressive rendering
- Built-in Routing: File-system based routing
- API Routes: Backend-for-frontend pattern support
Why Prisma?
Why Prisma?
- Type Safety: Auto-generated types from schema
- Developer Experience: Intuitive query API
- Migration Management: Version-controlled schema changes
- Prisma Studio: Visual database browser