API Setup
The backend API for AskAtlas, built with Go.
Prerequisites
- Go — Version 1.24 or higher
- Docker — For containerization
- Infisical CLI — For environment variables
Dependencies
- golangci-lint — Code quality
- goimports — Import formatting
- chi — REST API framework
Getting Started
-
Install dependencies:
make install -
Run the development server:
make dev
Makefile Commands
Development & Build
| Command | Description |
|---|---|
make dev | Start the development server (go run). |
make stage | Start the staging server (go run). |
make prod | Start the production server (go run). |
make build | Build the binary to api. |
Code Quality
| Command | Description |
|---|---|
make lint | Run golangci-lint. |
make format | Format code using goimports -w. |
make format-check | Check formatting using goimports -l. |
make tidy | Run go mod tidy and go mod verify. |
make tidy-check | Check if modules are tidy via script. |
Testing
| Command | Description |
|---|---|
make test | Run unit tests. |
make mockery | Generate mocks for interfaces. |
Docker
| Command | Description |
|---|---|
make docker-build | Build the Docker image askatlas-api. |
make docker-run | Run the container on port 8080 with Infisical secrets. |
Project Structure
api/
├── cmd/ # Application entrypoints
├── internal/ # Private application code and business logic
│ ├── clerk/ # Clerk webhook event processing
│ ├── db/ # sqlc-generated database code
│ ├── files/ # Files domain (model, service, repository, handler)
│ ├── handlers/ # HTTP handlers
│ ├── middleware/ # Auth and request middleware
│ ├── user/ # User domain
│ └── utils/ # Shared utilities
├── pkg/ # Public packages (apperrors, authctx)
├── db/queries/ # SQL query files for sqlc
├── e2e/ # End-to-end tests
└── scripts/ # Helper scripts