-
Notifications
You must be signed in to change notification settings - Fork 0
Enhances Backend with PostgreSQL, Docker & Auth Refactor #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
FinnTheHero
wants to merge
50
commits into
master
Choose a base branch
from
development
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… improve error messages
Elevates the Go language version from 1.23.0 to 1.25.0, benefiting from the latest language features and performance enhancements. Removes several direct and indirect dependencies that are no longer needed, such as Firebase and Heroku-related modules, streamlining the module graph. Adjusts various indirect dependencies, including promoting `google.golang.org/api` and `google.golang.org/grpc` to indirect status and integrating new OpenTelemetry SDK components. These changes reflect an overall cleanup and update of the module graph.
Refactors CreatedAt and UpdatedAt fields in domain models (Chapter, Novel) from string to time.Time. This improves type safety and enables proper date and time operations within the application.
Introduces a new PostgreSQL client with connection pooling and schema initialization on application startup. Defines relational schemas for novels and chapters, incorporating hash partitioning for chapters and an index for efficient seek pagination. Implements data access patterns for novels and chapters, including atomic chapter indexing and cursor-based pagination. All previous Firestore client and collection logic has been removed.
Updates the database client factory to no longer require an explicit connection string argument. The connection string is now handled internally by the client, streamlining initialization logic.
Introduces a `ClientConfig` struct for explicit database connection pool settings, enhancing configurability. Updates `NewClientWithConfig` to accept the `ClientConfig` struct, including basic validation for connection limits. Modifies `GetClient` to retrieve the connection string from environment variables and apply production-ready default connection pool settings. Ensures the global database client singleton is properly reset and reinitialized after `Close()`. Refactors the database package by moving collection files out of the `collections` subdirectory. Changes the database client package name to `db`.
Introduces a unified `db` abstraction for database client access, removing direct Firestore dependencies from the service layer. Streamlines service methods by delegating ID generation, timestamp management, and soft-delete logic to the new database abstraction. This simplifies service logic and removes boilerplate. Converts service method return types from pointers to values (`*domain.Type` to `domain.Type`), standardizing data handling and error propagation (e.g., explicit nil checks for "not found" cases are replaced with direct error returns). Enhances the `FindAllChapters` API endpoint to support pagination (`size`) and sorting order (`ascending`) via query parameters. Updates middleware token generation and user loading to align with the new value-based `domain.User` handling.
Sets up the schema migration tracking table. Creates core tables for users, novels, and chapters, including essential indexes. Implements hash partitioning for the chapters table to optimize performance and scalability. Introduces a soft-delete mechanism for users and novels by adding a `deleted` column.
Introduces a dedicated migration runner to manage database schema evolution using SQL script files, replacing the ad-hoc `EnsureSchema` logic. Refactors `ListChaptersSeek` to accept a `CursorOptions` struct, enhancing parameter clarity. Updates `DeleteChapter` to require `novel_id`, improving deletion data integrity. Adds `CreateNovelFromEpub` for atomic creation of a novel with batch chapter insertion. Enriches novel retrieval queries to fetch full metadata including timestamps and deletion status. Simplifies `CreateUser` by allowing the database to handle ID generation.
Introduces specific data structures for handling novel and chapter creation requests. This also includes dedicated types for uniquely identifying novels and chapters, streamlining API interactions and ensuring consistent data representation across the domain layer.
Moves resource IDs (novel and chapter) from URL path parameters to the request body for Create, Update, Delete, and specific chapter retrieval operations. Simplifies the FindNovel endpoint to exclusively use the novel ID from the path. Enhances validation for chapter pagination page size and ascending query parameter values. Temporarily disables authentication middleware.
Refactors chapter and novel services to use dedicated DTOs for creation and updates, enhancing API clarity. Streamlines the EPUB import process into a single database operation for novel and chapter creation. Introduces chapter indexing for correct ordering and enforces `novelId` for chapter deletion. Adjusts user registration by removing a redundant email existence check.
Updates the base Go version for building both the web and worker Docker images to `golang:1.25-alpine`. This keeps the development environment current with the latest Go release.
Ensures critical application resources, specifically the .env configuration file and database migrations/ directory, are copied with appropriate ownership (appuser:appgroup). This prevents potential permission issues and aligns with security best practices for running applications as non-root users within Docker containers.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request significantly updates the backend infrastructure and features:
Database Transition & Schema:
Containerization:
.dockerignorefile for optimized Docker build contexts.Procfile, as Dockerfiles now manage service execution.Authentication & Token Management:
Username, providing more comprehensive user information.System Improvements:
/healthendpoint for service monitoring.GIN_MODEconfiguration and improves robust domain parsing for environment variables.time.Timefor better type safety and handling.