Skip to main content

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

Getting Started

  1. Install dependencies:

    make install
  2. Run the development server:

    make dev

Makefile Commands

Development & Build

CommandDescription
make devStart the development server (go run).
make stageStart the staging server (go run).
make prodStart the production server (go run).
make buildBuild the binary to api.

Code Quality

CommandDescription
make lintRun golangci-lint.
make formatFormat code using goimports -w.
make format-checkCheck formatting using goimports -l.
make tidyRun go mod tidy and go mod verify.
make tidy-checkCheck if modules are tidy via script.

Testing

CommandDescription
make testRun unit tests.
make mockeryGenerate mocks for interfaces.

Docker

CommandDescription
make docker-buildBuild the Docker image askatlas-api.
make docker-runRun 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