Skip to main content

Featr Backend

A scalable backend foundation for the Featr feature request management platform built with Go, Gin-Gonic, and MongoDB.

🚀 Quick Start

Prerequisites

  • Go 1.21+
  • MongoDB 7.0+
  • Redis 7.2+ (optional, for caching)

Local Development

  1. Clone the repository
  2. Copy environment variables:
    cp .env.example .env
    
  3. Start dependencies with Docker:
    make docker-up
    
  4. Run the application:
    make run
    
The API will be available at http://localhost:8080

API Documentation

Health Check

GET /health

Authentication

GET /api/v1/auth/me              # Get current user
GET /api/v1/auth/github/callback # GitHub OAuth callback
GET /api/v1/auth/google/callback # Google OAuth callback

Projects

GET    /api/v1/projects          # Get public projects
POST   /api/v1/projects          # Create project (auth required)
GET    /api/v1/projects/my       # Get user's projects (auth required)
GET    /api/v1/projects/:id      # Get project by ID
PUT    /api/v1/projects/:id      # Update project (auth required)
DELETE /api/v1/projects/:id      # Delete project (auth required)

Feature Requests

GET    /api/v1/projects/:id/requests  # Get project requests
POST   /api/v1/projects/:id/requests  # Create request (auth required)
GET    /api/v1/requests/:id           # Get request by ID
PUT    /api/v1/requests/:id           # Update request (auth required)
DELETE /api/v1/requests/:id           # Delete request (auth required)

Voting

POST   /api/v1/requests/:id/vote      # Vote on request (auth required)
DELETE /api/v1/requests/:id/vote      # Remove vote (auth required)

Project Structure

featr-backend/
├── main.go                    # Application entry point
├── config/                    # Configuration management
├── internal/
│   ├── models/               # Data models
│   ├── repository/           # Data access layer
│   │   └── mongodb/         # MongoDB implementations
│   ├── service/             # Business logic layer
│   ├── controller/          # HTTP handlers
│   ├── middleware/          # HTTP middleware
│   └── utils/               # Utility functions
└── routes/                  # Route definitions

Architecture Principles

  • Layered Architecture: Clear separation between controllers, services, and repositories
  • Dependency Injection: Services and repositories are injected into controllers
  • Interface-Based Design: Repository interfaces allow for easy testing and database switching
  • Middleware Support: Authentication, CORS, rate limiting, and logging
  • Error Handling: Consistent error responses across all endpoints
  • Security: JWT authentication, rate limiting, and CORS protection

Environment Variables

PORT=8080
ENVIRONMENT=development
MONGO_URI=mongodb://localhost:27017
MONGO_DATABASE=featr
JWT_SECRET=your-super-secret-jwt-key
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret

Database Schema

The application uses MongoDB with the following collections:
  • users - User accounts and profiles
  • projects - Feature request projects
  • requests - Individual feature requests
  • votes - User votes on requests
  • comments - Comments on requests

Development Commands

make build        # Build the application
make run          # Run the application
make test         # Run tests
make docker-up    # Start Docker services
make docker-down  # Stop Docker services
make dev-setup    # Initial development setup

Contributing

  1. Follow Go best practices and conventions
  2. Add tests for new functionality
  3. Update documentation for API changes
  4. Use conventional commit messages

License

This project is part of the Featr feature request management platform.