https://github.com/muga20/go-modular-application
AutoVerse is a modular Go framework for building RESTful APIs and backend applications It features database migrations user management and authentication with seamless MySQL integration Designed for scalability AutoVerse simplifies creating production ready APIs for microservices or monolithic applications
https://github.com/muga20/go-modular-application
authentication backend database-migrations framework go golang mysql open-source rest-api
Last synced: about 1 year ago
JSON representation
AutoVerse is a modular Go framework for building RESTful APIs and backend applications It features database migrations user management and authentication with seamless MySQL integration Designed for scalability AutoVerse simplifies creating production ready APIs for microservices or monolithic applications
- Host: GitHub
- URL: https://github.com/muga20/go-modular-application
- Owner: Muga20
- Created: 2025-03-07T22:43:04.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-07T22:43:39.000Z (about 1 year ago)
- Last Synced: 2025-03-08T04:46:13.233Z (about 1 year ago)
- Topics: authentication, backend, database-migrations, framework, go, golang, mysql, open-source, rest-api
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AutoVerse: A Modular Go Framework for RESTful APIs
AutoVerse is a **modular Go framework** designed to simplify building **RESTful APIs** and backend applications. Whether you're building a **microservice** or a **monolithic application**, AutoVerse provides the tools you need to get started quickly and efficiently.
---
## Why Use AutoVerse?
If you're looking for a **scalable**, **modular**, and **production-ready** framework to build RESTful APIs in Go, AutoVerse is for you. Here's why:
- π οΈ **Built-in Features**: Database migrations, user management, and authentication are included out of the box.
- π **Quick Start**: Get your API up and running in minutes with a clean and intuitive structure.
- π§© **Modular Design**: Easily extend or replace components to fit your specific needs.
- ποΈ **MySQL Integration**: Seamlessly connect to MySQL for data storage and management.
---
## How Can You Use AutoVerse?
AutoVerse is designed to be flexible and adaptable to your needs. Here are some ways you can use it:
### 1. **As a Template for New Projects**
- Use AutoVerse as a starting point for your next Go project. Clone the repository, customize the modules, and start building your application.
### 2. **As a Dependency in Existing Projects**
- Import specific modules (e.g., database migrations or authentication) into your existing Go projects.
### 3. **As a Learning Resource**
- Explore the codebase to learn best practices for building modular and scalable Go applications.
---
## Features
- **Database Migrations**: Manage schema changes with ease using built-in migration tools.
- **User Management**: Handle user authentication and authorization effortlessly.
- **MySQL Integration**: Connect to MySQL databases seamlessly.
- **Modular Architecture**: Add, remove, or replace modules to suit your application's needs.
---
## Getting Started
### Prerequisites
- Go (version 1.20 or higher)
- MySQL
### Installation
1. Clone the repository:
```bash
git clone https://github.com/Muga20/Go-Modular-Application.git
cd Go-Modular-Application
```
2. Install dependencies:
```bash
go mod download
```
3. Set up the database:
- Update the database configuration in `config/config.go`.
- Run migrations:
```bash
make migrate-up
```
4. Start the application:
```bash
make run
```
---
## Running the Application
### Start the Application
To start the application, run:
```bash
make run
```
This will start the application on the default port (e.g., `:8080`).
### Build the Application
To build the application and generate an executable, run:
```bash
make build
```
The executable will be placed in the `bin/` folder.
---
## Database Migrations
### Create a Migration
To create a new migration for a module, use:
```bash
make create-migration MODULE_NAME=users MIGRATION_DESC=create_users_table
```
This generates two migration files in the `Modules/users/migrations/` folder:
- `20231010120000_create_users_table.up.sql`
- `20231010120000_create_users_table.down.sql`
Edit these files to include the necessary SQL for creating and dropping tables.
### Apply Migrations
To apply all migrations, run:
```bash
make migrate-up
```
To apply migrations for a specific module, run:
```bash
make migrate-up-module MODULE_NAME=users
```
### Rollback Migrations
To rollback all migrations, run:
```bash
make migrate-down
```
To rollback migrations for a specific module, run:
```bash
make migrate-down-module MODULE_NAME=users
```
---
## Folder Structure
```
auto_verse/
βββ bin/ # Compiled executable
βββ cmd/ # Application entry points
β βββ main.go
βββ config/ # Configuration files
β βββ config.go
βββ helpers/ # Helper scripts
β βββ create_module.go
βββ migrations/ # Migration management
β βββ registry.go
βββ Modules/ # Application modules
β βββ users/ # Example module
β βββ migrations/ # Migration files for the module
β βββ models/ # Database models
β βββ routes/ # HTTP routes
β βββ ...
βββ go.mod # Go module file
βββ go.sum # Go dependencies checksum
βββ Makefile # Makefile for running commands
βββ README.md # Project documentation
```
---
## Configuration
The application configuration is stored in `config/config.go`. Update the following environment variables:
```go
var Envs = struct {
DBUser string
DBPassword string
DBAddress string
DBName string
}{
DBUser: os.Getenv("DB_USER"),
DBPassword: os.Getenv("DB_PASSWORD"),
DBAddress: os.Getenv("DB_ADDRESS"),
DBName: os.Getenv("DB_NAME"),
}
```
Set these variables in your environment or in a `.env` file.
---
## Troubleshooting
### 1. Dirty Database Version
If you encounter the error `Dirty database version`, follow these steps:
1. Identify the failed migration:
```bash
cat Modules/users/migrations/20231010120000_create_users_table.up.sql
```
2. Fix the SQL in the migration file.
3. Force the database version:
```bash
make force-version VERSION=20231010120000
```
4. Apply migrations again:
```bash
make migrate-up
```
### 2. Database Connection Issues
Ensure the database configuration is correct in `config/config.go`. Verify that the database is running and accessible.
---
## Contributing
We welcome contributions! If you'd like to contribute to AutoVerse, feel free to:
- Open an issue to report bugs or suggest features.
- Submit a pull request with your improvements.
Check out our [Contributing Guidelines](CONTRIBUTING.md) for more details.
---
## License
AutoVerse is licensed under the MIT License. See [LICENSE](LICENSE) for more details.
---
## Questions or Feedback?
If you have any questions or feedback, feel free to open an issue or reach out. Letβs build something awesome together! π