Your content. The perfect caption.
CapIt is an AI-powered social media caption generator designed to help content creators, businesses, photographers, and digital marketers create engaging captions for their social media posts.
By providing a topic, choosing a social media platform, and selecting a preferred tone, users can generate captions using Google's Gemini AI.
- AI-powered caption generation: Generate captions using Google's Gemini API.
- Multiple social media platforms: Supports Instagram, Facebook, TikTok, and LinkedIn.
- Customizable tone: Specify the tone that best suits your content.
- REST API: Generate captions through a Go-powered HTTP API.
- Input validation: Validate incoming requests and reject unsupported platforms.
- Local caption storage: Save generated captions in the browser using localStorage.
- Mock generator: Retain a mock implementation for development and testing.
| Component | Technology |
|---|---|
| Backend | Go |
| HTTP Router | Chi |
| AI Provider | Google Gemini |
| AI SDK | Google GenAI Go SDK |
| Frontend | HTML, CSS, JavaScript |
| Configuration | Environment variables |
| Browser Storage | localStorage |
| Testing | Go testing package |
CapIt/
│
├── cmd/
│ └── server/
│ └── main.go
│
├── internal/
│ ├── captions/
│ │ ├── handler.go
│ │ ├── handler_test.go
│ │ └── mock.go
│ │
│ ├── config/
│ │ └── config.go
│ │
│ └── providers/
│ └── gemini.go
│
├── web/
│ ├── assets/
│ │ ├── css/
│ │ └── js/
│ │
│ └── index.html
│
├── .env
├── .gitignore
├── go.mod
└── go.sum
CapIt follows a modular backend architecture.
- cmd/server: Application entry point, environment loading, dependency initialization, routing, and HTTP server startup.
- internal/captions: Caption request handling, input validation, response formatting, and the generator interface.
- internal/config: Application configuration and environment variable management.
- internal/providers: AI provider implementations, including the Gemini integration.
- web: Frontend assets and user interface.
The application uses dependency injection to separate caption generation from HTTP request handling.
The Generator interface allows different implementations, such as the mock generator and Gemini generator, to be used interchangeably.
Make sure you have installed:
- Go
- Git
- A Google Gemini API key
- A modern web browser
git clone https://github.com/nyae44/CapIt.git
cd CapItgo mod downloadCreate a .env file in the project root.
PORT=3000
APP_ENV=development
GEMINI_API_KEY=your_gemini_api_key
GEMINI_MODEL=your_supported_gemini_modelReplace the placeholders with your actual Gemini API credentials and a model available to your account.
Security: Never commit your .env file or expose your Gemini API key in frontend JavaScript.
go run ./cmd/serverThe application will be available at:
http://localhost:3000
Check whether the application is running.
Endpoint
GET /api/v1/healthResponse
{
"status": "ok"
}Generate a caption using the configured AI provider.
Endpoint
POST /api/v1/captions/generateContent-Type
application/json
Request Body
{
"platform": "instagram",
"topic": "A beautiful coastal wedding in Kilifi",
"tone": "professional"
}Supported Platforms
- TikTok
Response
{
"caption": "Celebrate love, laughter, and unforgettable moments...",
"platform": "instagram"
}The generated caption will vary depending on the topic, platform, and selected tone.
The API validates incoming requests and returns appropriate HTTP error responses.
Examples include:
400 Bad Request: Invalid JSON, missing fields, or unsupported platform.500 Internal Server Error: Caption generation failure.
Detailed generation errors are logged on the backend rather than exposed to API clients.
Run all project tests with:
go test ./...The mock generator allows the caption handler to be tested without making actual requests to the Gemini API.
CapIt uses Google's Gemini API through the official Go SDK.
The backend communicates with Gemini to generate captions based on user-provided content.
The AI provider is separated from the HTTP handler through the Generator interface, making it easier to introduce additional providers in the future.
AI services may occasionally experience temporary availability issues or rate limits.
- Complete frontend integration with the Go caption API.
- Multiple caption variations per request.
- Improve error handling and retry mechanisms.
- Additional AI providers.
- User authentication and accounts.
- Cloud-based caption history.
- Caption editing and regeneration.
- Docker support.
- Deployment to production infrastructure.
Contributions, ideas, bug reports, and suggestions are welcome.
- Fork the repository.
- Create a feature branch.
- Make your changes.
- Run the tests.
- Submit a pull request.
A license has not yet been specified.
CapIt
Your content. The perfect caption.