Skip to content

🌈 Robust backend infrastructure for a privacy-focused, scalable, and inclusive LGBTIQ social media platform. Designed to foster genuine human connections in a safe and respectful environment.

Notifications You must be signed in to change notification settings

CoolVibesLGBT/core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

66 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CoolVibes Core

A Go-based backend application with WebSocket support, PostgreSQL database, and JWT authentication.

Features

  • RESTful API with Gorilla Mux router
  • 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

Prerequisites

  • Go 1.23.0 or higher
  • PostgreSQL 15+ with PostGIS extension
  • Git

Installation

1. Clone the repository

git clone <repository-url>
cd core

2. Install PostgreSQL and PostGIS

Ubuntu/Debian:

sudo apt-get install postgresql-15-postgis-3
# or for PostgreSQL 17
sudo apt install postgis postgresql-17-postgis-3

macOS:

brew install postgresql postgis

3. Set up environment variables

cp env.sample .env
# Edit .env with your database credentials and other settings

4. Install Go dependencies

go mod download

5. Run database migrations

go run main.go
go run main.go -migrate
go run main.go -seed

Project Structure

core/
β”œβ”€β”€ constants/          # Application constants and error definitions
β”œβ”€β”€ models/            # Data models
β”œβ”€β”€ routes/            # HTTP route handlers and middleware
β”œβ”€β”€ services/          # Business logic and external services
β”‚   β”œβ”€β”€ db/           # Database operations and repositories
β”‚   └── socket/       # WebSocket server implementation
β”œβ”€β”€ static/           # Static files served by the application
β”œβ”€β”€ types/            # Custom type definitions
β”œβ”€β”€ utils/            # Utility functions and helpers
β”œβ”€β”€ main.go           # Application entry point
└── go.mod            # Go module dependencies

API Endpoints

  • GET / - Home endpoint
  • POST /packet - Main packet handler for authentication and other actions
  • GET /static/* - Static file serving

Authentication

The application uses JWT tokens for authentication. Include the token in the Authorization header:

Authorization: <your-jwt-token>

WebSocket

WebSocket server runs alongside the HTTP server and handles real-time communication.

Development

To run the application in development mode:

go run main.go

The server will start on the port specified in your .env file.

Dependencies

  • Gorilla Mux - 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

Known Errors

  • Chats.go PinnedMsg *Message gorm:"foreignKey:PinnedMsgID;references:ID"

License

[Add your license information here]

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 'TestTest!1453!';

brew services restart postgresql

Installation

server { 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

About

🌈 Robust backend infrastructure for a privacy-focused, scalable, and inclusive LGBTIQ social media platform. Designed to foster genuine human connections in a safe and respectful environment.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages