liveBook · Manning

Directory structure

As explained in Rust Servers, Services, and Apps

A project structure is the organization of a software project's files, directories, modules, and related artifacts.

As a Rust web service grows, organize database access, handlers, and models into folders instead of letting each area remain a single file. This shortens individual files and makes code quicker to find, at the cost of added structural complexity. section 6.1

One layout for the evolving service keeps application concerns distinct:

  • `src/bin/iter5.rs` contains `main()`; `src/iter5/routes.rs` holds routes, and `state.rs` and `errors.rs` hold application state and error handling. section 6.1
  • Group course and tutor database access under `dbaccess`, and organize handlers and models into their own folders. section 6.1
  • Keep supporting artifacts in view too: database scripts live under `src/iter5/dbscripts`, while `.env` holds database credentials and should not be checked into the repository. section 6.1
Figure 6.1 Project structure for chapters 5 and 6

Compare the earlier project layout with the reorganized structure. section 6.1

How Rust Servers, Services, and Apps covers it

How deep it goes
Shows a concrete file-and-folder reorganization and its tradeoff, without detailing every resulting file.
Examples
Uses a course-and-tutor service layout with separate database-access, handler, and model folders.
What it assumes
Assumes familiarity with Actix Web services, relational database CRUD, and error handling.
What you can do after
Apply Rust modules to reorganize a growing service into navigable, responsibility-focused folders.
How it connects
Connects project structure to Rust modules, Actix Web, database access, handlers, models, and code refactoring.

Also explained in

Compare how 7 books explain directory structure →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust Servers, Services, and Apps. The section links point to the parts of the book it draws on.