|
| 1 | +# Nexus |
| 2 | + |
| 3 | +Nexus is a local first toolkit for running, mocking, and sharing API collections from your repository. It helps teams iterate faster by keeping HTTP requests as plain files, letting you run them with a CLI or a web UI, stand up private mock servers, and get optional AI assisted help for crafting payloads and assertions. |
| 4 | + |
| 5 | +This repository contains a Go backend (CLI and API) and a Nextjs frontend. The design favors local development, reproducible runs stored in git, and private environments for teams. |
| 6 | + |
| 7 | +**Highlights** |
| 8 | +- **Run collections locally**: execute YAML based request collections from the CLI or web UI. |
| 9 | +- **Private mock servers**: run isolated mocks for integration tests and local development. |
| 10 | +- **Team friendly**: store collections in your repo, review changes with git, and share runs with teammates. |
| 11 | +- **AI assisted**: optional OpenAI adapter to generate example bodies and assertions. |
| 12 | + |
| 13 | +**Layout** |
| 14 | +- **[cmd/nexus](cmd/nexus)**: Go CLI and server entrypoint. |
| 15 | +- **[pkg](pkg)**: core libraries — AI adapters, collection runner, http helpers, mock server. |
| 16 | +- **[web](web)**: Nextjs frontend (UI, landing page, editor, Monaco integration). |
| 17 | + |
| 18 | +**Quick start (development)** |
| 19 | + |
| 20 | +Prerequisites: |
| 21 | +- Go 1.20+ (required to run the backend locally) |
| 22 | +- Node 16+ / npm or pnpm (for the frontend) |
| 23 | +- Optional: `OPENAI_API_KEY` if you want AI features |
| 24 | + |
| 25 | +Backend (from repository root): |
| 26 | + |
| 27 | +```bash |
| 28 | +# build and run the API server |
| 29 | +go build -o bin/nexus ./cmd/nexus |
| 30 | +./bin/nexus server |
| 31 | + |
| 32 | +# or run directly during development |
| 33 | +go run ./cmd/nexus server |
| 34 | +``` |
| 35 | + |
| 36 | +Frontend (from `web`): |
| 37 | + |
| 38 | +```bash |
| 39 | +cd web |
| 40 | +npm install |
| 41 | +npm run dev # starts Nextjs dev server on port 3000 |
| 42 | + |
| 43 | +# production build |
| 44 | +npm run build |
| 45 | +npm run start |
| 46 | +``` |
| 47 | + |
| 48 | +The frontend expects a backend URL during development. See `web/.env.local` for the `NEXT_PUBLIC_BACKEND_URL` and `NEXT_PUBLIC_WS_URL` environment variables. |
| 49 | + |
| 50 | +Environment variables |
| 51 | +- **OPENAI_API_KEY**: optional. Enables AI assisted helpers in the UI and CLI where configured. |
| 52 | +- **NEXT_PUBLIC_BACKEND_URL**: frontend URL for API requests (default: `http://localhost:8080`). |
| 53 | +- **NEXT_PUBLIC_WS_URL**: frontend WebSocket URL for realtime features. |
| 54 | + |
| 55 | +Running a sample collection |
| 56 | + |
| 57 | +There are example collections in `examples/collections`. From the repository root you can try: |
| 58 | + |
| 59 | +```bash |
| 60 | +nexus run examples/collections/demo.yaml |
| 61 | +``` |
| 62 | + |
| 63 | +When running locally via the CLI or UI you will see request and response details, timings, and test results when assertions are present. |
| 64 | + |
| 65 | +Development notes |
| 66 | +- The project is split to keep UI and backend concerns separated. The CLI (`cmd/nexus`) can serve the frontend static build if you prefer a single binary deployment. |
| 67 | +- The backend includes a permissive CORS wrapper for local development; tighten CORS in production. |
| 68 | +- The AI code is abstracted behind an `AIClient` interface — adapters include an OpenAI adapter. Keep keys out of source control and use env vars. |
| 69 | + |
| 70 | +Docker |
| 71 | + |
| 72 | +There is a Dockerfile scaffold for building the backend image. Example build: |
| 73 | + |
| 74 | +```bash |
| 75 | +docker build -t nexus:local . |
| 76 | +docker run --env OPENAI_API_KEY=$OPENAI_API_KEY -p 8080:8080 nexus:local |
| 77 | +``` |
| 78 | + |
| 79 | +Contributing |
| 80 | +- Use the existing unit tests and linters. Run `golangci-lint` for Go linting. |
| 81 | +- Add new collections to `examples/collections` and include tests when appropriate. |
| 82 | + |
| 83 | +Contact and license |
| 84 | +- Repo: https://github.com/ayushedith/nexus |
| 85 | +- License: MIT |
| 86 | + |
| 87 | +Enjoy — if you want, I can also add a short onboarding script that sets up env files and runs the frontend and backend in parallel locally. |
1 | 88 | # NEXUS-API |
2 | 89 |
|
3 | 90 |  |
|
0 commit comments