Skip to content

SabaliDev/rust-api-template

Repository files navigation

Rust API Template

This is a template for creating a modular monolithic Rust backend application.

Architecture

The template follows a modular monolithic architecture with the following crates:

  • api: Handles the web API layer (routes, handlers, middleware).
  • db: Manages all database interactions (repositories, services).
  • core: Contains the core business logic and data models.
  • auth: Encapsulates authentication and authorization logic.

How to use this template

  1. Clone this repository.
  2. Run the setup script with your project name:
    ./setup.sh <your-project-name>
    For example:
    ./setup.sh my-todo-app
  3. The script will replace all placeholders with your project name.
  4. (Optional) Rename the directories inside the crates directory to match your project name. For example, rename __PROJECT_NAME__-api to my-todo-app-api.
  5. Start coding!

API Documentation

Swagger UI (Interactive)

  • URL: http://localhost:8080/api/v1/docs/
  • Features: Interactive API testing, request/response examples, schema validation
  • Best for: Testing endpoints, understanding request formats

ReDoc (Clean Documentation)

  • URL: http://localhost:8080/api/v1/docs/redoc
  • Features: Clean, readable documentation with search functionality
  • Best for: Reading API documentation, integration planning

OpenAPI Specification

  • JSON Format: http://localhost:8080/api/v1/docs/openapi.json
  • YAML Format: http://localhost:8080/api/v1/docs/openapi.yaml
  • Use for: Code generation, importing into API tools

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published