Welcome to Prayerloop! This repository, prayerloop-backend, is the primary Go (Golang) server application for Prayerloop. It provides the API endpoints, authentication, and business logic while interfacing with PostgreSQL via the scripts housed in the prayerloop-psql repository.
Below, you’ll find an overview of how this backend fits into the Prayerloop ecosystem, setup instructions, API usage basics, and references to other repositories in the Prayerloop family.
The Prayerloop platform is composed of three major repositories:
-
prayerloop-psql
Holds the PostgreSQL database schema definitions, SQL scripts, and shell scripts for setup/migrations. -
prayerloop-backend (this repo)
A Go-based server that provides RESTful API endpoints, orchestrates database interactions, and manages user authentication/authorization. -
prayerloop-mobile
A React Native mobile application enabling users to interact with the Prayerloop platform on iOS and Android devices.
- Golang REST API
Provides endpoints for user management, prayer creation, updating, retrieval, etc. - Database Integration
Connects to PostgreSQL using the schemas and scripts from prayerloop-psql. - Authentication & Authorization
Secure handling of user credentials, session management, and role-based checks. - Scalable Architecture
Utilizes Go’s concurrency and performance benefits for high availability.
- Go (1.18+ recommended)
- PostgreSQL (12+ recommended)
- GOPATH properly configured (if needed), or using Go modules with a recent Go version.
- Clone the Repository
git clone https://github.com/zdelcoco/prayerloop-backend.git cd prayerloop-backend- Install Dependencies
Go modules should handle dependencies automatically:
go mod tidy- Configure Environment Variables
The backend typically requires environment variables to be set for database connection details. For example:
DB_HOST=localhost DB_PORT=5432 DB_USER=prayerloop_user DB_PASSWORD=some_password DB_NAME=prayerloop JWT_SECRET=supersecretkeyAdjust names/secrets as needed. You might store these in a .env file or supply them in your deployment environment.
- Database Setup
- Ensure you have run the prayerloop-psql SQL scripts to create the schema and any seed data in your PostgreSQL instance.
- Confirm that the configured environment variables match your PostgreSQL credentials and database name.
- Run the Server
go run main.goor
go build -o prayerloop && ./prayerloopThe application will typically listen on a configured port (e.g., :8080). Check logs for confirmation or error messages.
Once the server is running:
-
Authentication
Use a JWT or session token (as configured) in theAuthorizationheader for restricted endpoints. -
JWT Session Handling: Sessions are not stored in the database. Instead, the Go middleware issues a JWT upon login containing key details (e.g., admin status, login time), which expires after 24 hours.
-
API Endpoints
Access the endpoints viahttp://localhost:8080(or whatever host/port you configured). The available endpoints are:-
Endpoints requiring no auth headers
GET /pingHealth check endpoint.POST /loginUser login.
-
User endpoints
POST /usersUser signup.GET /users/meGet current user profile.GET /users/:user_profile_id/groupsGet groups for a specific user.GET /users/:user_profile_id/prayersGet prayers for a specific user.POST /users/:user_profile_id/prayersCreate a prayer for a specific user.GET /users/:user_profile_id/preferencesGet preferences for a specific user.PATCH /users/:user_profile_id/preferences/:preference_idUpdate a preference for a specific user.
-
Notification endpoints
GET /users/:user_profile_id/notificationsGet notifications for a specific user.PATCH /users/:user_profile_id/notifications/:notification_idToggle notification status for a specific user.
-
Group endpoints
GET /groupsGet all groups.POST /groupsCreate a new group.GET /groups/:group_profile_idGet details for a specific group.PUT /groups/:group_profile_idUpdate a specific group.DELETE /groups/:group_profile_idDelete a specific group.GET /groups/:group_profile_id/prayersGet prayers for a specific group.POST /groups/:group_profile_id/prayersCreate a prayer for a specific group.GET /groups/:group_profile_id/usersGet users in a specific group.POST /groups/:group_profile_id/users/:user_profile_idAdd a user to a specific group.DELETE /groups/:group_profile_id/users/:user_profile_idRemove a user from a specific group.
-
Invite endpoints
POST /groups/:group_profile_id/inviteCreate an invite code for a specific group.POST /groups/:group_profile_id/joinJoin a specific group.
-
Prayer endpoints
PUT /prayers/:prayer_idUpdate a specific prayer.DELETE /prayers/:prayer_idDelete a specific prayer.POST /prayers/:prayer_id/accessAdd access to a specific prayer.DELETE /prayers/:prayer_id/access/:prayer_access_idRemove access from a specific prayer.
-
Admin only routes (backend use only)
GET /prayersGet all prayers.GET /prayers/:prayer_idGet details for a specific prayer.
-
-
To run tests, if provided:
go test ./...
or refer to the Makefile (if included) for any specialized commands.
- Testing may include unit tests for handlers, database interactions, or integration tests.
- prayerloop-psql
PostgreSQL database schema scripts and migrations. - prayerloop-mobile
React Native mobile app for iOS/Android that consumes the backend API.
Contributions are welcome! Whether you’re adding new features, fixing bugs, or improving documentation, feel free to open an issue or pull request. For major changes, please discuss them in an issue first to avoid duplication of effort.
This project is licensed under the MIT License.
- Issues & Support: Submit an issue or open a discussion for any questions, proposals, or feedback.
- For more information on the overall project, see also:
- prayerloop-psql issues
- prayerloop-mobile issues