A full-stack application with NestJS API, React frontend, and PostgreSQL database.
- API: NestJS backend with TypeORM and PostgreSQL
- Web: React frontend with Vite
- Database: PostgreSQL 15 with Docker
- Containerization: Docker Compose for local development
- Docker and Docker Compose
- Node.js 18+ (for local development)
-
Clone and setup:
git clone <repository-url> cd replit-refactor
-
Start all services:
docker compose up -d
-
Access the application:
- Web App: http://localhost:5173
- API: http://localhost:3000
- PostgreSQL: localhost:5432
- Container:
replit-postgres - Database:
replit_db - User:
replit_user - Password:
replit_password - Port: 5432
- Container:
replit-api - Port: 3000
- Database URL:
postgresql://replit_user:replit_password@postgres:5432/replit_db
- Container:
replit-web - Port: 5173
- API URL:
http://localhost:3000
Start only the database:
docker compose up -d postgresStart API and database:
docker compose up -d postgres apiStart web and API:
docker compose up -d postgres api webInstall dependencies:
# API
cd api && npm install
# Web
cd web && npm installRun locally (with database running):
# Terminal 1: Start database
docker compose up -d postgres
# Terminal 2: Run API
cd api && npm run start:dev
# Terminal 3: Run web
cd web && npm run devThe PostgreSQL database is initialized with:
- A
userstable with sample data - UUID extension enabled
- Proper indexing on email field
From API:
// The DATABASE_URL environment variable is automatically set
const connectionString = process.env.DATABASE_URL;From external tools:
# Using psql
psql -h localhost -p 5432 -U replit_user -d replit_db
# Using connection string
postgresql://replit_user:replit_password@localhost:5432/replit_dbCreate a .env file in the root directory:
# Database Configuration
DATABASE_URL=postgresql://replit_user:replit_password@localhost:5432/replit_db
POSTGRES_DB=replit_db
POSTGRES_USER=replit_user
POSTGRES_PASSWORD=replit_password
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
# API Configuration
NODE_ENV=development
API_PORT=3000
# Web Configuration
VITE_API_URL=http://localhost:3000View logs:
# All services
docker compose logs
# Specific service
docker compose logs postgres
docker compose logs api
docker compose logs webStop services:
docker compose downReset database:
docker compose down -v
docker compose up -d postgresRebuild services:
docker compose up -d --build├── api/ # NestJS API
│ ├── src/
│ ├── Dockerfile
│ └── package.json
├── web/ # React frontend
│ ├── src/
│ ├── Dockerfile
│ └── package.json
├── docker-compose.yaml # Docker services configuration
├── init.sql # Database initialization
└── README.md