How masudrana430/web-test-masudrana430 works
1. Monorepo shape
Chirp is a pnpm + Turborepo monorepo with three deployable apps and several shared packages. The major runtime boundaries are: apps/api for backend services, apps/client-user for the consumer UI, and apps/client-admin for moderation/admin UI.
2. Backend core
The API server in apps/api is a gRPC service, not a REST API. Request handling is split into gRPC handlers under src/grpc/handlers and business logic services under src/services. The handlers are the transport boundary; services contain the feature logic.
3. Contract-first service layer
packages/proto is the service contract source of truth. Proto files define services such as auth, users, posts, comments, likes, follows, bookmarks, notifications, search, and admin. Generated proto artifacts are consumed by the API and client-side gRPC code.
4. Client-to-server flow
Both frontends are TanStack Start apps with server functions under src/server/functions. Those server functions act as the app boundary: route components call server functions, and the server functions use packages/grpc-client to talk to the API over gRPC. This keeps browser code off the direct backend boundary.
5. Two separate frontends
apps/client-user is the consumer social app with routes for auth, feed, explore, posts, profiles, bookmarks, notifications, and search. apps/client-admin is a separate admin console focused on moderation, audits, reports, users, and post/comment management. They share the same backend and data model but have different UI and authorization surfaces.
6. Authentication and session boundary
Auth is handled in the API via the auth service and in each client via server-side session helpers. The user app has login/register flows; the admin app has a stronger auth gate and admin-specific server auth logic. Session state is kept at the app/server-function layer rather than in shared client state.
7. Domain services and data flow
The backend service layer is organized by domain: posts, comments, likes, follows, bookmarks, feed, notifications, search, users, mentions, and admin. Typical flows are: user action in client route -> server function -> gRPC client -> API handler -> domain service -> SQLite via Drizzle -> response back through gRPC to the app.
8. Persistence layer
Persistence is SQLite, with schema definitions in packages/db-schema and migrations in db/migrations. The API owns database access through apps/api/src/db, and seed data is in apps/api/src/db/seed.ts. The database tables mirror the product domains: users, posts, comments, likes, follows, bookmarks, notifications, reports, and audit logs.
9. Shared UI and types
packages/ui is a shared design system built with StyleX components such as Button, Card, Input, TextArea, Avatar, and loading primitives. packages/shared-types provides common TypeScript types for API/session data. These packages reduce duplication across both client apps.
10. Feature-specific frontend composition
The user app is organized around reusable feature components like PostCard, CommentCard, FollowButton, NotificationBell, and post/comment forms. Routes are file-based and page-specific, while server functions isolate backend calls per feature. The admin app follows the same pattern but with moderation-oriented routes and layout components such as AdminHeader.
11. Infra and tooling
Styling is managed with StyleX tokens in each app and shared UI package. TypeScript is strict and centralized with shared configs under tooling/typescript. Biome handles linting/formatting. Vitest covers unit tests, Playwright covers end-to-end tests, and GitHub Actions runs the test workflow.
12. Operational boundaries
The README documents three local service endpoints: user app on 3000, admin app on 3002, and API on 3001 with a health check. That separation is important for a diagram: the browsers hit the two TanStack Start apps, and only those apps talk to the API backend and database indirectly through gRPC.
Main entry points: api API · client-user User app · client-admin Admin app · test.yml CI workflow
Components 20
Apps
Deployable API and client runtimes
- API · Backend runtime for auth, social domains, and admin operations
apps/api - gRPC handlers · Service entrypoints that map proto requests into backend operations
apps/api/src/grpc/handlers - Domain services · Feature logic for auth, posts, comments, feed, search, and moderation
apps/api/src/services - DB access · Database access and seeding owned by the API
apps/api/src/db - User app · Consumer social frontend for browsing, posting, and discovery
apps/client-user - Server functions · Server-side feature functions that call the API through gRPC
apps/client-user/src/server/functions - User routes · File-based pages for auth, feed, posts, profiles, bookmarks, notifications, and search
apps/client-user/src/routes - Feature UI · Reusable social UI such as posts, comments, follows, notifications, and shared primitives
apps/client-user/src/components - Admin app · Moderation console for audits, reports, users, and content management
apps/client-admin - Admin functions · Server-side auth and admin feature calls into the API
apps/client-admin/src/server/functions - Admin routes · Moderation-focused pages for login, audit, reports, users, posts, and comments
apps/client-admin/src/routes - Admin UI · Admin layout and shared console components
apps/client-admin/src/components
Packages
Shared contracts, UI, and client libraries
- Proto contracts · Service definitions and generated contract surface for API and clients
packages/proto - gRPC client · Shared client used by both frontends to call the API
packages/grpc-client - DB schema · Shared Drizzle schema for SQLite tables and relations
packages/db-schema - UI kit · Shared StyleX components and tokens
packages/ui - Shared types · Common API and session TypeScript types
packages/shared-types
Infra
Database, migrations, and tooling
- Migrations · Database migration history for the shared schema
db/migrations - TS tooling · Shared TypeScript base and React configs
tooling/typescript - CI workflow · Repository test workflow
.github/workflows/test.yml
Connections 22
- User routes → Server functions: calls · Route components invoke server functions
- Server functions → gRPC client: uses · Client app functions call the shared gRPC client
- Admin routes → Admin functions: calls · Admin pages invoke server functions
- Admin functions → gRPC client: uses · Admin functions call the shared gRPC client
- gRPC client → Proto contracts: typed by · Client stubs are generated from service contracts
- gRPC handlers → Proto contracts: implements · Handlers realize the contract-defined services
- gRPC handlers → Domain services: delegates · Transport layer forwards into domain logic
- Domain services → DB access: persists · Services read and write through the API-owned database layer
- DB access → DB schema: uses · Database layer is shaped by the shared schema package
- DB schema → Migrations: evolves into · Schema changes are captured in migration files
- User app → UI kit: renders with · Consumer frontend uses shared design system components
- Admin app → UI kit: renders with · Admin frontend uses shared design system components
- User app → Shared types: shares types · User app consumes common API and session types
- Admin app → Shared types: shares types · Admin app consumes common API and session types
- API → gRPC handlers: hosts · API runtime exposes gRPC handlers
- API → Domain services: contains · API runtime includes the domain service layer
- API → DB access: owns · API runtime owns database access
- User app → API: calls via gRPC · Browser flows reach the backend only through server functions and the client library
- Admin app → API: calls via gRPC · Admin flows reach the backend only through server functions and the client library
- CI workflow → User app: tests · Workflow exercises the user app
- CI workflow → Admin app: tests · Workflow exercises the admin app
- CI workflow → API: tests · Workflow exercises the API runtime