You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+88-45Lines changed: 88 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,26 +4,60 @@
4
4
5
5
<h1align="center">BeeAPI Go</h1>
6
6
7
-
## Self-Hostable API for AlgoHive
7
+
<palign="center">
8
+
<b>A high-performance, self-hostable API service for AlgoHive puzzle distribution</b>
9
+
</p>
8
10
9
-
BeeAPI Go is a Go implementation of the BeeAPI service, designed to load puzzles from `.alghive` files, organized into themes, and serve them to the AlgoHive platform independently. It comes with a Swagger UI to test the API endpoints and a simple web interface to manage the puzzles.
11
+
## Overview
10
12
11
-

13
+
BeeAPI Go is a robust Go implementation of the BeeAPI service, designed with a microservice architecture for high availability and horizontal scaling. It provides a comprehensive API for loading, managing, and serving puzzles from `.alghive` files to the AlgoHive platform. The service is built with performance and reliability in mind, allowing for independent deployment across multiple environments.
12
14
13
-
## AlgoHive
15
+
## Key Features
14
16
15
-
AlgoHive is a web, self-hostable platform that allows developers to create puzzles for other developers to solve. Each puzzle contains two parts to solve, allowing developers to test their skills in a variety of ways. The puzzles are created using a proprietary file format that is compiled into a single file for distribution.
17
+
-**Dynamic Puzzle Management**: Automatically extracts, loads, and unloads puzzles from `.alghive` files
18
+
-**Stateless Architecture**: Designed for easy replication across multiple instances
19
+
-**High Availability Design**: Can be deployed in redundant configurations for zero downtime
20
+
-**Secure API Authentication**: API key-based authentication for protected endpoints
21
+
-**Comprehensive API**: Full suite of endpoints for puzzle discovery and interaction
22
+
-**Swagger Documentation**: Interactive API documentation for easy integration
23
+
-**Container-Ready**: Optimized for Docker and container orchestration platforms
24
+
-**Efficient Resource Usage**: Intelligent memory management for puzzle loading/unloading
16
25
17
-
## Installation
26
+
## Technical Architecture
27
+
28
+
BeeAPI Go implements a clean architecture pattern with clear separation between:
29
+
30
+
-**Service Layer**: Handles core business logic including puzzle extraction and loading
31
+
-**Controller Layer**: Manages API endpoints and request/response handling
32
+
-**Model Layer**: Defines data structures for puzzles and themes
33
+
-**Middleware Layer**: Provides authentication and request processing
34
+
35
+
The service is designed to be stateless, making it ideal for horizontal scaling in high availability environments. Multiple BeeAPI instances can be deployed behind a load balancer to distribute traffic and provide redundancy.
36
+
37
+
## Puzzle Management System
38
+
39
+
BeeAPI employs a sophisticated puzzle management system:
40
+
41
+
1.**Initial Loading**: When the server starts, it scans the `puzzles` directory structure
42
+
2.**Extraction Process**: `.alghive` files are automatically extracted into their component files
43
+
3.**Memory Management**: Puzzles are loaded into memory with optimized resource usage
44
+
4.**Graceful Unloading**: On shutdown, puzzle resources are properly released
45
+
5.**Dynamic Reloading**: Themes and puzzles can be reloaded without service interruption
46
+
47
+
This design allows for efficient management of puzzle resources while maintaining high performance.
18
48
19
-
### Local
49
+
##AlgoHive Platform
20
50
21
-
To use BeeAPI Go, you need to have Go 1.16 or higher installed on your system.
51
+
AlgoHive is a web-based, self-hostable platform that enables developers to create and solve coding puzzles. Each puzzle contains two parts to solve, challenging developers to apply different skills and approaches. The puzzles are distributed using the proprietary `.alghive` file format, which BeeAPI is designed to process.
BeeAPI Go uses API key authentication for protected endpoints (POST, PUT, DELETE). When the server starts for the first time, it generates a unique API key and saves it in a `.api-key` file in the root directory.
65
-
66
-
To authenticate your requests to protected endpoints:
108
+
BeeAPI Go implements a secure API key authentication system for protected endpoints:
67
109
68
-
1. Look for the API key in the `.api-key` file or in the server logs when it starts
69
-
2. Include the API key in your requests' Authorization header:
110
+
- An API key is automatically generated on first startup
111
+
- The key is stored in a `.api-key` file in the root directory
112
+
- Protected endpoints (POST, PUT, DELETE) require this key in the Authorization header
113
+
- The key can be retrieved via the authenticated `/apikey` endpoint
70
114
71
115
```bash
116
+
# Example authenticated request
72
117
curl -X POST "http://localhost:5000/theme" \
73
118
-H "Authorization: Bearer YOUR_API_KEY" \
74
119
-d "name=new-theme"
75
120
```
76
121
77
-
If you're using Docker, you can access the API key by:
78
-
79
-
```bash
80
-
docker exec beeapi-go cat /app/.api-key
81
-
```
82
-
83
-
Make sure to keep this key secure as it provides administrative access to your BeeAPI instance.
84
-
85
122
## API Documentation
86
123
87
-
The API documentation is available at `/swagger/index.html` when the server is running.
124
+
The API documentation is accessible through Swagger UI at `/swagger/index.html` when the server is running. This provides:
125
+
126
+
- Interactive API testing interface
127
+
- Complete endpoint documentation
128
+
- Request/response schema details
129
+
- Authentication requirements
88
130
89
-
## Environment Variables
131
+
## Configuration
90
132
91
-
The following environment variables can be used to configure the server:
133
+
BeeAPI can be configured using environment variables:
92
134
93
135
-`SERVER_NAME`: The name of the server (default: "Local")
94
136
-`SERVER_DESCRIPTION`: A description of the server (default: "Local Dev Server")
95
-
-`USER_*`: Create users automatically, for example `USER_ADMIN=adminpassword`
137
+
-`PORT`: The port to run the server on (default: 5000)
138
+
-`PYTHON_PATH`: Path to Python interpreter for puzzle execution (default: "python")
0 commit comments