A Go-based backend application with WebSocket support, PostgreSQL database, and JWT authentication.
- HTTP action API with Fiber v3
- WebSocket support using Socket.IO
- PostgreSQL database with GORM ORM
- JWT authentication for secure API access
- CORS support for cross-origin requests
- Static file serving
- Environment configuration with dotenv
- Go 1.26.3 or higher
- PostgreSQL 15+ with PostGIS extension
- Git
git clone <repository-url>
cd coreUbuntu/Debian:
sudo apt-get install postgresql-15-postgis-3
# or for PostgreSQL 17
sudo apt install postgis postgresql-17-postgis-3macOS:
brew install postgresql postgisbrew install golangci-lintcp env.sample .env
# Edit .env with your database credentials and other settings
# USER_JWT_SECRET is required and must be at least 32 bytes.
# Generate one with: openssl rand -base64 48User JWT validation is fail-closed (HS256, issuer/subject/identity and temporal
claims are required) with 30 seconds of clock-skew tolerance. Tokens issued by
older builds without iat/nbf claims are intentionally rejected, so users
must sign in again after deploying this change. Rotate USER_JWT_SECRET through
your secret manager; never commit it to the repository.
go mod downloadRun migrations and seed data together on first install:
./start.sh -installRun migration or seed independently when needed:
./start.sh -migrateThe migration also installs required report-kind reference data and the database constraints used by atomic location/engagement writes.
./start.sh -seedStart the server:
./start.shThe launcher fingerprints the Go source tree, builds an optimized native
binary only when it changes, applies idempotent database migrations, and then
executes the cached binary. Set AUTO_MIGRATE=false only when migrations are
managed by a separate deployment job.
Grant moderation access to an existing, usable account by public ID:
./start.sh -grant-admin 123456789
./start.sh -grant-moderator 987654321golangci-lint run ./...Dependency wiring is maintained manually in infrastructure/bootstrap/bootstrap.go.
go test -race -cover ./...go test ./...core/
βββ adapters/inbound/ # Fiber HTTP and MCP input adapters
βββ application/
β βββ ports/ # Repository and external-system boundaries
β βββ types/ # Persistence-free application DTOs
β βββ legacyviews/ # Quarantined legacy response projections
β βββ usecases/ # Application orchestration
βββ domain/ # Framework-independent business rules
βββ infrastructure/
β βββ bootstrap/ # Composition root
β βββ repositories/ # GORM outbound adapters
β βββ ... # Auth, media, GeoIP, socket and other adapters
βββ models/ # Legacy GORM/schema compatibility boundary
βββ workers/ # Background processors
βββ static/ # Static files served by the application
βββ main.go # Process lifecycle and maintenance commands
βββ go.mod
The enforced dependency direction and remaining migration debt are documented
in docs/ddd-audit.md.
GET /- Home endpointPOST /packet- Main packet handler for authentication and other actionsGET /static/*- Static file serving
The application uses JWT tokens for authentication. Include the token in the Authorization header:
Authorization: Bearer <your-jwt-token>
Only HS256 user tokens with the expected issuer/subject and complete time
claims are accepted. Startup fails closed when USER_JWT_SECRET is missing or
shorter than 32 bytes.
WebSocket server runs alongside the HTTP server and handles real-time communication.
To run the application in development mode:
./start.shThe server will start on the port specified in your .env file.
File uploads have no application-level size limit. Large multipart files are
spooled to temporary files instead of being retained entirely in memory.
Private and chat upload URLs require an authorized bearer token.
If a reverse proxy or ingress is used, its request-body limit must also be
disabled; that limit is outside this process. Configure TRUSTED_PROXIES with
an explicit comma-separated proxy IP/CIDR allowlist before relying on forwarded
client IP headers.
For an Nginx API location, disable both the byte cap and request buffering so the body can flow through to Fiber's disk-backed multipart parser:
client_max_body_size 0;
proxy_request_buffering off;Private-photo album/batch item counts remain domain cardinality rules; they do not inspect or cap the number of bytes in an uploaded file.
- Fiberv3 - HTTP router and URL matcher
- GORM - ORM library for Go
- PostgreSQL Driver - Database driver for PostgreSQL
- Socket.IO - WebSocket library
- JWT - JSON Web Token implementation
- CORS - Cross-Origin Resource Sharing middleware
This project is free to use, open for everyone, and can be developed by anyone.
brew update
brew install postgresql
brew install postgis
brew services start postgresql
brew services list
brew services start postgresql
psql postgres
ALTER ROLE postgres WITH PASSWORD 'yourownpassword';
brew services restart postgresqlserver { listen 80; server_name socket.coolvibes.lgbt socket.coolvibes.app socket.coolvibes.io;
location /socket.io/ {
proxy_pass http://127.0.0.1:3002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
location /health {
return 200 "OK";
}
}
sudo systemctl reload nginx
Test:
go test ./...