| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A modern Twitter clone API built with Go, Gin, and GORM following Clean Architecture principles. This project provides a complete backend solution for a Twitter-like social media platform with user authentication, posts, likes, and real-time logging.
This project implements Clean Architecture principles in Go, providing a well-structured, maintainable, and scalable API for a Twitter clone application. The architecture separates concerns into distinct layers (controllers, services, repositories, entities) making the codebase easy to understand, test, and extend.
The application includes a built-in logging system that allows you to monitor and track system queries. You can access the logs through a modern, user-friendly interface.
To view the logs:
http://your-domain/logsClone the repository
git clone https://github.com/Lab-RPL-ITS/twitter-clone-api.git
cd twitter-clone-apiSet up environment variables
cp .env.example .env
# Edit .env with your configurationStart the application
make upInitialize database
make init-uuid
make migrate-seedAccess the API
Clone and navigate
git clone https://github.com/Lab-RPL-ITS/twitter-clone-api.git
cd twitter-clone-apiSet up environment variables
cp .env.example .env
# Configure your PostgreSQL credentials in .envSet up PostgreSQL
# Create database and enable UUID extension
psql -U postgres
CREATE DATABASE your_database;
\c your_database
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
\qInstall dependencies and run
go mod tidy
go run main.gomake up # Start all services
make down # Stop all services
make logs # View logs
make init-docker # Build and start servicesmake migrate # Run database migrations
make seed # Seed database with initial data
make migrate-seed # Run both migrations and seeding
make init-uuid # Initialize UUID extensionmake run # Run the application locally
make build # Build the application
make test # Run tests
make dep # Install dependenciesThe application supports various command line arguments:
go run main.go --migrate --seed --run --script:example_scripttwitter-clone-api/ ├── config/ # Configuration files ├── controller/ # HTTP controllers ├── dto/ # Data Transfer Objects ├── entity/ # Database entities/models ├── helpers/ # Helper functions ├── middleware/ # HTTP middleware ├── migrations/ # Database migrations ├── provider/ # Dependency injection ├── repository/ # Data access layer ├── routes/ # API route definitions ├── script/ # Utility scripts ├── service/ # Business logic layer ├── tests/ # Test files ├── utils/ # Utility functions ├── docker/ # Docker configuration ├── main.go # Application entry point ├── go.mod # Go module file ├── docker-compose.yml └── Makefile # Build and deployment commands
Create a .env file with the following variables:
# Application
APP_NAME=twitter-clone-api
APP_ENV=development
PORT=8888
IS_LOGGER=true
# Database
DB_HOST=localhost
DB_USER=postgres
DB_PASS=your_password
DB_NAME=twitter_clone
DB_PORT=5432
# JWT
JWT_SECRET=your_jwt_secret_key
# Email (optional)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your_email@gmail.com
SMTP_PASS=your_email_passwordYou can explore the available endpoints and their usage in the Postman Documentation. This documentation provides a comprehensive overview of the API endpoints, including request and response examples.
Most endpoints require JWT authentication. Include the JWT token in the Authorization header:
Authorization: Bearer <your_jwt_token>
For development with hot reload, the project includes Air configuration:
# Install Air
go install github.com/cosmtrek/air@latest
# Run with hot reload
airRun the test suite:
make testThe project follows Go best practices and Clean Architecture principles:
We welcome contributions! Please see our contributing guidelines:
The repository includes templates for issues and pull requests to standardize contributions and improve the quality of discussions and code reviews.
This project is licensed under the MIT License - see the LICENSE file for details.
If you have any questions or need help, please:
Happy Coding! 🚀
| Back | FazBrowse Home | New Git URL |