A Go-based backend service for a music application that provides podcast management, user authentication, and search functionality using MongoDB.
- Podcast management (create, list, search)
- User authentication (login, registration)
- JWT-based authentication
- MongoDB integration
- RESTful API endpoints
- Text search capabilities
- Go 1.16 or higher
- MongoDB 4.4 or higher
- Git
-
Install MongoDB (if not already installed):
brew tap mongodb/brew && brew install mongodb-community
-
Clone the repository:
git clone <repository-url> cd music_app_go_backend
-
Install dependencies:
go mod download
-
Set up environment variables: Create a
.env
file in the root directory with the following variables:MONGODB_URI=mongodb://localhost:27017 PORT=8080 JWT_SECRET=your-secret-key
music_app_go_backend/
├── internal/
│ ├── controllers/ # HTTP handlers
│ ├── models/ # Data models
│ └── utils/ # Utility functions
│ ├── constants/ # Constants
│ ├── db/ # Database utilities
│ └── manager/ # JWT manager
├── main.go # Application entry point
└── go.mod # Go module file
POST /login
- User loginPOST /create
- User registration
GET /podcast
- List all podcastsPOST /podcast
- Create a new podcastGET /search?q={query}
- Search podcasts
GET /explore
- Get explore page content
-
Start MongoDB:
brew services start mongodb-community
-
Run the application:
go run main.go
The server will start on http://localhost:8080
by default.
curl -X POST http://localhost:8080/create \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "password123"}'
curl -X POST http://localhost:8080/login \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "password123"}'
curl -X POST http://localhost:8080/podcast \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your-jwt-token>" \
-d '{"title": "My Podcast", "description": "A great podcast"}'
curl -X GET "http://localhost:8080/search?q=podcast"
- Create new models in
internal/models/
- Add controllers in
internal/controllers/
- Update routes in
main.go
To run tests:
go test ./...
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.