A RESTful API built with Go and Gin framework for managing events and attendees.
- User Authentication: JWT-based authentication system with user registration and login
- Event Management: Full CRUD operations for events with owner-based permissions
- Attendee Management: Add, remove, and list attendees for events
- Database Integration: SQLite database with migration support
- API Documentation: Swagger/OpenAPI documentation for all endpoints
- Test Coverage: Comprehensive test suite
├── cmd/
│ ├── api/ # API handlers and server setup
│ │ ├── auth.go # Authentication handlers
│ │ ├── events.go # Event and attendee handlers
│ │ ├── main.go # Application entry point
│ │ ├── routes.go # Route definitions
│ │ └── server.go # Server configuration
│ └── migrate/ # Database migrations
├── internal/
│ ├── database/ # Database models and operations
│ └── env/ # Environment configuration
├── tests/ # Test suite
└── docs/ # Swagger documentation
make dev # Run tests then start development server
make run # Run tests then start server
make build # Run tests then build applicationmake test # Run all tests
make test-coverage # Run tests with coverage report
make test-unit # Run unit tests onlymake format # Format code
make lint # Lint code
make swagger # Generate Swagger documentationmake migrate-up # Run database migrations
make clean # Clean build artifacts and databaseThe API uses JWT (JSON Web Tokens) for authentication. After successful login, include the token in the Authorization header:
Authorization: Bearer <your_jwt_token>
Protected endpoints require valid authentication and will return 401 Unauthorized if the token is missing or invalid.
- Clone the repository
- Install dependencies:
make deps - Run migrations:
make migrate-up - Start the development server:
make dev - View API documentation at
/swagger/index.html
The API will be available at http://localhost:4000 by default (you can edit the port & the JWT secret via the PORT and JWT_SECRET environment variables).
The project includes comprehensive tests covering database models and business logic. Tests use an in-memory SQLite database for isolation and speed.
Run the test suite:
make testGenerate coverage report:
make test-coverage