A full-stack social network application built with Node.js, Express, TypeScript, PostgreSQL, and React.
- User authentication and authorization
- Create, read, update, and delete posts
- Like/unlike posts
- User profiles and timelines
- File upload support
- RESTful API with comprehensive endpoints
- Runtime: Node.js 18
- Framework: Express.js
- Language: TypeScript
- Database: PostgreSQL 15
- Authentication: JWT
- Security: Helmet, CORS, Rate limiting
- File Upload: Multer
- Framework: React 19
- Language: TypeScript
- Build Tool: Vite
- Styling: Tailwind CSS 4 <- NOT UNDER MY WATCH
- Routing: React Router DOM
- Tool: Bruno Collections (in
/collections)
- Docker and Docker Compose
- Node.js 18+ (for local development)
-
Clone the repository
git clone <repository-url> cd rede-social
-
Start the backend services
docker-compose up -d
This will start:
- PostgreSQL database on port
5432 - API server on port
8080(with debug port9229)
- PostgreSQL database on port
-
Start the frontend
cd app npm install npm run devThe React app will be available at
http://localhost:5173
cd api
npm install
npm run devcd app
npm install
npm run dev- Create a PostgreSQL database
- Copy
api/.env.exampletoapi/.envand configure your database connection - Run the SQL schema from
api/schema.sql
The API provides the following main endpoints:
POST /auth/register- User registrationPOST /auth/login- User loginGET /auth/me- Get current user info
GET /posts- Get timeline postsPOST /posts- Create new postGET /posts/:id- Get specific postPUT /posts/:id- Update postDELETE /posts/:id- Delete postPOST /posts/:id/like- Toggle post like
GET /users/:id- Get user profilePUT /users/:id- Update user profileGET /users/:id/posts- Get user's posts
GET /health- API health status
cd api
npm run dev # Start development server
npm run build # Build TypeScript
npm run lint # Run ESLint
npm run typecheck # Type checkingcd app
npm run dev # Start development server
npm run build # Build for production
npm run lint # Run ESLint
npm run preview # Preview production buildConfigure the following variables in api/.env:
PORT=8080
NODE_ENV=development
# Database
POSTGRES_HOST=db
POSTGRES_PORT=5432
POSTGRES_DB=social_network
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password
# JWT
JWT_SECRET=your-super-secret-jwt-key
JWT_EXPIRES_IN=86400
# CORS
ALLOWED_ORIGINS=http://localhost:3001,http://localhost:5173
# File Upload
MAX_FILE_SIZE=5242880
UPLOAD_PATH=uploadsUse the Bruno collections in the /collections directory to test the API endpoints. Import the collection into Bruno to access pre-configured requests for:
- Authentication flows
- Post management
- User operations
- Health checks
The docker-compose.yml includes:
- API Container: Node.js 18 Alpine with development hot-reload
- Database Container: PostgreSQL 15 with automatic schema initialization
- Health Checks: Built-in health monitoring for both services
- Debug Support: Remote debugging on port 9229
MIT