A production-ready backend foundation built with Go, featuring a robust authentication system, multi-database support, and essential backend services. This project provides a solid starting point for building scalable and secure web applications.
-
Comprehensive Authentication System:
- OAuth 2.0 support for Google, GitHub, and Discord.
- Secure session management with Redis.
- CSRF protection on # Awesome Backend
A production-ready backend foundation built with Go, featuring a robust authentication system, multi-database support, and essential backend services. This project provides a solid starting point for building scalable and secure web applications.
Project Status: This project is not currently in active development, and there is no ETA for when development will resume. However, the existing codebase is stable and provides a solid foundation. I encourage open-source contributions! Please feel free to create issues for bugs or submit pull requests for fixes and improvements.
- Comprehensive Authentication System:
- OAuth 2.0 support for Google, GitHub, and Discord.
- Secure session management with Redis.
- CSRF protection on authenticated routes.
- Role-based access control (RBAC) stubs.
- Multi-Database Ready:
- PostgreSQL: For structured, relational data (e.g., users, profiles).
- MongoDB: For flexible, unstructured data.
- Redis: For caching, session storage, and real-time messaging.
- Robust Backend Services:
- Structured Logging: Advanced logging with
zapandlumberjack, with separate logs for different modules (app, auth, ratelimit, requests). - Rate Limiting: Middleware to protect against brute-force attacks and abuse.
- Metrics & Monitoring: Integrated Prometheus for metrics and prepared for Grafana/Loki for visualization and log aggregation.
- Configuration Management: Centralized and environment-based configuration using
viper.
- Structured Logging: Advanced logging with
- Containerized & Easy to Deploy:
- Dockerized setup with
docker-composefor all services. Makefilewith commands for building, testing, and running the application.
- Dockerized setup with
- Language: Go
- Framework: Gin
- Databases: PostgreSQL, MongoDB, Redis
- Authentication: Goth for OAuth2
- Configuration: Viper
- Logging: Zap
- Containerization: Docker & Docker Compose
- Metrics: Prometheus
- Go (v1.23 or newer)
- Docker and Docker Compose
- Infisical CLI (for secret management, as used in the Makefile) or willingness to manage environment variables manually.
-
Clone the repository:
git clone https://github.com/LoveKhatri/aegis.git cd aegis -
Set up environment variables: This project uses Infisical for secret management. You can either set up an Infisical project or create a
.envfile in the root directory.Rename
.env.exampleto.envand fill in the required values:mv .env.example .env
-
Run the services: The easiest way to get started is with Docker Compose, which will spin up the backend and all required databases.
make docker
This command uses
infisical runto inject secrets. If you are using a.envfile, you may need to adjust thedocker-compose.ymlor load the variables into your shell before runningdocker compose up. -
Run the application: You can run the application in development mode using the Makefile:
make dev
This will start the server on
http://localhost:8080.
. βββ cmd/ # Application entrypoint βββ config/ # Configuration files (Viper) βββ internal/ # Private application logic β βββ auth/ # Authentication services and logic β βββ server/ # Gin server setup, middleware, and routes β βββ services/ # Connectors for external services (DBs, Kafka) βββ pkg/ # Reusable packages (logger, metrics, ratelimit) βββ types/ # Shared data structures and types βββ docker-compose.yml # Docker setup for all services βββ Dockerfile # Dockerfile for the Go application βββ Makefile # Helper commands for developmentThe server exposes the following main endpoints:
GET /health: Health check.GET /auth/:provider: Initiate OAuth2 flow (e.g.,/auth/google).GET /auth/:provider/callback: OAuth2 callback URL.POST /auth/logout: Log out and clear the session.GET /api/profile: Example protected route to get user profile.
The application is configured through YAML files in the
/configdirectory and environment variables.Viperloads configuration in the following order:config/base.yamlconfig/{environment}.yaml(e.g.,development.yaml)- Environment variables
See
config/base.yamlfor all available configuration options.Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details. authenticated routes.
- Role-based access control (RBAC) stubs.
-
Multi-Database Ready:
- PostgreSQL: For structured, relational data (e.g., users, profiles).
- MongoDB: For flexible, unstructured data.
- Redis: For caching, session storage, and real-time messaging.
-
Robust Backend Services:
- Structured Logging: Advanced logging with
zapandlumberjack, with separate logs for different modules (app, auth, ratelimit, requests). - Rate Limiting: Middleware to protect against brute-force attacks and abuse.
- Metrics & Monitoring: Integrated Prometheus for metrics and prepared for Grafana/Loki for visualization and log aggregation.
- Configuration Management: Centralized and environment-based configuration using
viper.
- Structured Logging: Advanced logging with
-
Containerized & Easy to Deploy:
- Dockerized setup with
docker-composefor all services. Makefilewith commands for building, testing, and running the application.
- Dockerized setup with
- Language: Go
- Framework: Gin
- Databases: PostgreSQL, MongoDB, Redis
- Authentication: Goth for OAuth2
- Configuration: Viper
- Logging: Zap
- Containerization: Docker & Docker Compose
- Metrics: Prometheus
- Go (v1.23 or newer)
- Docker and Docker Compose
- Infisical CLI (for secret management, as used in the Makefile) or willingness to manage environment variables manually.
-
Clone the repository:
git clone https://github.com/LoveKhatri/aegis.git cd aegis -
Set up environment variables: This project uses Infisical for secret management. You can either set up an Infisical project or create a
.envfile in the root directory.Rename
.env.exampleto.envand fill in the required values:mv .env.example .env
-
Run the services: The easiest way to get started is with Docker Compose, which will spin up the backend and all required databases.
make docker
This command uses
infisical runto inject secrets. If you are using a.envfile, you may need to adjust thedocker-compose.ymlor load the variables into your shell before runningdocker compose up. -
Run the application: You can run the application in development mode using the Makefile:
make dev
This will start the server on
http://localhost:8080.
.
βββ cmd/ # Application entrypoint
βββ config/ # Configuration files (Viper)
βββ internal/ # Private application logic
β βββ auth/ # Authentication services and logic
β βββ server/ # Gin server setup, middleware, and routes
β βββ services/ # Connectors for external services (DBs, Kafka)
βββ pkg/ # Reusable packages (logger, metrics, ratelimit)
βββ types/ # Shared data structures and types
βββ docker-compose.yml # Docker setup for all services
βββ Dockerfile # Dockerfile for the Go application
βββ Makefile # Helper commands for development
The server exposes the following main endpoints:
GET /health: Health check.GET /auth/:provider: Initiate OAuth2 flow (e.g.,/auth/google).GET /auth/:provider/callback: OAuth2 callback URL.POST /auth/logout: Log out and clear the session.GET /api/profile: Example protected route to get user profile.
The application is configured through YAML files in the /config directory and environment variables. Viper loads configuration in the following order:
config/base.yamlconfig/{environment}.yaml(e.g.,development.yaml)- Environment variables
See config/base.yaml for all available configuration options.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.