The Circle platform is architected as a modern, decoupled monolithic application. It consists of a robust RESTful API backend and a responsive Single Page Application (SPA) frontend. The system is designed for scalability, maintainability, and ease of deployment.
graph TD
Client[Client Browser]
FE[Frontend SPA (React/Vite)]
BE[Backend API (Node/Express)]
DB[(PostgreSQL)]
Redis[(Redis Cache)]
Cloudinary[Cloudinary Media]
Client -->|HTTPS| FE
FE -->|REST API/JSON| BE
BE -->|Prisma ORM| DB
BE -->|Caching| Redis
BE -->|Media Upload| Cloudinary
The project is structured as a Monorepo, but enforces clear logical separation between concerns.
- Responsibility: Handles user interaction, presentation logic, and state management.
- Communication: Consumes the Backend API via HTTP requests (using Axios).
- Key Libraries: React, Redux Toolkit, Chakra UI, React Router.
- Build System: Vite.
- Responsibility: Handles business logic, data persistence, authentication, and authorization.
- Communication: Exposes RESTful endpoints documented via Swagger.
- Key Libraries: Express, Prisma, Zod (Validation), JSON Web Token (JWT).
- Runtime: Node.js.
The backend implementation follows a Controller-Service-Repository pattern (or similar modular structure) to separate concerns.
- API Layer (Controllers): Handles HTTP requests, parses input, validates using Zod, and sends responses.
- Service Layer: Implementing business logic and transaction management.
- Data Access Layer (Prisma): Interacts directly with the PostgreSQL database.
- Middleware: Handles cross-cutting concerns like Authentication (
auth middleware), Error Handling, and Logging.
The frontend is built using a component-based architecture.
- Pages: Top-level components representing routes.
- Components: Reusable UI elements (Buttons, Cards, Inputs).
- Store (Redux): Global state management for user sessions and cached data.
- Hooks: Custom React hooks for encapsulating logic (e.g.,
useAuth).
- Protocol: HTTP/1.1 (HTTPS in production).
- Format: JSON.
- Authentication: Bearer Token (JWT) passed in the
Authorizationheader.
- Database: Connection via TCP/IP to PostgreSQL instance.
- Redis: Used for caching frequently accessed data and session management.
- Cloudinary: Direct upload or proxy upload for handling user-generated content (images/videos).
- Data Transport: All traffic encrypted via TLS/SSL.
- Data at Rest: Sensitive data (passwords) hashed using bcrypt before storage.
- Input Validation: Strict validation on both client and server sides (Zod).
- CORS: Configured to allow requests only from trusted frontend domains.
- Stateless Backend: The Node.js application is stateless, allowing for horizontal scaling behind a load balancer.
- Caching Strategy: Redis is employed to reduce database load for read-heavy operations.
- Database Optimization: Prisma migrations manage schema evolution; indexing strategies applied to frequently queried fields.