This project is a backend application built using the Go programming language and the Fiber framework. The application follows a microservices architecture, employing JWT authentication with 2FA (Two-Factor Authentication), bcrypt for password hashing, and secure HttpOnly cookies for session management. The backend enables users to perform a variety of actions such as creating and approving routes, managing buy models, registering plans, creating accounts, and logging in securely.
- Microservices Architecture: Each service is isolated for scalability and maintainability.
- Authentication:
- JWT-based authentication with Two-Factor Authentication (2FA).
- Secure password storage using bcrypt.
- Session management using HttpOnly cookies.
- Core Functionalities:
- User registration and account management.
- Secure login with optional 2FA.
- Creation and approval of routes.
- Management of buy models.
- Plane registration and updates.
- Security Features:
- Enforced secure practices using bcrypt and HttpOnly cookies.
- Validation of JWT tokens for API request authorization.
- Go
- Fiber (a fast, lightweight web framework inspired by Express.js)
- bcrypt: For secure password hashing.
- JWT: For token-based authentication.
- Fiber Middleware: Various middleware for request handling, error management, and CORS.
- gorilla/mux: For additional routing needs.
- PostgreSQL: For user and transactional data.
- Redis: For session storage and caching.
-
Prerequisites:
- Go (version 1.20 or later).
- PostgreSQL database.
- Redis server.
-
Clone the Repository:
git clone https://github.com/your-repo/backend-go-fiber cd backend-go-fiber
-
Environment Setup:
- Create a
.env
file and configure the following variables:DB_HOST=localhost DB_PORT=5432 DB_USER=yourusername DB_PASSWORD=yourpassword DB_NAME=yourdatabase REDIS_URL=redis://localhost:6379 JWT_SECRET=yourjwtsecret
- Create a
-
Install Dependencies:
go mod tidy
-
Run Database Migrations (if any):
go run migrate.go
-
Run the Application:
go run main.go