Prerequisites
Before you begin, ensure you have the following installed:- Node.js 20 or higher (specified in engines)
- Docker and Docker Compose
- Git for version control
- npm package manager
Architecture Overview
Macondo Link Manager is organized as a monorepo containing:/api- Backend (Fastify + Prisma + PostgreSQL)/web- Frontend (Next.js 14 with App Router)
Quick Start with Docker
The easiest way to get started is using Docker Compose, which sets up both the database and API automatically.# Postgres
POSTGRES_DB=macondo_links
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_secure_password
DATABASE_URL=postgresql://postgres:your_secure_password@postgres:5432/macondo_links
# API Base URL
BASE_URL=http://localhost:3333
# Google OAuth
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
# JWT Secret
JWT_SECRET=generate_a_random_string_here
# Frontend URL
FRONTEND_URL=http://localhost:3000
# Environment
NODE_ENV=development
NODE_VERSION=20
PORT=3333
543233335555Manual Setup (Without Docker)
If you prefer to run services individually:Google OAuth Setup
The application uses Google OAuth for authentication with corporate domain restriction.- Development:
http://localhost:3333/auth/google/callback - Production:
https://li.mcd.ppg.br/auth/google/callback
Database Management
Prisma Studio
Access the visual database browser:http://localhost:5555.
Database Migrations
Create a new migration after schema changes:Reset Database
Environment Configuration
Backend Environment Variables
| Variable | Description | Example |
|---|---|---|
DATABASE_URL | PostgreSQL connection string | postgresql://user:pass@host:5432/db |
GOOGLE_CLIENT_ID | Google OAuth Client ID | From Google Cloud Console |
GOOGLE_CLIENT_SECRET | Google OAuth Secret | From Google Cloud Console |
JWT_SECRET | Secret for JWT token signing | Random string (use password generator) |
BASE_URL | API base URL | http://localhost:3333 |
FRONTEND_URL | Frontend URL for CORS | http://localhost:3000 |
NODE_ENV | Environment mode | development or production |
PORT | API server port | 3333 |
Frontend Environment Variables
The frontend uses Next.js and requires API configuration: Createweb/.env.local:
Troubleshooting
API fails to start with database connection error
API fails to start with database connection error
Check that PostgreSQL is running and the Common issues:
DATABASE_URL is correct:- Database container not ready (wait 5-10 seconds)
- Incorrect password or credentials
- Port 5432 already in use
Prisma Client generation fails
Prisma Client generation fails
Ensure the schema file is valid:If using Docker, rebuild the container:
Google OAuth redirect fails
Google OAuth redirect fails
Verify:
- Redirect URI matches exactly in Google Cloud Console
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETare correctFRONTEND_URLenvironment variable is set- User email domain is authorized (for internal apps)
Port already in use error
Port already in use error
Check if another service is using the port:Kill the process or change the port in your configuration.
GeoLite2 database missing
GeoLite2 database missing
The API uses MaxMind GeoLite2 for geolocation. If you see warnings:This is optional for development. To enable:
- Sign up at MaxMind
- Generate a license key
- Add to
.env:MAXMIND_LICENSE_KEY=your_key - Run:
npm run geolite:download
Available Scripts
Backend (api/)
Frontend (web/)
Next Steps
Once your development environment is set up:- Explore the API Reference for available endpoints
- Learn about Database Schema and Prisma models
- Read the Deployment Guide when ready for production
Docker Compose Reference
Thedocker-compose.yml configuration:
start.sh which:
- Installs dependencies
- Generates Prisma Client
- Waits for PostgreSQL to be ready
- Starts the development server with
ts-node
