The FCC Book Trading Club is a backend system designed to manage a community-driven book trading platform. Users can register, browse available books, add books to their collection, request trades with other users, and manage incoming and outgoing trade requests. The system ensures secure user authentication, maintains accurate book ownership records, and provides a seamless experience for trading books within the club.
Project Link: freeCodeCamp: Manage a Book Trading Club
. ├── cmd/ # Application entry points │ ├── httpserver/ # HTTP server executable │ ├── worker/ # Background worker executable │ └── migrate/ # Database migration tool ├── docs/ # Documentation and OpenAPI specs │ └── architecture.png # Architecture diagram │ └── diagrams/ # C4 diagrams (system-context, container, component) ├── internal/ # Private application code │ ├── account/ # User account domain module │ ├── book/ # Book domain module │ ├── exchange/ # Exchange/trade domain module │ └── ... # Other modules │ ├── delivery/ # HTTP handlers │ ├── repository/ # Database implementations │ └── usecases/ # Application logic │ domain-model.go # Domain Business logic ├── pkg/ # Public shared packages │ ├── config/ # Configuration handling │ ├── migration/ # Database migration utilities │ ├── hasher/ # Password hashing utilities │ ├── token/ # JWT token utilities │ └── testutil/ # Testing utilities └── tools/ # Scripts and tools └── compose/ # Docker compose files
This project follows the Onion/Clean Architecture pattern.
Key principles:
- Dependencies flow inward
- Inner layers contain business logic
- Outer layers contain implementation details
- Domain entities are at the core
- Each layer is isolated and testable
For detailed architecture, system context, container, and component diagrams, as well as further technical documentation, please refer to the docs folder:
- System Context Diagram
- Container Diagram
- Component Diagram
- Architecture Details
- OpenAPI Specification (if available)
- Go 1.21+
- Docker and Docker Compose
- PostgreSQL 15
- air - Live reload for Go applications
- golangci-lint - Go linters aggregator
- gotestsum - Better test output formatter
- sql-migrate - Database migration tool
-
Clone the repository
git clone https://github.com/ngoctrng/bookz.git
-
Copy environment file and configure
cp .env.example .env
-
Start dependencies
make local-dev
-
Run database migrations
make db/migrate
-
Start the HTTP server
go run cmd/httpserver/main.go
-
Start the background worker
go run cmd/worker/main.go
This project uses swaggo/swag for API documentation.
-
Install swag if you haven't:
go install github.com/swaggo/swag/cmd/swag@latest
-
Generate Swagger docs:
make swagger
-
The generated Swagger UI and OpenAPI spec will be available in the
api
directory.
-
Put the file name
*.puml
in thedocs/diagrams
directory -
Generating the svg from .puml file
make diagram
- cmd - Entry points for executables (httpserver, worker, migrate)
- internal - Private application code
- pkg - Public shared packages
- tools - Development and deployment tools
- docs - Documentation and OpenAPI specs
Run all tests:
make test
Create a new migration:
sql-migrate new -env="development" your-new-migration
Hot reload during development:
make run
Run worker:
make worker
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
MIT