Skip to content
/ bookz Public

The FCC Book Trading Club is a backend system designed to manage a community-driven book trading platform.

License

Notifications You must be signed in to change notification settings

ngoctrng/bookz

Repository files navigation

coverage coverage

FCC Book Trading Club

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

Project Structure

.
├── 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

Architecture

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

Documentation

For detailed architecture, system context, container, and component diagrams, as well as further technical documentation, please refer to the docs folder:

Prerequisites

  • Go 1.21+
  • Docker and Docker Compose
  • PostgreSQL 15

Development Tools

Getting Started

  1. Clone the repository

    git clone https://github.com/ngoctrng/bookz.git
  2. Copy environment file and configure

    cp .env.example .env
  3. Start dependencies

    make local-dev
  4. Run database migrations

    make db/migrate
  5. Start the HTTP server

    go run cmd/httpserver/main.go
  6. Start the background worker

    go run cmd/worker/main.go

Generating document

OpenAPI

This project uses swaggo/swag for API documentation.

  1. Install swag if you haven't:

    go install github.com/swaggo/swag/cmd/swag@latest
  2. Generate Swagger docs:

    make swagger
  3. The generated Swagger UI and OpenAPI spec will be available in the api directory.

C4 model diagrams

  1. Put the file name *.puml in the docs/diagrams directory

  2. Generating the svg from .puml file

    make diagram

Development

Project Layout

  • 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

Testing

Run all tests:

make test

Database Migrations

Create a new migration:

sql-migrate new -env="development" your-new-migration

Development Tools

Hot reload during development:

make run

Run worker:

make worker

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

License

MIT

About

The FCC Book Trading Club is a backend system designed to manage a community-driven book trading platform.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages