Skip to content

Commit a8b11d7

Browse files
committed
Update README.md to enhance overview, key features, and deployment instructions
1 parent 1f6d2b3 commit a8b11d7

1 file changed

Lines changed: 88 additions & 45 deletions

File tree

README.md

Lines changed: 88 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,60 @@
44

55
<h1 align="center">BeeAPI Go</h1>
66

7-
## Self-Hostable API for AlgoHive
7+
<p align="center">
8+
<b>A high-performance, self-hostable API service for AlgoHive puzzle distribution</b>
9+
</p>
810

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
1012

11-
![Swagger](img/swagger.png)
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.
1214

13-
## AlgoHive
15+
## Key Features
1416

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
1625

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.
1848

19-
### Local
49+
## AlgoHive Platform
2050

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.
52+
53+
## Installation
54+
55+
### Local Development
2256

2357
```bash
2458
# Clone the repository
25-
git clone https://github.com/AlgoHive-Coding-Puzzles/BeeAPI-Go.git
26-
cd BeeAPI-Go
59+
git clone https://github.com/AlgoHive-Coding-Puzzles/BeeAPI.git
60+
cd BeeAPI
2761

2862
# Build the application
2963
go build -o beeapi
@@ -32,67 +66,76 @@ go build -o beeapi
3266
./beeapi
3367
```
3468

35-
Feed the `puzzles` directory with themes folders containing `.alghive` files or use the Web interface to manage the puzzles for the BeeAPI instance.
69+
### Docker Deployment
3670

37-
```
38-
beeapi/
39-
├── puzzles/
40-
│ ├── theme1/
41-
│ │ ├── puzzle1.alghive
42-
│ │ ├── puzzle2.alghive
43-
│ ├── theme2/
44-
│ │ ├── puzzle3.alghive
45-
│ │ ├── puzzle4.alghive
71+
```bash
72+
# Build the Docker image
73+
docker build -t beeapi-go .
74+
75+
# Run as a container
76+
docker run -d -p 8080:8080 --name beeapi-go \
77+
-v $(pwd)/puzzles:/app/puzzles \
78+
-v $(pwd)/data:/app/data \
79+
beeapi-go
4680
```
4781

48-
### Docker
82+
### High Availability Deployment
4983

50-
You can also run the API using Docker. To build the Docker image:
84+
For production environments, BeeAPI can be deployed in a high availability configuration:
5185

52-
```bash
53-
docker build -t beeapi-go .
54-
```
86+
1. Deploy multiple instances behind a load balancer
87+
2. Use a shared storage volume for puzzle files (NFS, S3, etc.)
88+
3. Implement health checks for automatic instance recovery
89+
4. Configure instance auto-scaling based on load
5590

56-
Then, run the Docker container:
91+
## Directory Structure
5792

58-
```bash
59-
docker run -d -p 8080:8080 --name beeapi-go -v $(pwd)/puzzles:/app/puzzles -v $(pwd)/data:/app/data beeapi-go
93+
```
94+
beeapi/
95+
├── puzzles/ # Root directory for puzzle content
96+
│ ├── theme1/ # Theme directory
97+
│ │ ├── puzzle1.alghive # Compressed puzzle file
98+
│ │ ├── puzzle1/ # Extracted puzzle directory (created at runtime)
99+
│ │ ├── puzzle2.alghive
100+
│ │ ├── puzzle2/
101+
│ ├── theme2/
102+
│ │ ├── puzzle3.alghive
103+
│ │ ├── puzzle3/
60104
```
61105

62106
## API Authentication
63107

64-
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:
67109

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
70114

71115
```bash
116+
# Example authenticated request
72117
curl -X POST "http://localhost:5000/theme" \
73118
-H "Authorization: Bearer YOUR_API_KEY" \
74119
-d "name=new-theme"
75120
```
76121

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-
85122
## API Documentation
86123

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
88130

89-
## Environment Variables
131+
## Configuration
90132

91-
The following environment variables can be used to configure the server:
133+
BeeAPI can be configured using environment variables:
92134

93135
- `SERVER_NAME`: The name of the server (default: "Local")
94136
- `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")
96139

97140
## License
98141

0 commit comments

Comments
 (0)