The Client for Codergrounds. Built with React and TypeScript, following a Feature-First Architecture.
This project follows a Feature-First Architecture that scales with the application by grouping related logic (UI, State, API) together within features, while keeping shared utilities and core infrastructure separate.
The architecture is organized into four main layers:
features/- Feature-based modules (business domain logic)shared/- Reusable code with no feature dependenciesservices/- Infrastructure & external integrationsapp/- Application configuration & providers
src/
├── app/ # Application configuration & Providers
│ ├── router/ # Route definitions & Guard wrappers
│ ├── store/ # Global Redux store configuration
│ ├── providers/ # Context providers (Theme, Toast, etc.)
│ ├── App.tsx # Root component
│ └── main.tsx # Entry point
│
├── features/ # Feature-based specific modules
│ ├── auth/ # Authentication Feature
│ │ ├── api/ # RTK Query API definitions
│ │ ├── components/ # Feature-specific UI components
│ │ ├── hooks/ # Feature-specific hooks
│ │ ├── slice/ # Redux slices (state)
│ │ ├── routes/ # Feature internal routes
│ │ └── index.ts # Public API of the feature
│ │
│ ├── playground/ # Coding Playground Feature
│ │ ├── components/ # Editor, Terminal, FileTree
│ │ ├── services/ # Feature-specific services
│ │ ├── store/ # Playground specific state logic
│ │ └── index.ts
│ │
│ └── user/ # User Profile/Settings Feature
│
├── shared/ # Reusable code (No feature dependencies)
│ ├── components/ # UI Kit (Atomic, dumb components)
│ │ ├── ui/ # Headless UI implementations
│ │ ├── layout/ # Layout components
│ │ └── forms/ # Form primitives
│ ├── hooks/ # Global hooks
│ ├── utils/ # Pure utility functions
│ ├── types/ # Global TypeScript types
│ └── assets/ # SVGs, Images, Global Styles
│
├── services/ # Infrastructure & External Integrations
│ ├── api/ # Base API setup (RTK Query baseQuery)
│ ├── socket/ # Socket.io singleton & connection management
│ ├── storage/ # LocalStorage/SessionStorage wrappers
│ └── logger/ # Frontend logger/Analytics wrapper
│
└── config/ # Environment & Constant configurations
├── env.config.ts
└── breakpoints.config.ts
- Feature Isolation: Each feature is self-contained with its own components, state, and API logic
- Shared Foundation:
shared/contains only reusable code with no business logic dependencies - Separation of Concerns: Server state (RTK Query) vs Client state (Redux slices)
- Single Responsibility: One feature = one business domain
- No Cross-Feature Dependencies: Features communicate via global store or shared events
app/ (Main Entry)
↓
features/ (Auth, Playground, User)
↓
shared/ (UI Kit, Utils) & services/ (API, Socket)
Dependency Rules:
features/→ Can import fromshared/andservices/✅shared/→ Can only import fromshared/or external packages ✅services/→ Can only import fromshared/or external packages ✅app/→ Can import fromfeatures/,shared/, andservices/✅- NEVER create circular dependencies
- AVOID direct imports between features
This project uses Redux Toolkit with RTK Query for state management, splitting state into two categories:
Managed entirely by RTK Query:
- Do not manually fetch data in
useEffectand store in Redux - Use
useGetPlaygroundQueryhooks directly in components - Cache invalidation tags handle updates
- API endpoints are defined in
features/*/api/
Managed by Redux Slices:
- Examples: "Is Modal Open", "Current Selected File Path", "Terminal History"
- Located in
features/*/slice/ - Use for UI state that doesn't come from the server
We use TailwindCSS v4 for scoped, maintainable styling with BEM (Block Element Modifier) naming convention if using custom css styles.
Consistent breakpoints are defined in @/config/breakpoints.config.ts:
- Mobile (sm):
< 640px - Tablet (md):
640px - 1023px - Desktop (lg):
>= 1024px
All CSS classes in module files must follow the BEM methodology:
- Block: The main component (e.g.,
.button,.header) - Element: Part of the block, separated by
__(e.g.,.button__icon,.header__nav) - Modifier: Variation of block/element, separated by
--(e.g.,.button--primary,.input__field--error)
- React: UI library with hooks
- TypeScript: Type-safe development
- TailwindCSS: CSS Library
- Redux Toolkit: State management
- RTK Query: Server state management and data fetching
- React Router: Client-side routing
- Socket.io: Real-time collaboration and updates
- CSS Modules: Scoped component styling
- Vite: Build tool and dev server
- Monaco Editor: Code editor component
pnpm dev: Start development server with hot module replacementpnpm build: Build production bundle todist/pnpm preview: Preview production build locallypnpm lint: Lint code with ESLint
- Install dependencies:
pnpm install - Set up environment variables: Copy
.env.exampleto.envand configure - Start development server:
pnpm dev - Open browser: Navigate to
http://localhost:5173(or the port shown in terminal)
Real-time features (collaboration, live updates) are handled via Socket.io:
- Connection: Established in
App.tsxor Auth wrapper usingservices/socket - Global Events: Handled in custom middleware or global hooks
- Feature Events: Handled inside Feature components using
useEffectthat listens to thesocketServiceinstance
- Components: React Testing Library - Test behavior, not implementation details
- Logic: Pure functions in
utils/or complex Redux selectors - Integration: Test full feature flows mocking the API via MSW (Mock Service Worker) or simple Redux mocks