This guide will help you get the Station application up and running.
Before starting, ensure you have:
- ✅ Node.js >= 18 installed (
node --version) - ✅ pnpm >= 8 installed (
pnpm --version) - ✅ Docker and Docker Compose installed (
docker --version&&docker-compose --version)
git clone <your-repo-url>
cd station
pnpm installImportant: Start Docker services BEFORE running the application.
# Start PostgreSQL and Redis in detached mode
docker-compose up -d
# Verify services are running
docker-compose ps
# You should see:
# - database (postgres:13) running on port 5433
# - redis (redis:7-alpine) running on port 6379Troubleshooting Docker Services:
# Check if services are healthy
docker-compose ps
# View logs if services aren't starting
docker-compose logs database
docker-compose logs redis
# Restart services if needed
docker-compose restart
# Stop and remove everything (if you need to start fresh)
docker-compose down -v
docker-compose up -dThe backend/.env file should already exist. Verify it has the correct values:
cat backend/.envExpected content:
DATABASE_HOST=localhost
DATABASE_PORT=5433
DATABASE_USER=stationDbUser
DATABASE_PASSWORD=stationDbPassword1
DATABASE_NAME=stationDb
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
REDIS_HOST=localhost
REDIS_PORT=6379
PORT=3001
APP_NAME=STATION BACKENDIf the file doesn't exist:
cp backend/.env.example backend/.envImportant: Only run migrations AFTER PostgreSQL is running.
cd backend
pnpm typeorm migration:run -d src/data-source.ts
cd ..Expected output:
Data Source has been initialized
4 migrations have been executed successfully
If you see errors:
- Make sure PostgreSQL is running:
docker-compose ps - Check PostgreSQL logs:
docker-compose logs database - Verify connection:
docker exec -it station-database-1 psql -U stationDbUser -d stationDb -c "SELECT 1"
# From the root directory
pnpm devThis starts:
- Backend: http://localhost:3001
- Frontend: http://localhost:5173
You should see output like:
backend:dev: Data Source has been initialized!
backend:dev: ✅ Redis cache connected successfully
backend:dev: 🚀 Application 'STATION BACKEND' is running on: http://localhost:3001
backend:dev: 📚 Swagger documentation available at: http://localhost:3001/api/docs
frontend:dev: ➜ Local: http://localhost:5173/
-
Check backend health:
curl http://localhost:3001
Should return:
{"success":true,"statusCode":200,"timestamp":"...","data":"Hello from Station API!"} -
Access Swagger docs: http://localhost:3001/api/docs
-
Access frontend: http://localhost:5173
-
Test registration:
- Go to http://localhost:5173
- Click "Get Started" or "Sign Up"
- Fill in the registration form
- Should successfully create an account and redirect to dashboard
Cause: Backend is not running on port 3001.
Solution:
- Check if backend is running:
curl http://localhost:3001 - If not, check if Docker services are running:
docker-compose ps - Ensure
backend/.envfile exists with correct PORT=3001 - Restart the application: Stop
pnpm dev(Ctrl+C) and run it again
Cause: PostgreSQL is not running.
Solution:
# Start Docker services
docker-compose up -d
# Verify PostgreSQL is running
docker-compose ps
# Check PostgreSQL logs
docker-compose logs databaseCause: Theme not applied correctly.
Solution: This should be fixed in the latest version. Make sure you've pulled the latest changes.
Cause: Old migration configuration.
Solution: This is already fixed in backend/src/data-source.ts with explicit migration imports.
Cause: Redis is not running.
Impact: The application will still work with in-memory caching.
Solution (optional):
# Start Redis
docker-compose up -d redis
# Verify Redis is running
docker exec -it station-redis-1 redis-cli ping
# Should return: PONGCause: API proxy not working or backend not running.
Solution:
- Verify backend is running on port 3001
- Check
frontend/vite.config.tshas correct proxy configuration - Restart frontend dev server
Backend port 3001:
# Find process using port 3001
lsof -i :3001
# Kill the process
kill -9 <PID>Frontend port 5173:
# Find process using port 5173
lsof -i :5173
# Kill the process
kill -9 <PID># View running containers
docker-compose ps
# View logs (follow mode)
docker-compose logs -f
# View specific service logs
docker-compose logs -f database
docker-compose logs -f redis
# Restart services
docker-compose restart
# Stop services
docker-compose stop
# Stop and remove containers
docker-compose down
# Stop and remove containers + volumes (complete reset)
docker-compose down -v# Access PostgreSQL shell
docker exec -it station-database-1 psql -U stationDbUser -d stationDb
# Run migrations
cd backend && pnpm typeorm migration:run -d src/data-source.ts
# Revert last migration
cd backend && pnpm typeorm migration:revert -d src/data-source.ts
# Generate new migration
cd backend && pnpm typeorm migration:generate src/migrations/MigrationName -d src/data-source.ts# Access Redis CLI
docker exec -it station-redis-1 redis-cli
# Check if Redis is responding
docker exec -it station-redis-1 redis-cli ping
# View all keys
docker exec -it station-redis-1 redis-cli KEYS '*'
# Clear all cache
docker exec -it station-redis-1 redis-cli FLUSHALL# Install dependencies
pnpm install
# Run in development mode
pnpm dev
# Build for production
pnpm build
# Run tests
pnpm test
# Lint code
pnpm lint
# Format code
pnpm format
# Type check
pnpm typecheck- Navigate to http://localhost:5173
- Click "Get Started" or navigate to /register
- Fill in:
- Username: testuser
- Email: test@example.com
- Password: Test123!@#
- Click "Register"
- Should automatically redirect to /dashboard
- Navigate to http://localhost:5173/login
- Enter credentials
- Click "Login"
- Should redirect to /dashboard
- Login and navigate to http://localhost:5173/profile
- Update profile fields (firstName, lastName, phoneNumber, bio)
- Click "Update Profile"
- Should see success message
- Navigate to http://localhost:3001/api/docs
- Click "Authorize" and enter your JWT token
- Test various endpoints
| Variable | Description | Default |
|---|---|---|
DATABASE_HOST |
PostgreSQL host | localhost |
DATABASE_PORT |
PostgreSQL port | 5433 |
DATABASE_USER |
Database user | stationDbUser |
DATABASE_PASSWORD |
Database password | stationDbPassword1 |
DATABASE_NAME |
Database name | stationDb |
JWT_SECRET |
Secret for JWT signing | (change in production) |
REDIS_HOST |
Redis host | localhost |
REDIS_PORT |
Redis port | 6379 |
PORT |
Backend server port | 3001 |
APP_NAME |
Application name | STATION BACKEND |
Create frontend/.env:
VITE_API_URL=http://localhost:3001- Frontend: 5173 (Vite dev server)
- Backend: 3001 (NestJS)
- PostgreSQL: 5433 (mapped from container's 5432)
- Redis: 6379
Migrations are explicitly imported in backend/src/data-source.ts:
CreateUsersTable1716956654528CreateOrganizationsRolesAndJunctionTable1730841000000CreateRefreshTokenTable1731715200000AddUserProfileFields1732000000000
- Organization members: 5 minutes TTL
- User permissions: 15 minutes TTL
- Fallback: Automatic in-memory cache if Redis unavailable
All API responses follow this format:
{
"success": true,
"statusCode": 200,
"timestamp": "2024-01-01T00:00:00.000Z",
"data": { ... }
}Error responses:
{
"success": false,
"statusCode": 400,
"timestamp": "2024-01-01T00:00:00.000Z",
"path": "/auth/register",
"method": "POST",
"message": "Validation failed",
"errors": [ ... ]
}Before deploying to production:
- Change JWT Secret: Update
JWT_SECRETin.envto a strong random value - Use Production Database: Configure production PostgreSQL credentials
- Use Production Redis: Configure production Redis instance
- Enable HTTPS: Configure SSL/TLS certificates
- Set NODE_ENV:
NODE_ENV=production - Review CORS: Update CORS settings for production domain
- Database Migrations: Run migrations in production:
pnpm typeorm migration:run - Build Assets: Run
pnpm buildto create optimized production builds
If you encounter issues not covered in this guide:
- Check the logs:
docker-compose logs -f - Verify all services are running:
docker-compose ps - Check backend logs in the terminal running
pnpm dev - Review the Swagger API docs: http://localhost:3001/api/docs
- Check the GitHub repository for issues
After successful setup:
- Explore the Swagger documentation
- Create test organizations and roles
- Test the permission system
- Review the codebase structure
- Read the contribution guidelines
- Start building your features!