Skip to content

Commit 046f90f

Browse files
committed
chore: readme update
1 parent 8a6bd7b commit 046f90f

1 file changed

Lines changed: 127 additions & 42 deletions

File tree

README.md

Lines changed: 127 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,168 @@
1-
## LibrarEase Web
1+
# LibrarEase Web
22

3-
A Next.js app for LibrarEase. This repo uses Yarn.
3+
LibrarEase Web is the Next.js frontend for LibrarEase, a library management application for books, members, subscriptions, borrows, reviews, collections, staff, and admin dashboards.
44

5-
**Prereqs**
5+
This guide is for developers who need to run the web app locally.
66

7-
- Node.js 18+ (or 20+ recommended)
8-
- Yarn (classic) — packageManager is set in `package.json`
9-
- Redis (local or hosted)
10-
- Firebase project (client SDK + Admin credentials)
7+
## Requirements
118

12-
## Quick Setup
9+
- Node.js 20 or newer
10+
- Yarn classic, managed through the version pinned in `package.json`
11+
- Redis, either local or hosted
12+
- Firebase project with client configuration and an Admin service account
13+
- Running LibrarEase API service, reachable from this app through `API_URL`
1314

14-
1. Install deps
15+
## Local Setup
16+
17+
### 1. Install dependencies
18+
19+
Enable Corepack so the pinned Yarn version is used:
1520

1621
```bash
17-
yarn install
22+
corepack enable
23+
yarn install --frozen-lockfile
1824
```
1925

20-
2. Configure environment
26+
If your Node installation does not include Corepack, install Yarn classic and then run `yarn install --frozen-lockfile`.
27+
28+
### 2. Create the environment file
2129

22-
Copy the example and fill required values:
30+
Copy the example environment file:
2331

2432
```bash
25-
cp .env.example .env
26-
# or create .env.local in development
33+
cp .env.example .env.local
34+
```
35+
36+
Fill these values before starting the app:
37+
38+
```bash
39+
API_URL=http://localhost:<api-port>
40+
NEXT_PUBLIC_APP_URL=http://localhost:3000
41+
42+
FIREBASE_API_KEY=<firebase-web-api-key>
43+
FIREBASE_AUTH_DOMAIN=<firebase-auth-domain>
44+
FIREBASE_PROJECT_ID=<firebase-project-id>
45+
46+
SESSION_COOKIE_NAME=<session-cookie-name>
47+
REFRESH_TOKEN_COOKIE_NAME=<refresh-token-cookie-name>
48+
LIBRARY_COOKIE_NAME=<library-cookie-name>
49+
CLIENT_ID=<api-client-id>
50+
51+
GOOGLE_APPLICATION_CREDENTIALS=/absolute/path/to/serviceAccountKey.json
52+
53+
REDIS_HOST=localhost
54+
REDIS_PORT=6379
55+
REDIS_PASSWORD=
56+
REDIS_DB=0
2757
```
2858

29-
Required variables (see `.env.example` for the full list):
59+
`GOOGLE_APPLICATION_CREDENTIALS` must point to a Firebase Admin service account JSON file on your machine. Do not commit that file or any filled environment file.
3060

31-
- Firebase client: `FIREBASE_API_KEY`, `FIREBASE_AUTH_DOMAIN`, `FIREBASE_PROJECT_ID`
32-
- Firebase Admin: `GOOGLE_APPLICATION_CREDENTIALS` (absolute path to the service account JSON)
33-
- Redis: `REDIS_HOST`, `REDIS_PORT`, `REDIS_PASSWORD` (optional), `REDIS_DB`
34-
- App URLs: `API_URL`, `NEXT_PUBLIC_APP_URL`
61+
The OpenTelemetry variables in `.env.example` are optional for local development.
3562

36-
3. Start Redis
63+
### 3. Start Redis
3764

38-
On macOS (Homebrew):
65+
With Homebrew on macOS:
3966

4067
```bash
4168
brew install redis
4269
brew services start redis
43-
# default host: localhost, port: 6379
4470
```
4571

46-
Or via Docker:
72+
Or with Docker:
4773

4874
```bash
49-
docker run -p 6379:6379 --name redis -d redis:7
75+
docker run --name librarease-redis -p 6379:6379 -d redis:7
5076
```
5177

52-
4. Run the app
78+
Use the same host, port, password, and database in your environment file.
79+
80+
### 4. Start the backend API
81+
82+
Run the LibrarEase API service separately and set `API_URL` to its base URL, for example:
83+
84+
```bash
85+
API_URL=http://localhost:8000
86+
```
87+
88+
In local development, this app rewrites `/api/*` requests to `${API_URL}/api/*`.
89+
90+
### 5. Run the web app
5391

5492
```bash
5593
yarn dev
56-
# build & run production
57-
yarn build && yarn start
5894
```
5995

60-
Open http://localhost:3000 to view.
96+
Open [http://localhost:3000](http://localhost:3000).
97+
98+
To run the development server with local HTTPS:
99+
100+
```bash
101+
yarn devs
102+
```
103+
104+
## Verify Your Setup
105+
106+
Run these checks before opening a pull request:
107+
108+
```bash
109+
yarn lint
110+
yarn typecheck
111+
yarn build
112+
```
113+
114+
`yarn lint` runs Biome checks, `yarn typecheck` runs TypeScript, and `yarn build` creates a production Next.js build.
115+
116+
## Available Scripts
117+
118+
- `yarn dev`: start the Next.js dev server with Turbopack
119+
- `yarn devs`: start the dev server with experimental local HTTPS
120+
- `yarn devi`: start the dev server with the Node inspector enabled
121+
- `yarn analyze`: run Next.js bundle analysis
122+
- `yarn build`: create a production build
123+
- `yarn start`: start the production server after a build
124+
- `yarn lint`: run Biome checks
125+
- `yarn format`: format code with Biome
126+
- `yarn typegen`: generate Next.js route types and run TypeScript
127+
- `yarn typecheck`: run TypeScript without emitting files
128+
129+
## Common Issues
130+
131+
### The app cannot reach API routes
132+
133+
Check that the backend API is running and that `API_URL` points to its base URL. The value should not include a trailing `/api`.
134+
135+
### Authentication fails locally
136+
137+
Confirm that the Firebase project values match the project used by the backend API. Also verify that the Admin service account path is absolute and readable from your shell.
138+
139+
### Redis connection fails
140+
141+
Confirm Redis is running on the host and port from your environment file. If you are using Docker, make sure the container is still running:
142+
143+
```bash
144+
docker ps
145+
```
146+
147+
### Metadata, sitemap, or absolute URLs look wrong
148+
149+
Set `NEXT_PUBLIC_APP_URL` to the URL where the web app is being served locally, usually `http://localhost:3000`.
61150

62-
## Scripts
151+
## Production Build
63152

64-
- `yarn dev`: Next.js dev server (Turbopack)
65-
- `yarn build`: Production build
66-
- `yarn start`: Start production server
67-
- `yarn lint`: ESLint
68-
- `yarn format`: Prettier format
69-
- `yarn typecheck`: TypeScript type checking
153+
To test the production path locally:
70154

71-
## Firebase Notes
155+
```bash
156+
yarn build
157+
yarn start
158+
```
72159

73-
- Create a Firebase project and enable Authentication as needed
74-
- Place the Admin service account JSON and point `GOOGLE_APPLICATION_CREDENTIALS` to it
75-
- Client keys go in `FIREBASE_*` variables; do not commit secrets
160+
The Dockerfile builds a standalone Next.js server and exposes port `3000`.
76161

77-
## Observability (optional)
162+
## Contributing
78163

79-
If using OpenTelemetry, configure `OTEL_*` variables per `.env.example`.
164+
See [CONTRIBUTING.md](CONTRIBUTING.md) for pull request expectations, code style, and contribution terms.
80165

81166
## License
82167

83-
This software is licensed under the PolyForm Noncommercial License 1.0.0. See the `LICENSE` file for terms. For commercial licensing inquiries, contact: solidifyarmor@gmail.com.
168+
This software is licensed under the PolyForm Noncommercial License 1.0.0. See [LICENSE](LICENSE) for terms. For commercial licensing inquiries, contact solidifyarmor@gmail.com.

0 commit comments

Comments
 (0)