A Go-based API server for the Meme Coin project.
.
├── Makefile # Make commands for development
├── cmd/
│ └── api/ # Main application entry point
│ ├── config/ # Configuration handling
│ └── main.go # Main application file
├── internal/
│ └── api/ # Internal API packages
│ ├── controller/ # HTTP handlers
│ ├── dao/ # Data Access Objects
│ ├── migrations/ # Database migrations
│ ├── model/ # Data models
│ └── service/ # Business logic
├── pkg/ # Shared packages
│ ├── apierror/ # API error handling
│ ├── database/ # Database related packages
│ ├── log/ # Logging utilities
│ └── utils/ # Common utilities
└── dev-support/
├── docker/ # Dockerfile definitions
└── docker-compose/ # Docker compose files and environment configs
- Go 1.21 or higher
- Docker and Docker Compose
- Make (optional)
- Clone the repository:
git clone https://github.com/YiChengHsu/meme-coin-api-server.git
cd meme-coin-api-server
- Set up environment file:
# Create env file from template
cp dev-support/docker-compose/env/template.env dev-support/docker-compose/env/.env
# Edit the env file according to your needs
vim dev-support/docker-compose/env/.env
- Run with Docker Compose :
# Using Makefile (recommended)
make docker-compose-up
# Or using Docker command directly
docker compose -f dev-support/docker-compose/docker-compose.yml up -d
The API server will be available at http://localhost:8080
The application can be configured using environment variables:
SERVER_TIME_ZONE
: Timezone setting (e.g., "Asia/Taipei")SERVER_ALLOW_ORIGINS
: Allowed CORS originsSERVER_HTTP_LISTEN_ADDR:
HTTP listen addressSERVER_HTTP_LISTEN_PORT
: HTTP listen portSERVER_TRUST_PROXIES
: Trusted proxy CIDR ranges
DATABASE_HOST
: Database hostDATABASE_PORT
: Database portDATABASE_USER
: Database userDATABASE_PASSWORD
: Database passwordDATABASE_DB_NAME
: Database nameDATABASE_SSLMODE
: SSL modeDATABASE_MIGRATION_URL
: Migration files location
You can run tests either locally or in Docker:
# Run tests locally
# Using Makefile (recommended)
make docker-compose-up
# Run directly
./internal/api/controller/test.sh
Note:
- The test environment variables are configured in
internal/api/controller/test.sh