Chappie Server is an AI-powered API service that automatically generates and manages repository descriptions for Telegram channels.
- AI-powered text generation using Mistral AI
- Automatic GitHub repository parsing and description generation
- RESTful API for content management
- Database storage for generated descriptions
- Go 1.23
- MariaDB/MySQL
- Docker & Docker Compose
- Mistral AI API
Read about the project's journey and development:
(Articles are in Ukrainian)
- Docker v20.10.0 or later
- Docker Compose v2.0.0 or later
- Mistral AI API key
- docker or/and docker-compose
- mistral ai api key
- create mistral agent (model: mistral large 2.1, temperature: 0.1)
- system prompt (UA, translate yourself if necessary):
Ти слухняний і корисний помічник, який суворо дотримується усіх нищезазначених вимог. Твоя основна задача — генерувати короткі підсумки українською мовою для текстів, які будуть надані. Ці тексти є описами (README) GitHub репозиторіїв. При генеруванні тексту обов'язково дотримуйся таких вимог:
1. Починай текст словами: "Цей репозиторій".
2. В описі має бути не більше трьох ключових функцій репозиторію.
3. Використовуй простий і зрозумілий стиль тексту без перерахувань. Інформацію про функції репозиторію вплітай у зв'язний текст.
4. Не згадуй інформацію про сумісність, платформи, авторів або назву репозиторію.
5. Не використовуй розмітку тексту, таку як HTML теги, Markdown розмітку тощо.
6. Опис має бути лаконічним і точним, обсягом від 300 до 600 символів (з урахуванням пробілів та інших символів).
7. Якщо зустрічаються технічні терміни, такі як назви мов програмування, бібліотек, команд або інструментів, видів програмування, залишай їх англійською мовою без перекладу.
8. Перед генерацією тексту переконайся, що він повністю відповідає усім вищезазначеним вимогам.
Далі тобі буде надано назву GitHub репозиторію та його README. Твоє завдання — створити чіткий і зрозумілий підсумок, який відповідає всім вищезазначеним вимогам.
git clone https://github.com/Think-Root/chappie_server.git
create a .env file in the app root directory
Before creating the .env file, ensure you have:
- Created a Mistral AI account
- Generated an API key
- Created and configured a Mistral agent
- Set up your MariaDB instance
MISTRAL_TOKEN=<mistral api key>
MISTRAL_AGENT=<get agent api id https://console.mistral.ai/build/agents>
DB_CONNECTION=<db connection string e.g. user:password@tcp(localhost:3306)>
BEARER_TOKEN=<your token for API protection>
-
Create Docker network:
docker network create chappie_network
-
Deploy MariaDB:
docker run -d --name mariadb --network chappie_network -e MYSQL_ROOT_PASSWORD=your_password -p 3306:3306 mariadb:latest
-
Deploy Chappie Server:
docker compose up -d
All API requests must include an Authorization header in the following format:
Authorization: Bearer <BEARER_TOKEN>
Rate Limit: 100 requests per minute per IP address All endpoints return JSON responses with appropriate HTTP status codes
Endpoint: /think-root/api/manual-generate/
Method: POST
Description: This endpoint is used to manually generate description for a provided repository URL, and add it to the database.
Curl Example:
curl -X POST \
'http://localhost:9111/think-root/api/manual-generate/' \
-H 'Authorization: Bearer <BEARER_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{"url": "https://github.com/example/repo"}'
Request Example:
{
"url": "https://github.com/example/repo"
}
Status Codes:
- 200: Success
- 400: Invalid request
- 401: Unauthorized
Response Example:
{
"status": "ok",
"added": [
"https://github.com/example/repo"
],
"dont_added": []
}
Endpoint: /think-root/api/auto-generate/
Method: POST
Description: This endpoint is used to automatically parse trending repositories and generate description based on certain parameters. It also adds the generated posts to the database.
Curl Example:
curl -X POST \
'http://localhost:9111/think-root/api/auto-generate/' \
-H 'Authorization: Bearer <BEARER_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"max_repos": 5,
"since": "weekly",
"spoken_language_code": "en"
}'
Request Example:
{
"max_repos": 5,
"since": "weekly",
"spoken_language_code": "en"
}
Response Example:
{
"status": "ok",
"added": [
"https://github.com/example/repo1",
"https://github.com/example/repo2"
],
"dont_added": [
"https://github.com/example/repo3"
]
}
Endpoint: /think-root/api/get-repository/
Method: POST
Description: This endpoint retrieves a list of repositories based on the provided limit and posted status.
Curl Example:
curl -X POST \
'http://localhost:9111/think-root/api/get-repository/' \
-H 'Authorization: Bearer <BEARER_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"limit": 1,
"posted": false
}'
Request Example:
{
"limit": 1,
"posted": false
}
Response Example:
{
"status": "ok",
"message": "Repositories fetched successfully",
"data": {
"all": 50,
"posted": 20,
"unposted": 30,
"items": [
{
"id": "1",
"posted": false,
"url": "https://github.com/example/repo",
"text": "Repository description here."
}
]
}
}
Endpoint: /think-root/api/update-posted/
Method: PATCH
Description: This endpoint updates the posted status of a repository identified by its URL.
Curl Example:
curl -X PATCH \
'http://localhost:9111/think-root/api/update-posted/' \
-H 'Authorization: Bearer <BEARER_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://github.com/example/repo",
"posted": true
}'
Request Example:
{
"url": "https://github.com/example/repo",
"posted": true
}
Response Example:
{
"status": "ok",
"message": "Posted status updated successfully"
}
- Install Go 1.23 or later
- Install MariaDB 10.5 or later
- Clone the repository
- Install dependencies:
go mod download
- Set up your .env file
- Start MariaDB
- Run the server:
go run ./cmd/server/main.go
go build -o chappie_server ./cmd/server/main.go