Skip to content

Sus-Nexus07/naija-stats-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Naija Stats API

A RESTful API built from scratch with Go — no frameworks, no shortcuts. Manages football teams and players with full CRUD operations and persistent JSON file storage.

Built as a practical backend engineering project to learn how real APIs work at the HTTP level.


Tech Stack

  • Language: Go
  • Packages: net/http, encoding/json, os
  • Storage: JSON file-based persistence
  • Testing: curl / Postman

Project Structure

naija-stats-api/
│
├── main.go        ← server entry point + route registration
├── handlers.go    ← HTTP route handlers (GET, POST, PUT, DELETE)
├── models.go      ← data structs (Team, Player) + in-memory state
├── storage.go     ← file read/write (loadData, saveData)
├── go.mod         ← Go module config
└── README.md

Getting Started

Clone the repository:

git clone https://github.com/Sus-Nexus07/naija-stats-api.git
cd naija-stats-api

Run the server:

go run .

Server starts at http://localhost:8080


API Endpoints

Teams

Method Endpoint Description
GET /teams Get all teams
POST /teams Add a new team

GET /teams

curl http://localhost:8080/teams
[
  { "id": 1, "name": "Enyimba", "country": "Nigeria" },
  { "id": 2, "name": "Arsenal", "country": "England" }
]

POST /teams

curl -X POST http://localhost:8080/teams \
  -H "Content-Type: application/json" \
  -d '{"name":"Barcelona","country":"Spain"}'

Players

Method Endpoint Description
GET /players Get all players
POST /players Add a new player
PUT /players/{id} Update a player
DELETE /players/{id} Delete a player

GET /players

curl http://localhost:8080/players
[
  { "id": 1, "name": "Victor Osimhen", "team": "Napoli", "country": "Nigeria" },
  { "id": 2, "name": "Ademola Lookman", "team": "Atalanta", "country": "Nigeria" }
]

POST /players

curl -X POST http://localhost:8080/players \
  -H "Content-Type: application/json" \
  -d '{"name":"Samuel Chukwueze","team":"AC Milan","country":"Nigeria"}'

PUT /players/{id}

curl -X PUT http://localhost:8080/players/1 \
  -H "Content-Type: application/json" \
  -d '{"name":"Victor Osimhen","team":"Galatasaray","country":"Nigeria"}'

DELETE /players/{id}

curl -X DELETE http://localhost:8080/players/1

🚧 Roadmap

  • PostgreSQL integration (replace JSON file storage)
  • Search and filter (players by team, country)
  • Authentication with JWT
  • Team update and delete routes
  • Get player or team by ID
  • Pagination
  • Docker support
  • API documentation with Swagger
  • Deploy to cloud (Railway / Render)

Author

Richard Obodo Backend Developer (Go) Learning backend engineering through practical projects and real-world APIs.

About

A REST API built with Go — full CRUD with file persistence

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages