# AI Agent Networking Lab (ANL) — Go/Gin/SQLite Backend API This module implements the standalone backend REST API server, SQLite database storage, seed ingestion pipeline, and static content exporter for the ANL landing page. --- ## 🏛 Architecture Overview ``` +-------------------------------------------------------------+ | SQLite (anl.db) | | 11 Relational Tables (Projects, Members, Pubs, Lectures) | +-------------------------------------------------------------+ ▲ ▲ │ (cmd/seed) │ (SQL query) │ │ +-------------------------------+ +-------------------------+ | seed/data/*.json | | Gin REST API Server | | (extracted from content/*.ts) | | (cmd/api, :8080) | +-------------------------------+ +-------------------------+ │ +-------------------------+ | Content Exporter | | (cmd/export-content) | +-------------------------+ │ ▼ +-------------------------+ | Next.js Static SSG | | (refer_landing_page/) | +-------------------------+ ``` --- ## 🚀 Quick Start ### 1. Build Binaries ```bash make build ``` Creates `bin/api`, `bin/seed`, and `bin/export-content`. ### 2. Run Migrations & Seed Database ```bash make seed ``` Creates `anl.db`, executes SQL DDL migrations, inserts seed data, and verifies all 11 table row counts and the 5 designated highlights. ### 3. Run Backend API Server ```bash make run # Or with options: ./bin/api --port 8080 --db anl.db ``` Server starts at `http://localhost:8080/api/v1`. ### 4. Run Unit & Integration Tests ```bash make test ``` ### 5. Export Content to Next.js Frontend ```bash make export-content ``` Regenerates `refer_landing_page/content/*.ts` from SQLite with typed `isHighlight` metadata. --- ## 📡 REST API Endpoints (`/api/v1`) | Method | Path | Description | |---|---|---| | `GET` | `/api/v1/health` | Service health status check | | `GET` | `/api/v1/research-projects` | 3 research project entities | | `GET` | `/api/v1/research-areas` | 14 core research areas ordered by `display_order` | | `GET` | `/api/v1/stats/summary` | Aggregated counts (`intl_publications`, `standardization_docs`, `patents`) | | `GET` | `/api/v1/members` | 16 active members (with `is_advisor` flag) | | `GET` | `/api/v1/alumni` | 60 alumni ordered chronologically | | `GET` | `/api/v1/publications` | 148 publications (supports `?category=intl-journal-conf` or `domestic-journal-conf`) | | `GET` | `/api/v1/publications/highlights` | 5 designated top representative publications (`WHERE is_highlight = 1`) | | `GET` | `/api/v1/patents` | 75 intellectual property patents | | `GET` | `/api/v1/semesters` | 45 semesters with nested courses, ordered by year DESC and term | | `GET` | `/api/v1/standards-bodies` | 6 standards bodies with nested projects and documents (deterministic ordering) | --- ## ⚙️ Environment Configuration (`.env`) Copy `.env.example` to `.env` to customize runtime settings: ```bash cp .env.example .env ``` | Variable | Default | Description | |---|---|---| | `HOST` | `0.0.0.0` | Binding host IP address | | `PORT` | `8080` | Server listening port | | `DB_PATH` | `anl.db` | SQLite database file path | | `GIN_MODE` | `release` | Gin runtime mode (`release`, `debug`, `test`) | | `CORS_ALLOW_ORIGINS` | `*` | Allowed CORS origins (e.g. `https://anl.knu.ac.kr`) | | `AUTO_MIGRATE` | `true` | Apply database migrations automatically on startup | --- ## 🐳 Docker & Containerization ### Build & Run Container ```bash docker build -t anl-backend-api . docker run -p 8080:8080 -v anl-data:/app/data anl-backend-api ``` ### Docker Compose Run the full backend service with automated healthchecks and volume persistence from the repository root: ```bash docker compose up -d ``` --- ## 📦 Database Schema & Specifications * **Architecture**: See [ARCHITECTURE.md](../ARCHITECTURE.md) * **REST API Interfaces**: See [API_INTERFACE.md](../API_INTERFACE.md) * **Database Schema Spec**: See [DATA_TABLE.md](../DATA_TABLE.md) and [000001_init.up.sql](internal/db/migrations/000001_init.up.sql)