Gopher Login is a high-performance API for authentication and identity management, built with a focus on Clean Architecture and Dependency Injection. This project was developed as a robust backend-first foundation to support future frontend interfaces, prioritizing decoupling and testability.
Disclaimer: This project is for strictly educational purposes. Although it implements industry standards, a full security audit is recommended before any use in production environments.
- Stateless Authentication: JWT (JSON Web Tokens) implementation for secure and scalable sessions.
- Security First: Password hashing using
bcrypt(viago-hasher) and route protection through Guard Middleware. - Consumer Management: Complete registration, login, and profile retrieval (
/me) flows. - Resilience & Performance: Native rate limiting and configurable context-level timeouts.
- Observability: Integration with
slogandLogbullfor structured event and error tracking.
| Component | Technology |
|---|---|
| Runtime | Go 1.25.5 |
| Web Framework | Fiber v3 |
| Dependency Injection | Uber Fx |
| Persistence (ORM) | Bun (PostgreSQL) |
| Validation | Go-Playground Validator v10 |
| Logging | Slog + Logbull Adapter |
The organization follows Clean Architecture principles:
cmd/: Application entry point.internal/api/core/domain/: Enterprise business entities.internal/api/core/service/: Business logic and use cases.internal/api/in/rest/: Input adapters (Fiber Handlers and Middlewares).internal/api/out/database/: Output adapters (Persistence with Bun).internal/api/platform/: Cross-cutting tools (Token generation, Validation).
The project uses rickferrdev/dotenv. Create a .env file in the root directory based on .env.example:
GOPHER_SERVER_PORT=8080
GOPHER_SERVER_JWT_SECRET=your_super_protected_secret
GOPHER_POSTGRES_URL=postgres://user:pass@localhost:5437/dbname?sslmode=disable
GOPHER_POSTGRES_USER=user
GOPHER_POSTGRES_PASSWORD=pass
GOPHER_POSTGRES_PORT=5437
GOPHER_POSTGRES_DB=dbname
GOPHER_LOGBULL_PROJECT_ID=your_project_id
GOPHER_LOGBULL_HOST=http://localhost:4005The repository includes a Compose file to spin up the database and the logging ecosystem. Run the following command:
docker compose -f docker/compose.yml up -dgo mod tidy
go run cmd/main.goThis repository is ready to use with VS Code Dev Containers. When you open the project, VS Code will suggest reopening it in a container, which already includes the configured Go 1.25 environment and necessary Docker extensions.
| Method | Route | Description | Access |
|---|---|---|---|
POST |
/api/v1/auth/register |
New user registration | Public |
POST |
/api/v1/auth/login |
Login and Token generation | Public |
| Method | Route | Description | Access |
|---|---|---|---|
GET |
/api/v1/consumers/me |
Logged-in user data | Private |
GET |
/api/v1/consumers/:username |
Search by username | Private |
- Expand Unit and Integration Test coverage (Initial tests set up using GoMock & Testify).
- Support for Refresh Tokens.
- Redis integration for Session Caching.
- Frontend: Development of a SPA (React/Next.js) to consume this API.
Developed by Rickferrdev
Contributions are what make the open-source community an amazing place to learn, inspire, and create. Any contribution you make is greatly appreciated.
Distributed under the MIT License. See the LICENSE file for more details.